Data Structures & Algorithms

Download Q&A
Q. How can hash tables be used in caching mechanisms?
  • A. To store data in a linear fashion
  • B. To quickly access frequently used data
  • C. To sort data before retrieval
  • D. To encrypt sensitive information
Q. How can the performance of a hash table be improved?
  • A. By using a larger initial size
  • B. By using a simpler hash function
  • C. By reducing the number of entries
  • D. By avoiding resizing
Q. How can you convert an array into a binary heap?
  • A. Insert elements one by one
  • B. Use the heapify process
  • C. Sort the array
  • D. Reverse the array
Q. How do hash tables handle collisions?
  • A. By using a linked list for each bucket
  • B. By resizing the table
  • C. By ignoring the new entry
  • D. By using a binary search tree
Q. How do hash tables improve the performance of caching mechanisms?
  • A. By using linked lists for storage
  • B. By allowing quick access to cached data
  • C. By sorting data before caching
  • D. By using binary trees for organization
Q. How do you remove the maximum element from a max-heap?
  • A. Remove the root and re-heapify
  • B. Remove the last element
  • C. Swap the root with the last element
  • D. Both A and C
Q. How does a priority queue differ from a regular queue?
  • A. It allows duplicate elements
  • B. It processes elements based on priority
  • C. It can only hold integers
  • D. It is implemented using arrays only
Q. How does path compression affect the structure of the Disjoint Set Union?
  • A. It increases the depth of the trees
  • B. It flattens the trees to make future queries faster
  • C. It creates new sets
  • D. It has no effect on the structure
Q. How does path compression improve the efficiency of the 'Find' operation in Disjoint Set Union?
  • A. By storing the size of each set
  • B. By flattening the structure of the tree
  • C. By using a stack to keep track of elements
  • D. By sorting the elements
Q. How does path compression improve the efficiency of the 'Find' operation?
  • A. By reducing the number of elements in the set
  • B. By flattening the structure of the tree
  • C. By increasing the rank of the trees
  • D. By merging all sets into one
Q. How does path compression improve the efficiency of the Disjoint Set Union?
  • A. By reducing the number of elements in a set
  • B. By flattening the structure of the tree representing the sets
  • C. By increasing the depth of the trees
  • D. By merging smaller sets into larger ones
Q. If a hash table has a load factor of 0.75, what does this imply?
  • A. The table is full
  • B. The table is half full
  • C. The table is 75% full
  • D. The table has 75 entries
Q. If a hash table has a load factor of 0.75, what does this mean?
  • A. The table is full
  • B. 75% of the table is empty
  • C. 75% of the table is filled with elements
  • D. The table can only hold 75 elements
Q. If a hash table uses a hash function that produces a large number of collisions, what is the likely outcome?
  • A. Increased search time
  • B. Decreased memory usage
  • C. Faster insertions
  • D. No effect on performance
Q. If two elements belong to different sets in a Disjoint Set Union, what will the 'Find' operation return for each element?
  • A. The same root
  • B. Different roots
  • C. An error
  • D. The size of the sets
Q. If two elements belong to different sets, what will the 'Find' operation return after a 'Union' operation is performed on them?
  • A. The first element's set identifier
  • B. The second element's set identifier
  • C. A new unique identifier
  • D. An error message
Q. If two elements belong to different sets, what will the 'Union' operation do?
  • A. It will do nothing
  • B. It will merge the two sets
  • C. It will return an error
  • D. It will create a new set
Q. If two elements belong to the same set in a Disjoint Set Union, what will the 'Find' operation return for both elements?
  • A. Different roots
  • B. The same root
  • C. An error
  • D. The size of the set
Q. If you have a min-heap, what will be the time complexity to extract the minimum element?
  • A. O(1)
  • B. O(log n)
  • C. O(n)
  • D. O(n log n)
Q. If you have a priority queue implemented as a binary heap, what is the time complexity of finding the k-th smallest element?
  • A. O(k log n)
  • B. O(n)
  • C. O(k)
  • D. O(log n)
Q. If you have n elements and perform m union operations, what is the amortized time complexity of each operation in a Disjoint Set Union with path compression and union by rank?
  • A. O(1)
  • B. O(log n)
  • C. O(n)
  • D. O(α(n))
Q. If you want to implement a priority queue that allows for efficient decrease-key operations, which data structure would be most suitable?
  • A. Binary Heap
  • B. Fibonacci Heap
  • C. Array
  • D. Linked List
Q. In a binary heap, how many children does each node have at most?
  • A. 1
  • B. 2
  • C. 3
  • D. 4
Q. In a Disjoint Set Union, what does the 'find' operation return?
  • A. The size of the set
  • B. The representative of the set
  • C. The number of elements in the set
  • D. The depth of the tree
Q. In a Disjoint Set Union, what does the 'Union by Rank' technique help to achieve?
  • A. Faster sorting of elements
  • B. Reduced height of trees
  • C. Increased memory usage
  • D. Faster searching in arrays
Q. In a Disjoint Set Union, what does the 'Union' operation do?
  • A. Combines two sets into one
  • B. Finds the maximum element in a set
  • C. Sorts the elements of a set
  • D. Removes an element from a set
Q. In a Disjoint Set Union, what is the effect of union by rank?
  • A. It increases the size of the set
  • B. It keeps the tree flat by attaching smaller trees under larger trees
  • C. It merges sets randomly
  • D. It has no effect on the structure
Q. In a Disjoint Set Union, what is the purpose of union by rank?
  • A. To keep track of the number of elements in each set
  • B. To minimize the height of the trees representing sets
  • C. To ensure all elements are unique
  • D. To sort the elements in each set
Q. In a Disjoint Set Union, what is the role of the 'rank' of a set?
  • A. To determine the size of the set
  • B. To optimize the union operation
  • C. To track the number of elements
  • D. To store the parent node
Q. In a graph, what does it mean if there is a path from vertex A to vertex B?
  • A. A is connected to B
  • B. A is adjacent to B
  • C. A is a parent of B
  • D. A is a child of B
Showing 1 to 30 of 182 (7 Pages)
Soulshift Feedback ×

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

Not likely Very likely