ThatQuiz Test Library Take this test now
DSALGO-reviewer(midterm)
Contributed by: Fernandez
  • 1. Which type of tree ensures that the left subtree contains only nodes with values less than the root node, and the right subtree contains nodes with values greater than the root node?
A) Red-Black tree
B) AVL tree
C) binary search tree (BST)
D) B-tree
  • 2. In a binary tree, what is the depth of a node?
A) The number of nodes on the path from the root to that node
B) The value of the node
C) The number of levels in the tree
D) The height of the node
  • 3. Which type of tree has a special condition that the left subtree is less than the root, and the right subtree is greater than the root?
A) AVL tree
B) Red-Black tree
C) Binary search tree (BST)
D) B-tree
  • 4. Which traversal of a binary tree visits the left subtree, then the right subtree, and finally the root?
A) Level order
B) Postorder
C) Preorder
D) Inorder
  • 5. Which node in a tree is at the top and has no parent?
A) Leaf node
B) Root node
C) Sibling node
D) Internal node
  • 6. What is the depth of a tree?
A) The height of the tree
B) The number of edges from the root to the deepest leaf
C) The maximum number of children of any node
D) The total number of nodes
  • 7. In a binary tree, each node can have a maximum of how many children?
A) 0
B) 2
C) 3
D) 1
  • 8. Which tree structure is used in database indexing to optimize search and retrieval operations?
A) Binary search tree
B) B-tree
C) Trie
D) AVL tree
  • 9. Which type of tree is used in balancing binary search trees to maintain their height and performance?
A) AVL tree
B) Binary tree
C) B-tree
D) Trie
  • 10. Which traversal of a binary tree visits the left subtree, then the root, and finally the right subtree?
A) Preorder
B) Level order
C) Inorder
D) Postorder
  • 11. What is the height of a tree? *
A) The number of leaves in the tree
B) The number of nodes in the tree
C) The maximum number of children a node can have
D) The distance from the root to the deepest leaf
  • 12. Which traversal of a binary tree visits the root first, then the left subtree, and finally the right subtree?
A) Postorder
B) Preorder
C) Inorder
D) Level order
  • 13. A node in a binary tree with no children is known as a:
A) Internal node
B) Sibling node
C) Leaf node
D) Unary node
  • 14. What is a tree in data structures?
A) A hash table
B) A hierarchical data structure
C) A linear data structure
D) A graph
  • 15. In a binary tree, if a node has only one child, is it a left child or a right child?
A) It must be a left child.
B) It must be a right child.
C) It cannot have only one child.
D) It could be either a left or a right child.
  • 16. What is the primary purpose of a binary search tree (BST)?
A) To store data in a sorted order
B) To store data in a random order
C) To ensure the tree is balanced
D) To minimize the height of the tree
  • 17. In a binary tree, a node with only one child is called a:
A) Internal node
B) Sibling node
C) Unary node
D) Leaf node
  • 18. In a balanced binary search tree, what is the height typically restricted to?
A) Logarithmic in the number of nodes
B) Quadratic in the number of nodes
C) Linear in the number of nodes
D) Constant
  • 19. In graph terminology, what is a "path"?
A) A collection of edges
B) A route connecting two nodes
C) A set of all nodes in the graph
D) A cycle without any vertices
  • 20. What characterizes a connected graph?
A) There are no edges
B) It has multiple components
C) It is a directed graph only
D) All vertices are reachable from one another
  • 21. What is a graph?
A) A collection of nodes and edges
B) A linear data structure
C) A collection of arrays
D) A type of tree
  • 22. Which algorithm is commonly used to find the shortest path in a weighted graph?
A) Prim's algorithm
B) Dijkstra's algorithm
C) Kruskal's algorithm
D) Depth-first search
  • 23. What does a bipartite graph consist of?
A) Vertices that form a cycle
B) Two sets of vertices where edges only connect nodes from different sets
C) A single set of vertices
D) Only one vertex
  • 24. What is the degree of a vertex in a graph?
A) The number of paths from that vertex
B) The distance to the farthest vertex
C) The total number of vertices in the graph
D) The number of edges connected to it
  • 25. What does the term "adjacency" refer to in graph theory?
A) A connection between two vertices
B) The distance between two vertices
C) The number of vertices in a graph
D) The total number of edges
  • 26. In a directed graph, an edge has a direction. What does this imply?
