Data Structures & Algorithms

Download Q&A
Q. In a hash table, what is the effect of a poor hash function?
  • A. Increased memory usage
  • B. Faster access times
  • C. Higher collision rates
  • D. Simpler implementation
Q. In a hash table, what is the purpose of a hash function?
  • A. To sort the data
  • B. To convert keys into indices
  • C. To store data in a linked list
  • D. To manage memory allocation
Q. In a hash table, what is the purpose of the hash function?
  • A. To sort the data
  • B. To convert keys into hash codes
  • C. To store data in a binary tree
  • D. To manage memory allocation
Q. In a max-heap, if the root node has a value of 20, what can be the maximum value of its children?
  • A. 10
  • B. 15
  • C. 20
  • D. 25
Q. In a max-heap, what is the relationship between the height of the heap and the number of elements?
  • A. Height is log(n)
  • B. Height is n
  • C. Height is n log(n)
  • D. Height is constant
Q. In a max-heap, which of the following is true about the parent and child nodes?
  • A. Parent is always greater than children
  • B. Parent is always less than children
  • C. Parent can be equal to children
  • D. None of the above
Q. In a max-heap, which of the following is true about the root node?
  • A. It is the smallest element
  • B. It is the largest element
  • C. It can be any element
  • D. It is the second largest element
Q. In a max-heap, which of the following statements is true?
  • A. The parent is always less than the children
  • B. The parent is always greater than the children
  • C. The children can be greater than the parent
  • D. All elements are in sorted order
Q. In a max-heap, which property must be maintained?
  • A. The parent node is always less than its children
  • B. The parent node is always equal to its children
  • C. The parent node is always greater than or equal to its children
  • D. The children nodes are always greater than their parent
Q. In a min-heap, which of the following is true about the parent and child nodes?
  • A. Parent is always greater than children
  • B. Parent is always less than children
  • C. Parent can be equal to children
  • D. None of the above
Q. In a min-heap, which of the following is true?
  • A. The root is the smallest element
  • B. The root is the largest element
  • C. All parent nodes are smaller than their children
  • D. Both A and C
Q. In a min-heap, which of the following statements is true?
  • A. The parent node is always greater than its children
  • B. The parent node is always less than its children
  • C. All nodes are in sorted order
  • D. The smallest element is at the bottom
Q. In a priority queue implemented with a binary heap, what happens when the heap property is violated?
  • A. The heap is automatically sorted
  • B. The heap is restructured
  • C. Elements are removed
  • D. No action is taken
Q. In a priority queue implemented with a binary heap, what happens when the maximum element is removed?
  • A. The last element is placed at the root
  • B. The root is replaced with the minimum element
  • C. The heap is restructured
  • D. Both A and C
Q. In a priority queue, how is the priority of elements typically determined?
  • A. By their insertion order
  • B. By their value
  • C. By a custom comparator function
  • D. By their index in the array
Q. In Dijkstra's algorithm, what role does a priority queue play?
  • A. To store all vertices
  • B. To keep track of visited nodes
  • C. To select the next vertex with the smallest distance
  • D. To sort the edges
Q. In graph theory, what does a cycle mean?
  • A. A path that visits every vertex
  • B. A path that starts and ends at the same vertex
  • C. A path with no edges
  • D. A disconnected graph
Q. In the context of Disjoint Set Union, what does the 'Union by Rank' optimization do?
  • A. It merges two sets based on their size
  • B. It keeps track of the height of trees to minimize depth
  • C. It sorts the elements in each set
  • D. It finds the maximum element in a set
Q. In the context of Disjoint Set Union, what does the 'Union by Rank' technique do?
  • A. It merges two sets based on their size
  • B. It merges two sets based on their depth
  • C. It keeps track of the number of elements in each set
  • D. It optimizes the 'Find' operation
Q. In the context of Disjoint Set Union, what does the 'Union' operation do?
  • A. Combines two sets into one
  • B. Finds the maximum element in a set
  • C. Removes an element from a set
  • D. Sorts the elements in a set
Q. In the context of Disjoint Set Union, what does the term 'union by rank' refer to?
  • A. Combining two sets based on their size
  • B. Combining two sets based on their depth
  • C. Finding the maximum element in a set
  • D. Sorting elements in a set
Q. In which scenario is the Disjoint Set Union most commonly used?
  • A. Finding the shortest path in a graph
  • B. Detecting cycles in a graph
  • C. Sorting an array
  • D. Searching for an element in a list
Q. In which scenario would you prefer a hash table over a binary search tree?
  • A. When you need to maintain sorted order
  • B. When you require frequent insertions and deletions
  • C. When you need to perform range queries
  • D. When you need constant time complexity for lookups
Q. What happens when the load factor of a hash table exceeds a certain threshold?
  • A. The table is resized
  • B. The table is deleted
  • C. The table becomes immutable
  • D. The table's performance improves
Q. What is a common application of a priority queue?
  • A. Implementing a stack
  • B. Managing tasks in a scheduling system
  • C. Sorting an array
  • D. Searching for an element in a list
Q. What is a common application of hash tables in databases?
  • A. Storing data in a sorted manner
  • B. Fast data retrieval
  • C. Data compression
  • D. Data encryption
Q. What is a common strategy for resizing a hash table?
  • A. Doubling the size
  • B. Halving the size
  • C. Increasing by a fixed amount
  • D. Randomly changing the size
Q. What is a potential drawback of using a hash table?
  • A. It requires more memory than arrays
  • B. It is slower than binary search trees
  • C. It cannot handle dynamic data
  • D. It is not suitable for large datasets
Q. What is a potential drawback of using hash tables?
  • A. They require more memory than arrays
  • B. They are slower than linked lists
  • C. They cannot handle collisions
  • D. They are not suitable for large datasets
Q. What is a potential drawback of using open addressing for collision resolution?
  • A. Increased memory usage
  • B. Higher time complexity for insertions
  • C. Requires a linked list
  • D. Cannot handle deletions
Showing 31 to 60 of 179 (6 Pages)
Soulshift Feedback ×

On a scale of 0–10, how likely are you to recommend The Soulshift Academy?

Not likely Very likely