R4RIN
Articles
Java 8
MCQS
Data structure MCQ Quiz Hub
Data Structures
Choose a topic to test your knowledge and improve your Data structure skills
1. "Following is C like pseudo code of a function that takes a number as an argument, and uses a stack S to do processing. void fun(int n) { Stack S; // Say it creates an empty stack S while "
Prints binary representation of n in reverse order
Prints binary representation of n
Prints the value of Logn
Prints the value of Logn in reverse order
2. Which one of the following is an application of Stack Data Structure?
Arithmetic expression evaluation
Managing function calls
The stock span problem
All of the above
3. Which of the following is true about linked list implementation of stack?
In push operation, if new nodes are inserted at the beginning of linked lis
In push operation, if new nodes are inserted at the end, then in pop operat
Both of the above
None of the above
4. Consider the following pseudocode that uses a stack declare a stack of characters while ( there are more characters in the word to read ) { read a character push the character on the stack
Question
iontQues
QuesQues
noitseuQ
5. The following postfix expression with single digit operands is evaluated using a stack: 8 2 3 ^ / 2 3 * + 5 1 * - Note that ^ is the exponentiation operator. The top two elements of t
7,2
1,1
6,1
Empty
6. Let S be a stack of size n >= 1. Starting with the empty stack, suppose we push the first n natural numbers in sequence, and then perform n pop operations. Assume that Push and Pop operation take X se
n(X+ Y)
3Y + 2X
n(X + Y)-X
Y + 2X
7. A single array A[1..MAXSIZE] is used to implement two stacks. The two stacks grow from opposite ends of the array. Variables top1 and top2 (topl< top 2) point to the location of the topmost element in
(top1 = MAXSIZE/2) and (top2 = MAXSIZE/2+1)
top1= top2 -1
top1 + top2 = MAXSIZE
(top1= MAXSIZE/2) or (top2 = MAXSIZE)
8. Assume that the operators +, -, × are left associative and ^ is right associative. The order of precedence (from highest to lowest) is ^, x , +, -. The postfix expression corresponding to the infix ex
abc &Atilde;&mdash; + def ^ ^ -
abc &Atilde;&mdash; - def ^ ^ +
abc &Atilde;&mdash; + de ^ f ^ -
abc + &Atilde;&mdash; def ^ ^ -
9. To evaluate an expression without any embedded function calls:
One stack is enough
Two stacks are needed
As many stacks as the height of the expression tree are needed
A Turing machine is needed in the general case
10. The result evaluating the postfix expression 10 5 + 60 6 / * 8 – is
123
142
34
289
11. A function f defined on stacks of integers satisfies the following properties. f(&#8709;) = 0 and f (push (S, i)) = max (f(S), 0) + i for all stacks S and integers i. If a stack S contains the intege
6
4
5
3
12. 0
15
10
25
35
13. Suppose a stack is to be implemented with a linked list instead of an array. What would be the effect on the time complexity of the push and pop operations of the stack implemented using linked list (
O(1) for insertion and O(n) for deletion
O(1) for insertion and O(1) for deletion
O(n) for insertion and O(1) for deletion
O(n) for insertion and O(n) for deletion
14. Consider n elements that are equally distributed in k stacks. In each stack, elements of it are arranged in ascending order (min is at the top in each of the stack and then increasing downwards). Give
O(n logk)
O(nk)
O(k)
O(n)
15. A priority queue Q is used to implement a stack S that stores characters. PUSH(C) is implemented as INSERT(Q, C, K) where K is an appropriate integer key chosen by the implementation. POP is implement
Non-increasing order
Non-decreasing order
strictly increasing order
strictly decreasing order
16. Consider the following statements: i. First-in-first out types of computations are efficiently supported by STACKS. ii. Implementing LISTS on linked lists is more efficient than implementing LIST
(ii) and (iii) are true
(i) and (iii) are true
(i) and (ii) are true
(ii) and (iv) are true
17. Which of the following permutation can be obtained in the same order using a stack assuming that input is the sequence 5, 6, 7, 8, 9 in that order?
7, 8, 9, 5, 6
5, 9, 6, 7, 8
7, 8, 9, 6, 5
9, 8, 7, 5, 6
18. The minimum number of stacks needed to implement a queue is
1
3
2
4
19. The best data structure to check whether an arithmetic expression has balanced parenthesis is a
Queue
Tree
Heap
Stack
20. The seven elements A, B, C, D, E, F and G are pushed onto a stack in reverse order, i.e., starting from G. The stack is popped five times and each element is inserted into a queue.Two elements are del
A
B
F
G
21. If the sequence of operations - push (1), push (2), pop, push (1), push (2), pop, pop, pop, push (2), pop are performed on a stack, the sequence of popped out values
2,2,1,1,2
2,2,1,2,2
2,1,2,1,2
2,1,1,2,2
22. The five items: A, B, C, D, and E are pushed in a stack, one after other starting from A. The stack is popped four items and each element is inserted in a queue. The two elements are deleted from the
A
B
C
D
23. Consider the following operations performed on a stack of size 5 : Push (a); Pop() ; Push(b); Push(c); Pop(); Push(d); Pop();Pop(); Push (e) Which of the following statements is correct?
Underflow occurs
Stack operations are performed smoothly
Overflow occurs
None of the above
24. Which of the following is not an inherent application of stack?
Implementation of recursion
Evaluation of a postfix expression
Job scheduling
Reverse a string
25. Stack A has the entries a, b, c (with a on top). Stack B is empty. An entry popped out of stack A can be printed immediately or pushed to stack B. An entry popped out of the stack B can be only be pri
b a c
a b c
c a b
b a c
26. Convert the following infix expression into its equivalent post fix expression (A + B^ D) / (E * F) + G
ABD^ + EF * / G+
ABD+ ^ EF * / G+
ABD^ + EF / - G+
ABD + EF * / G+ ^
27. Best Data Structure for Searching?
Heap
Binary Tree
Array
Hashing
28. Worst Time complexity for searching an element in Binary search tree is:
O(logn)
O(n)
O(1)
O(nlogn)
29. Balancing Factor of each node in AVL tree may be:-
1
-1
0
All of above
30. Balancing Factor of each node in B and B+ tree is
1
0
-1
All of the above
31. Which of the following tree support the sequential search?
AVL tree
B tree
B+ tree
Complete Binary tree
32. Which of the following are true:
Insertion in stack is done at the bottom of the stack
Searching an element in link list is performed in O(1)
Every binary search tree is binary tree
Every binary tree is binary search tree
33. Which of the following are true:
Stack are the LIFO
Queue is FIFO
Queue is LILO
All of the above
34. After insertion the following node in AVL tree what will be the root node ? 10,20,30,40,50,15,5
10
20
15
30
35. Which of the following are True?
Every Binary Tree is binary search tree
Binary search tree is AVL tree
Every AVL tree is binary tree
No relation between the binary tree and the AVL tree
36. In max Heap, the cost of finding smallest number is:-
O(logn)
O(n)
O(nlogn)
O(1)
37. In max Heap, the cost of finding largest element is :-
O(n)
O(logn)
O(nlogn)
O(1)
38. In min Heap, the cost of finding smallest elements is:-
O(n)
O(1)
O(logn)
None of the above
39. Which of the following sorting are the stable sorting:-
Insertion Sort
Selection Sort
Bubble Sort
All of the above
40. The cost of construct the Heap is :-
O(n)
O(nlogn)
O(log(logn))
None of the above
41. Hashing is a powerful data structure for the:-
Sorting
Searching
Insertion &amp; deletion
Storing data in Data base
42. Consider the postfix expression 2 3 2 * 6 / 5 + + 8 / 1 + Solve this expression by using stack and it give:-
2
1
12
34
43. The following node are inserted sequentially in Binary search tree:- 30,3,50,10,5,70,80,75,60,45 what will be the Inorder of above BST?
3,5,10,30,45,50,60,70,75,80
80,5,10,30,45,50,60,70,75,3
30,3,50,10,45,70,5,60,75,80
3,5,10,30,45,50,70,60,80,75
44. The following node are inserted sequentially in Binary search tree:- 30,3,50,10,5,70,80,75,60,45 what will be the preorder of above BST?
30,3,10,5,50,45,60,70,75,80
No preorder exist
Preorder of every BST is in increasing order of numbers
30,3,10,5,50,45,70,60,80,75
45. int func(struct node *ptr) { if(ptr==NULL) return; func(ptr->left); printf("%d",ptr->data); func(ptr->right); } The above function computes the :-
Postorder of BST
Inorder of BST
Preorder of BST
None of the above
46. int func(struct node *ptr) { if(ptr==NULL) return; printf("%d",ptr->data); func(ptr->left); func(ptr->right); } The above function computes the :-
Postorder of BST
Inorder of BST
Preorder of BST
All of the above
47. int func(struct node *ptr) { if(ptr==NULL) return; func(ptr->left); func(ptr->right); printf("%d",ptr->data); } The above function computes the :-
Postorder of BST
Inorder of BST
Preorder of BST
None of the above
48. Stack is implemented by:-
Array
Link list
Both of the above
None of the above
49. In circular link list, the last node contain the address of the:-
It contain NULL
first node
Both of the above
None of the above
50. Array is collection of similar data type while structure is collection of:-
array
Primitive data type
Different data type
Non primitive data type
Submit