A) The edge does not exist
B) The edge connects two nodes of different types
C) The edge can be traversed in both ways
D) The edge can only be traversed in one way
  • 27. In an undirected graph, how many edges can connect two vertices?
A) 0 or 1
B) Infinite
C) 1 or more
D) Exactly 2
  • 28. What is a weighted graph?
A) A graph with no edges
B) A graph where edges have values associated with them
C) A graph where vertices have weights
D) A graph where all edges have the same weight
  • 29. What is the purpose of an adjacency matrix?
A) To represent node and edge connectivity in a graph.
B) To simplify graph traversal.
C) To store edge weights only.
D) To perform sorting operations.
  • 30. What is a connected graph?
A) A graph that can be divided into two or more subgraphs
B) A graph that contains cycles
C) A graph where all vertices are connected by edges
D) A graph with no edges
  • 31. In a "simple graph," which of the following characteristics holds true?
A) It is always directed.
B) It allows weighted edges.
C) It has no parallel edges or self-loops.
D) It contains at least one cycle.
  • 32. What is a cycle in a graph?
A) A disconnected graph
B) A closed path where the starting and ending vertices are the same
C) A path that visits every vertex
D) A graph with no edges
  • 33. Which data structure is commonly used to represent a graph?
A) Stack
B) Array only
C) Linked list
D) Adjacency matrix
  • 34. What type of graph has all pairs of vertices connected by exactly one edge?
A) Undirected Graph
B) Directed Graph
C) Bipartite Graph
D) Complete Graph
  • 35. What type of graph can be divided into two disjoint sets where each edge connects a vertex from one set to the other?
A) Complete Graph
B) Weighted Graph
C) Bipartite Graph
D) Directed Graph
  • 36. What is a Queue?
A) A linear data structure
B) A non-linear data structure
C) A hierarchical data structure
D) A data type in C++
  • 37. In a queue, which item gets removed first?
A) The last item added
B) The first item added
C) The item at random
D) The item in the middle
  • 38. What is the process of adding an element to a queue called?
A) Push
B) Enqueue
C) Pop
D) Dequeue
  • 39. What is the process of removing an element from a queue called?
A) Pop
B) Dequeue
C) Enqueue
D) Push
  • 40. Which data structure follows the First-In-First-Out (FIFO) principle?
A) tree
B) queue
C) linked list
D) stack
  • 41. Which of the following operations are typically performed on a queue?
A) Only insertion
B) Insertion at one end and deletion at the other end
C) Only deletion
D) Insertion and deletion at both ends
  • 42. In a circular queue, what happens when you reach the end of the queue and want to add more elements?
A) An error is generated
B) Elements are added at the beginning of the queue
C) Elements are added at the end of the queue
D) Elements are discarded
  • 43. Which of the following is not a type of queue?
A) Circular Queue
B) Deque
C) Banana queue
D) Priority Queue
  • 44. What is the time complexity of enqueue and dequeue operations in a basic queue implemented using an array?
A) O(1) for both enqueue and dequeue
B) O(n) for both enqueue and dequeue
C) O(n) for both enqueue and dequeue
D) O(n) for enqueue and O(1) for dequeue
  • 45. Which of the following is not a valid method to implement a queue?
A) Using arrays
B) Using stacks
C) Using linked lists
D) Using dynamic arrays
  • 46. What is a priority queue?
A) A queue in which elements are processed based on their priority
B) A queue that processes elements in a random order
C) A queue that gives priority to older elements
D) A queue with a fixed size
  • 47. Which data structure is commonly used to implement a priority queue?
A) Circular queue
B) Stack
C) Queue
D) Binary heap
  • 48. What is the primary difference between a regular queue and a double-ended queue (deque)?
A) A deque can only enqueue elements at the front.
B) A deque can only dequeue elements from the front.
C) A deque can enqueue and dequeue elements at both ends.
D) A regular queue is faster than a deque.
  • 49. In a priority queue, which element gets processed first?
A) The element added least recently
B) The element with the lowest priority
C) The element with the highest priority
D) The element added most recently
  • 50. Which type of queue allows elements to be inserted and removed from both ends, like a deck of cards?
A) Priority Queue
B) Circular Queue
C) deque
D) Normal Queue
  • 51. Which data structure can be used to implement a queue with a fixed size and overwrite old elements when it's full?
A) Priority Queue
B) Circular Queue
C) Stack
D) Deque
  • 52. What is the size of a queue after enqueueing n elements and then dequeuing m elements, where m > n?
