Data Structures MCQs with answers parts 2 - letsbug
Here is another 25 sets of Data structures MCQs with answers. To view previous set click here
1. Which of the following is false about a circular linked list?
- Every node has a successor
- Time complexity of inserting a new node at the head of the list is O(1)
- Time complexity for deleting the last node is O(n)
- We can traverse the whole circular linked list by starting from any point
Answer: 2 : Time complexity of inserting a new node at the head of the list is O(1)
2. How many children does a binary tree have?
- 2
- any number of children
- 0 or 1 or 2
- 0 or 1
Answer: 3 : 0 or 1 or 2
3. What is/are the disadvantages of implementing tree using normal arrays?
- Difficulty in knowing children nodes of a node
- Difficult in finding the parent of a node
- Have to know the maximum number of nodes possible before creation of trees
- Difficult to implement
Answer: 3 : Have to know the maximum number of nodes possible before creation of trees
4. What must be the ideal size of array if the height of tree is "I"?
- 2L-1
- L-1
- L
- 2L
Answer: 1: 2l -1 .
5. If the tree is not a complete binary tree then what changes can be made for easy access of children of a node in the array?
- Every node stores data saying which of its children exist in the array
- No need of any changes continue with 2w+1, if node is at i
- Keep a seperate table telling children of a node
- use another array parallel to the array with tree
Answer: 1 : Every node stores data saying which of its children exist in the array
6. Advantages of linked list representation of binary trees over arrays?
- dynamic size
- Ease of insertion/deletion
- Ease in randomly accessing a node
- Both dynamic size and ease in insertion/deletion
Answer: 4: Both dynamic size and ease in insertion/deletion
7. Disadvantages of linked list representation of binary trees over arrays?
- Randomly accessing is not possible
- Extra memory for a pointer is needed with every element in the list
- Difficulty in deletion
- Random access is not possible and extra memory with every element.
Answer: 4 : Random access is not possible and extra memory with every element.
8. Which of the following traversing algorithm is not used to traverse in a tree?
- Post order
- Pre order
- None
- Randomized
Answer: 4: Randomized
9. The following given tree is an example for?
- Binary tree
- Binary search tree
- Fibonacci tree
- AVL tree
Answer: 2 : Binary Search tree
10. A binary tree is a rooted tree but not an ordered tree
- True
- False
Answer: 2: False
11. What is the traversal strategy used in the binary tree?
- depth-first traversal
- breadth-first traversal
- random traversal
- priority traversal
Answer: 2 : Breadth-first traversal
12. How many types of insertion are performed in a binary tree?
- 1
- 2
- 3
- 4
Answer: 2 : 2
13. What operation does the following diagram depict?
- inserting a leaf node
- inserting an internal node
- deleting a node with 0 or 1 child
- deleting a node with 2 children
Answer: 4 : deleting a node with 2 children
14. The number of edges from the root to the node is called ________ of the tree.
- Height
- Depth
- Length
- Width
Answer: 2: Depth
15. The number of edges from the node to deepest leaf is called ________ of the tree.
- Height
- Depth
- Length
- Width
Answer: 1: Height
16. What is a full binary tree?
- Each node has exactly zero or two children
- Each node has exactly two children
- All the leaves are at the same level
- Each node has exactly one or two children
Answer: 1 : Each node has exactly zero or two children
17. What is a complete binary tree?
- Each node has exactly zero or two children
- A binary tree, which is completely filled, with the possible exception of the bottom level, which is filled from the right to left.
- A binary tree, which is completely filled, with the possible exception of bottom level, which is filled from left to right.
- A tree in which all nodes have degree 2
Answer: 3
18. What is the average case time complexity of finding the height of the binary tree?
- h = O(log log n)
- h = O(n log n)
- h = O(n)
- h = O(log n)
Answer: 4 : h = O(log n)
19. What is the speciality about the inorder traversal of a binary search tree?
- It traverses in a non increasing order
- It traverses in an increasing order
- It traverses in a random fashion
- It traverses based on priority of the node
Answer: 2 : It traverses in an increasing order
20. What does the following piece of code do?
public void func(Tree root){ func(root.left()); func(root.right()); System.out.println(root.data());}
public void func(Tree root)
{
func(root.left());
func(root.right());
System.out.println(root.data());
}
- preorder traversal
- Inorder traversal
- Postorder traversal
- Level order traversal
Answer: 3: Postorder traversal
21. What does the following piece of code do?
public void func(Tree root){ System.out.println(root.data()); func(root.left()); func(root.right());}
public void func(Tree root)
{
System.out.println(root.data());
func(root.left());
func(root.right());
}
- preorder traversal
- Inorder traversal
- Postorder traversal
- Level order traversal
Answer: 1: preorder traversal
22. Which of the following is not a stable sorting algorithm.
- Insertion sort
- Selection sort
- Bubble sort
- Merge sort
Answer: 2 : Selection sort
23. What is an external sorting algorithm?
- Algorithm that uses tape or disk during the sort
- Algorithm that uses main memory during the sort
- Algorithm that involves swapping
- Algorithm that are considered 'in place'
Answer: 1: Algorithm that uses tape or disk during the sort
24. If the number records to be sorted is small, then ________ sorting can be efficient
- Merge
- Heap
- Selection
- Bubble
Answer: 3 : selection
25. Which of the following is not an in-place sorting algorithm?
- Selection sort
- Heap sort
- Quick sort
- Merge sort
Answer: 2 : Merge sort
To view previous set click here.
Comments
Post a Comment