Advance Java Mock Question
Advance Java Mock Question
Test1
Total points 29/40
0 of 0 points
Name: *
Centre: *
Juhu
Kharghar
PRN: *
230340320063
MCQ 29 of 40 points
The worst-case time complexity *1/1
for the linear search algorithm
is….
O(n)
O(log n)
O(n²)
O(n log n)
Correct answer
25,12,16,13,10,8,14
25,14,16,13,10,8,12
25,16,12,13,10,8,14
25,14,12,13,10,8,16
Let H be a binary min-heap *1/1
consisting of n elements
implemented as an array. What
is the worst-case time
complexity of an optimal
algorithm to find the maximum
element in H?
Ө(1)
Ө(log n)
Ө(n)
Ө(n log n)
6
Which of the following algorithm *1/1
design techniques is used in
finding all pairs of shortest
distances in a graph ( Warshall
algorithms)?
Dynamic programming
Back Tracking
Greedy
T(n) = 2T(n-2)+2
T(n) = 2T(n-1)+n
T(n) = 2T(n/2)+1
T(n) = 2T(n-1)+1
In which of the following tree do *1/1
the height of the left subtree and
the height of the right subtree
differ at most by one?
AVL Tree
Expression Tree
Correct answer
2
Which of the following types of *1/1
Linked List support forward and
backward traversal?
All of these
Suppose prevnode, p, nextnode *0/1
are three consecutive nodes in a
Doubly Linked List. Deletion of
node p in this Doubly Linked List
can be represented by which
code snippet?
p.getPrev().setPrev(p.getNext());
p.getNext().setNext(p.getPrev());
p.getPrev().setNext(p.getPrev());
p.getNext().setPrev(p.getNext());
p.getNext().setPrev(p.getPrev());
p.getPrev().setNext(p.getNext());
Correct answer
p.getNext().setPrev(p.getPrev());
p.getPrev().setNext(p.getNext());
Let ‘m’ and ‘n’ be the number of *1/1
edges and vertices in a graph G,
respectively. Which of the
following is the time complexity
of Kruskal's algorithm to find the
minimum spanning tree of G?
O(n log n)
O(m log m)
O(n2)
O(m2)
Timestamp comparison
None of these
In the worst case, the number of *1/1
comparisons needed to search a
singly linked list of length n for a
given element is
O(log2 n)
O(n/2)
O(log2 n – 1)
O(n)
Optimal Search
Random Search
Heuristic Search
Stratieed Search
The postfix equivalent of prefix *0/1
expression * + a b – c d is
ab+cd-*
abcd+-*
ab+cd*-
ab+-cd*
Correct answer
ab+cd-*
Median-of-three partitioning
method
Correct answer
Prim’s algorithm
Dijkstra's algorithm
Bellman-Ford algorithm
Floyd-Warshall’s algorithm
Digest
Hash value
Hash code
All of these
Which of the following are not *1/1
Associative Containers?
priority queue
map
multimap
multiset
O(1)
O(logn)
O(n)
O(nlogn)
What are the time complexities *0/1
of finding the 8th element from
the beginning and the 8th
element from the end in a singly
linked list? Let n be the number
of nodes in a linked list, you may
assume that n > 8.
Correct answer
Tree
Stack
Queue
Linked list
The height of a binary tree is the *1/1
maximum number of edges in
any root-to-leaf path. The
maximum number of nodes in a
binary tree of height h is:
2^h -1
2^(h-1) – 1
2^(h+1) -1
2*(h+1)
23,32,45,69,72,73,89,97
Selection sort
Merge sort
Insertion sort
Correct answer
n(n-1)/2
n(n-1)/4
n(n+1)/4
2n[logn]
Correct answer
n(n-1)/4
A complete n-ary tree is a tree in *1/1
which each node has n children
or no children. Let I be the
number of internal nodes and L
be the number of leaves in a
complete n-ary tree. If L = 41,
and I = 10, what is the value of
n?
Leaf node
Root node
Parent node
Ancestor node
A digraph is said to be *0/1
COMPLETE, if it has N vertices
and ………edges.
N*N
N-1
N*(N-1)
N*(N-1)/2
Correct answer
N*(N-1)
O(log n)
O(n)
O(1)
O(n2)
In the worst case, the number of *1/1
comparisons needed to search a
singly linked list of length n for a
given element is---
log2 n
n/2
log2 (n-1)
Push(54);push(52);pop();push(5
5);push(62);s=pop();
enqueuer(21);
enqueuer(24);
dequeuer();
enqueuer(28);
enqueuer(32);
q=dequeuer();
62
24
86
68
What would be the order in *0/1
which edges are added to form
a minimum spanning tree using
Kruskal’s and Prim’s algorithms
for the following graph:
Kruskal’s – CD AB CF FE AE and
Prim’s - AB AE FE CF CD
Correct answer
Θ(∣E∣ + ∣V∣)
Θ(∣E∣.∣V∣)
Θ(∣V∣)
I, III, II, IV
I, II, III, IV
Correct answer
I, III, II, IV
Forms
ADS Mock CCEE
Total points 25/40
0 of 0 points
230340320063
Center *
Kharghar
Name *
Questions 25 of 40 points
Which of the following *0/1
statements for a simple graph is
correct?
Correct answer
a) O(n)
b) O(log n)
c) O(n^2)
d) O(n log n)
What is the time complexity of *1/1
enqueue and dequeue
operations in a circular queue of
size n?
a) O(1)
b) O(log n)
c) O(n)
d) O(n^2)
40
74
-18
The postfix form of the *0/1
expression (A+ B)*(C*D- E)*F / G
is?
b) AB + CD* E – F **G /
c) AB + CD* E – *F *G /
d) AB + CDE * – * F *G /
Correct answer
c) AB + CD* E – *F *G /
a) Ordinary queue
c) Circular queue
d) Priority queue
a) log(n)
b) n/2
c) log(n+1)
d) n
Correct answer
c) log(n+1)
Kruskal’s algorithm is used to *1/1
______
b) Greedy algorithm
c) Dynamic Programming
d) Approximation algorithm
What is the disadvantage of *1/1
selection sort?
b) It is not scalable
12345
43215
32145
21345
What are the disadvantages of *0/1
recursion?
Correct answer
a) (rear + 1) % n == front
b) (front + 1) % n == rear
c) (rear - front + 1) % n == 0
d) (front - rear + 1) % n == 0
What will be output of the code? *0/1
a) 3
b) 6
c) 9
d) Error: NullPointerException
Correct answer
a) 3
A flowchart needs to represent a *1/1
situation where the user is
asked to enter his age, the age is
read into the system, and the
system outputs a 'Thank You'
message.
Decision
Loop
Sequence
a) Array
b) Stack
c) Queue
d) Linked List
Correct answer
c) Queue
What is the number of edges *0/1
present in a complete graph
having n vertices?
a) (n*(n+1))/2
b) (n*(n-1))/2
c) n
d) n(n*1)/2
Correct answer
b) (n*(n-1))/2
Consider the following heap *0/1
after buildheap phase. What will
be its corresponding array?
(What will be MAX HEAP)
a) 26,53,41,97,58,59,31
b) 26,31,41,53,58,59,97
c) 26,41,53,97,31,58,59
d) 97,53,59,26,41,58,31
Correct answer
d) 97,53,59,26,41,58,31
How many times is the *1/1
recursive function called, when
the following code is executed?
a) 9
b) 10
c) 11
d) 12
Which of the following is not a *0/1
characteristic of a good
algorithm?
a) Correctness
b) Efficiency
c) Complexity
d) Simplicity
Correct answer
c) Complexity
a) Bubble Sort
b) Insertion Sort
c) Quicksort
d) Selection Sort
How many swaps are required *0/1
to sort the given array using
bubble sort – { 2, 5, 1, 3, 4}
a) 4
b) 6
c) 8
d) 5
Correct answer
a) 4
Consider an implementation of *1/1
unsorted singly linked list.
Suppose it has its
representation with a head
pointer only.
Given the representation, which
of the following operation can
be implemented in O(1) time?
a) I and II
b) I and III
c) I, II and III
d) I, II and IV
In a binary tree, the maximum *1/1
number of nodes at level i is
given by:
a) 2^i
b) i^2
c) 2^(i-1)
d) i+1
a) Counting microseconds
a) O(1)
b) O(log n)
c) O(n)
d) O(n log n)
Correct answer
d) O(n log n)
How does function complexity *0/1
change during recursion?
Correct answer
a) N
b) N - 1
c) 2N - 1
d) 2N
What is the time complexity of *1/1
removing an element from the
middle of an ArrayList?
a) O(1)
b) O(log n)
c) O(n)
d) O(n^2)
a) Selection sort
b) Insertion sort
c) Bubble sort
d) Merge sort
From the given expression tree, *1/1
identify the infix expression,
evaluate it and choose the
correct result.
a) 5
b) 10
c) 12
d) 16
Which of the following methods *0/1
is used to insert an element at a
specific index in an ArrayList?
Correct answer
a) Diagonal traversal
b) Boundary traversal
c) Breadth-first traversal
d) Depth-first traversal
Time Complexity of Breadth *1/1
First Search is? (V – number of
vertices, E – number of edges)
a) O(V + E)
b) O(V)
c) O(E)
d) O(V*E)
a) O(n)
b) O(n^2)
c) O(logn)
d) O(1)
Correct answer
d) O(1)
Which of the following sorting *0/1
algorithms is the most efficient
for sorting a small list of
elements?
a) Selection sort
b) Insertion sort
c) Bubble sort
d) Quicksort
Correct answer
b) Insertion sort
a) Merge Sort
b) Insertion Sort
c) Quick Sort
d) Heap Sort
What does the following piece *1/1
of code do?
12345
23451
34521
45321
0 of 0 points
Feedback *
Forms