A) m
B) n-m
C) 0
D) n
  • 53. In a priority queue, if two elements have the same priority, how are they typically handled?
A) The first element added is processed first.
B) The order is implementation-specific.
C) The last element added is processed first.
D) They are processed in a random order.
  • 54. Which of the following is not a common application of a queue data structure?
A) Print spooling
B) Breadth-first search (BFS)
C) Sorting algorithms
D) Undo functionality in text editors
  • 55. Which operation can be performed in constant time (O(1)) on a well-implemented queue?
A) Dequeue
B) None of the above
C) Both enqueue and dequeue
D) Enqueue
  • 56. In a double-ended queue (deque), which operation allows you to retrieve the element at the front without removing it?
A) dequeue()
B) front()
C) remove_front()
D) pop_front()
  • 57. What is the primary advantage of using a circular queue over a basic queue?
A) No advantage; they are equivalent
B) Faster enqueue operation
C) Better memory utilization
D) Simpler implementation
  • 58. Which data structure is often used to implement a queue with a maximum size, where adding elements beyond the limit removes the oldest elements?
A) Cache
B) Circular Queue
C) Deque
D) Priority Queue
  • 59. What is the term used to describe a queue that allows elements to be added and removed at both ends, but does not have a fixed size?
A) Circular Queue
B) Deque
C) Stack
D) Priority Queue
  • 60. Which of the following is a disadvantage of using an array-based implementation for a queue?
A) It may lead to wasted memory for a large maximum size.
B) It allows for dynamic sizing.
C) It has faster enqueue and dequeue operations.
D) It is not suitable for implementing a priority queue.
  • 61. In a priority queue, which element will be removed first?
A) The element with the highest value
B) The last element added
C) The first element added
D) The element with the lowest value
  • 62. Which type of queue allows elements to be processed in the order they were added?
A) Normal Queue
B) Priority Queue
C) Circular Queue
D) Deque
  • 63. What data structure can be used to efficiently implement a priority queue that allows fast insertion and removal of elements with the highest priority?
A) Linked List
B) heap data structure
C) Binary Tree
D) Stack
  • 64. In a double-ended queue (deque), which operation allows you to retrieve the element at the back without removing it?
A) remove_back()
B) pop_back()
C) dequeue()
D) back()
  • 65. Which type of queue allows elements to be processed based on their age, with older elements processed first?
A) Priority Queue
B) Normal Queue
C) Age-Ordered Queue
D) Circular Queue
  • 66. In a circular queue, how do you detect that the queue is full?
A) Circular queues cannot be full.
B) Check if the front pointer is ahead of the rear pointer by 1.
C) Compare the rear and front pointers modulo the queue size.
D) Check if the rear pointer is ahead of the front pointer by 1.
  • 67. In a priority queue, what happens when two elements have the same priority and are removed?
A) The element with the higher value is removed.
B) The element with the lower value is removed.
C) It's implementation-dependent.
D) The element added first is removed.
  • 68. Which is not a Characteristics of an Algorithm
A) Unambiguous
B) Output
C) Feasibility
D) Input
E) Dependent
  • 69. This signifies the total time required by the program to run till its completion.
A) Time complexity
B) Efficiency
C) Abstraction
D) Reusability
E) Space Complexity
  • 70. This is the amount of memory used by the algorithm (including the input values to the algorithm) to execute and produce the result.
A) Reusability
B) Abstraction
C) Efficiency
D) Time complexity
E) Space Complexity
  • 71. once we have implemented a particular data structure, we can use it at any other place.
A) Efficiency
B) Reusability
C) Time complexity
D) Abstraction
  • 72. This characteristic describes whether the data items are arranged in chronological sequence, such as with an array, or in an unordered sequence, such as with a graph.
A) Linear or non-linear
B) Homogeneous or non-homogeneous
C) Static or dynamic
  • 73. This characteristic describes whether all data items in a given repository are of the same type or of various types.
A) Static or dynamic
B) Homogeneous or non-homogeneous
C) Linear or non-linear
  • 74. This characteristic describes how the data structures are compiled.
A) Homogeneous or non-homogeneous
B) Linear or non-linear
C) Static or dynamic
  • 75. This is broadly defined as the process of organizing data by relevant categories so that it may be used and protected more efficiently.
A) User
B) Content
C) Data classification
D) Context
Students who took this test also took :

Created with That Quiz — where a math practice test is always one click away.