Data Structures MCQ's Questions Set 2
Q.1. With what data structure can a priority queue be implemented?
Q.2. What is the time complexity to insert a node based on position in a priority queue?
Q.3. What is a dequeue?
- A queue with insert/delete defined for both front and rear ends of the queue
- A queue implemented with a doubly linked list
- A queue implemented with both singly and doubly linked lists
- A queue with insert/delete defined for front side of the queue
Q.4. What is the functionality of the following piece of code?
|public void function(Object item)|
Node temp=new Node(item,trail);
- Insert at the front end of the dequeue
- Insert at the rear end of the dequeue
- Fetch the element at the rear end of the dequeue
- Fetch the element at the front end of the dequeue
Q.5. What is the functionality of the following piece of code?
|public void fun(int x)|
- Perform push() with push as the costlier operation
- Perform push() with pop as the costlier operation
- Perform pop() with push as the costlier operation
- Perform pop() with pop as the costlier operation
Q.6. How many stacks are required for evaluation of prefix expression?
Q.7. In the given C snippet, find the statement number that has error.
//C code to push an element into a stack
1.void push( struct stack *s, int x)
5. printf(“stack overflow”);
Q.8. What is the other name for a postfix expression?
- Normal polish Notation
- Reverse polish Notation
- Warsaw notation
- Infix notation
Q.9. While evaluating a postfix expression, when an operator is encountered, what is the correct operation to be performed?
- push it directly on to the stack
- pop 2 operands, evaluate them and push the result on to the stack
- pop the entire stack
- ignore the operator
Q.10. In infix to postfix conversion algorithm, the operators are associated from?
- right to left
- left to right
- centre to left
- centre to right
Q.11. The time complexity of converting a prefix notation to infix notation is _________
- O(n) where n is the length of the equation
- O(n) where n is number of operands
- O(logn) where n is length of the equation
Q.12. The result of the postfix expression 5 3 * 9 + 6 / 8 4 / + is _____________
Q.13. What is the time complexity of reversing a word using stack algorithm?
- O (N log N)
- O (N2)
- O (N)
- O (M log N)
Q.14. Find the error (if any) in the following code snippet for pop operation.
|void pop() //removing an element from a stack|
- run time error
- compile time error
- pop operation is performed, but top moved in wrong direction
- pop operation is performed properly
Q.15. How will you implement dynamic arrays in Java?
Q.16. Which of the following is a disadvantage of dynamic arrays?
- Locality of reference
- Data cache utilization
- Random access
- Memory leak
Q.17. In a complete k-ary tree, every internal node has exactly k children or no child. The number of leaves in such a tree with n internal nodes is:
- (n-1)k + 1
- n(k-1) + 1
Q.18. Which of the following sorting algorithms can be used to sort a random linked list with minimum time complexity?
- Insertion Sort
- Quick Sort
- Heap Sort
- Merge Sort
Q.19. The height of a binary tree is the maximum number of edges in any root to leaf path. The maximum number of nodes in a binary tree of height h is:
- 2h - 1
- 2h-1 - 1
- 2h+1 - 1
Q.20. The number of leaf nodes in a rooted tree of n nodes, with each node having 0 or 3 children is:
Data Structures Interview Questions Set 1 Click here
For more Technical MCQ's and Interview Questions Click here