Q. Which algorithm is commonly used to convert an array into a heap?
A.
Heapify
B.
Merge Sort
C.
Quick Sort
D.
Insertion Sort
Show solution
Solution
The 'Heapify' algorithm is used to convert an array into a heap structure, ensuring the heap property is maintained.
Correct Answer:
A
— Heapify
Learn More →
Q. Which algorithm is used for finding the shortest path in a graph?
A.
Bubble Sort
B.
Dijkstra's Algorithm
C.
Merge Sort
D.
Depth First Search
Show solution
Solution
Dijkstra's Algorithm is commonly used for finding the shortest path in a weighted graph.
Correct Answer:
B
— Dijkstra's Algorithm
Learn More →
Q. Which algorithm uses a priority queue to find the minimum spanning tree?
A.
Kruskal's algorithm
B.
Prim's algorithm
C.
Dijkstra's algorithm
D.
Bellman-Ford algorithm
Show solution
Solution
Prim's algorithm uses a priority queue to efficiently select the next edge with the minimum weight to add to the spanning tree.
Correct Answer:
B
— Prim's algorithm
Learn More →
Q. Which algorithm uses a priority queue to find the shortest path in a graph?
A.
Dijkstra's Algorithm
B.
Kruskal's Algorithm
C.
Prim's Algorithm
D.
Bellman-Ford Algorithm
Show solution
Solution
Dijkstra's Algorithm uses a priority queue to efficiently find the shortest path from a source vertex to all other vertices in a graph.
Correct Answer:
A
— Dijkstra's Algorithm
Learn More →
Q. Which application of hash tables is most suitable for implementing a phone book?
A.
Storing names in alphabetical order
B.
Quickly retrieving phone numbers by name
C.
Sorting phone numbers
D.
Finding the longest name
Show solution
Solution
Hash tables allow for quick retrieval of phone numbers using names as keys, providing efficient access.
Correct Answer:
B
— Quickly retrieving phone numbers by name
Learn More →
Q. Which application would benefit most from using a hash table?
A.
Finding the shortest path in a graph
B.
Storing user sessions in a web application
C.
Sorting a list of numbers
D.
Performing binary search on a sorted array
Show solution
Solution
Hash tables are ideal for storing user sessions due to their fast access times and ability to handle dynamic data.
Correct Answer:
B
— Storing user sessions in a web application
Learn More →
Q. Which data structure can be efficiently implemented using Disjoint Set Union?
A.
Binary tree
B.
Graph
C.
Priority queue
D.
Sparse matrix
Show solution
Solution
Disjoint Set Union can be efficiently used to manage connected components in a graph.
Correct Answer:
B
— Graph
Learn More →
Q. Which data structure is commonly used to implement a priority queue?
A.
Array
B.
Linked List
C.
Binary Search Tree
D.
Heap
Show solution
Solution
A priority queue is commonly implemented using a heap, as it allows for efficient insertion and deletion of the highest (or lowest) priority element.
Correct Answer:
D
— Heap
Learn More →
Q. Which data structure is typically used to implement a priority queue?
A.
Array
B.
Linked List
C.
Heap
D.
Stack
Show solution
Solution
Heaps are commonly used to implement priority queues because they allow for efficient insertion and removal of the highest (or lowest) priority element.
Correct Answer:
C
— Heap
Learn More →
Q. Which of the following algorithms can be used to sort an array using a binary heap?
A.
Quick Sort
B.
Merge Sort
C.
Heap Sort
D.
Bubble Sort
Show solution
Solution
Heap Sort is an algorithm that uses a binary heap to sort an array efficiently.
Correct Answer:
C
— Heap Sort
Learn More →
Q. Which of the following algorithms uses a priority queue to find the shortest path in a graph?
A.
Depth-First Search
B.
Dijkstra's Algorithm
C.
Bubble Sort
D.
Binary Search
Show solution
Solution
Dijkstra's Algorithm uses a priority queue to efficiently find the shortest path from a source node to all other nodes in a graph.
Correct Answer:
B
— Dijkstra's Algorithm
Learn More →
Q. Which of the following algorithms uses a priority queue?
A.
Merge Sort
B.
Dijkstra's Algorithm
C.
Binary Search
D.
Quick Sort
Show solution
Solution
Dijkstra's Algorithm uses a priority queue to efficiently select the next vertex with the smallest tentative distance.
Correct Answer:
B
— Dijkstra's Algorithm
Learn More →
Q. Which of the following algorithms utilizes Disjoint Set Union for its implementation?
A.
Dijkstra's algorithm
B.
Kruskal's algorithm
C.
Merge sort
D.
Binary search
Show solution
Solution
Kruskal's algorithm utilizes Disjoint Set Union to efficiently manage and merge sets of vertices while finding the minimum spanning tree.
Correct Answer:
B
— Kruskal's algorithm
Learn More →
Q. Which of the following applications can benefit from hash tables?
A.
Implementing a stack
B.
Storing user sessions in web applications
C.
Performing depth-first search
D.
Sorting a list of numbers
Show solution
Solution
Hash tables are commonly used to store user sessions in web applications for quick access and management of session data.
Correct Answer:
B
— Storing user sessions in web applications
Learn More →
Q. Which of the following applications can benefit from using Disjoint Set Union?
A.
Cycle detection in a graph
B.
Binary search on sorted arrays
C.
Heap operations
D.
Dynamic programming
Show solution
Solution
Cycle detection in a graph can benefit from using Disjoint Set Union, as it helps in efficiently managing and merging sets of vertices.
Correct Answer:
A
— Cycle detection in a graph
Learn More →
Q. Which of the following hash functions is considered a good practice?
A.
Using the identity function
B.
Using a simple modulus operation
C.
Using a complex mathematical function
D.
Using a random number generator
Show solution
Solution
A good hash function should distribute keys uniformly across the hash table, and using a simple modulus operation is a common practice.
Correct Answer:
B
— Using a simple modulus operation
Learn More →
Q. Which of the following hash functions is considered good for a hash table?
A.
A function that always returns the same index
B.
A function that distributes keys uniformly across the table
C.
A function that uses only the first character of the key
D.
A function that is computationally expensive
Show solution
Solution
A good hash function distributes keys uniformly across the hash table to minimize collisions and ensure efficient access.
Correct Answer:
B
— A function that distributes keys uniformly across the table
Learn More →
Q. Which of the following hash functions is considered good practice?
A.
A function that returns the key itself
B.
A function that uses a prime number
C.
A function that always returns the same index
D.
A function that is linear
Show solution
Solution
A good hash function often uses a prime number to help distribute keys uniformly across the hash table.
Correct Answer:
B
— A function that uses a prime number
Learn More →
Q. Which of the following hash functions is least likely to produce collisions?
A.
Simple modulus operation
B.
Multiplicative hashing
C.
Cryptographic hash functions
D.
Division by a prime number
Show solution
Solution
Cryptographic hash functions are designed to minimize collisions and provide a uniform distribution of hash values.
Correct Answer:
C
— Cryptographic hash functions
Learn More →
Q. Which of the following hashing techniques can help reduce collisions?
A.
Chaining
B.
Linear probing
C.
Quadratic probing
D.
All of the above
Show solution
Solution
All listed techniques (chaining, linear probing, and quadratic probing) are methods used to handle collisions in hash tables.
Correct Answer:
D
— All of the above
Learn More →
Q. Which of the following is a benefit of using hash tables for implementing sets?
A.
Maintaining order of elements
B.
Allowing duplicate elements
C.
Fast membership testing
D.
Using less memory than arrays
Show solution
Solution
Hash tables provide average-case O(1) time complexity for membership testing, making them efficient for set operations.
Correct Answer:
C
— Fast membership testing
Learn More →
Q. Which of the following is a characteristic of a binary heap?
A.
Complete binary tree
B.
Balanced binary tree
C.
Binary search tree
D.
Unbalanced tree
Show solution
Solution
A binary heap is a complete binary tree, meaning all levels are fully filled except possibly for the last level.
Correct Answer:
A
— Complete binary tree
Learn More →
Q. Which of the following is a common method for handling collisions in a hash table?
A.
Chaining
B.
Sorting
C.
Binary Search
D.
Recursion
Show solution
Solution
Chaining is a common collision resolution technique where each slot in the hash table points to a linked list of entries that hash to the same index.
Correct Answer:
A
— Chaining
Learn More →
Q. Which of the following is a common method for handling collisions in hash tables?
A.
Chaining
B.
Sorting
C.
Binary Search
D.
Recursion
Show solution
Solution
Chaining is a common collision resolution technique where each slot in the hash table points to a linked list of entries that hash to the same index.
Correct Answer:
A
— Chaining
Learn More →
Q. Which of the following is a common method for implementing a hash function?
A.
Using a binary search
B.
Using a random number generator
C.
Using modular arithmetic
D.
Using a stack
Show solution
Solution
Modular arithmetic is commonly used in hash functions to ensure that the hash value fits within the bounds of the array size.
Correct Answer:
C
— Using modular arithmetic
Learn More →
Q. Which of the following is a disadvantage of using hash tables?
A.
Fast access time
B.
Dynamic resizing
C.
Collision handling complexity
D.
Easy implementation
Show solution
Solution
One disadvantage of hash tables is the complexity involved in handling collisions, which can affect performance and implementation.
Correct Answer:
C
— Collision handling complexity
Learn More →
Q. Which of the following is NOT a benefit of using hash tables?
A.
Fast access time
B.
Dynamic resizing
C.
Ordered data storage
D.
Efficient memory usage
Show solution
Solution
Hash tables do not maintain the order of elements, which is a characteristic of data structures like linked lists or trees.
Correct Answer:
C
— Ordered data storage
Learn More →
Q. Which of the following is NOT a characteristic of a binary heap?
A.
Complete binary tree
B.
Heap property
C.
Sorted order of elements
D.
Dynamic size
Show solution
Solution
A binary heap does not maintain a sorted order of elements; it only ensures the heap property (parent nodes are greater or less than child nodes).
Correct Answer:
C
— Sorted order of elements
Learn More →
Q. Which of the following is NOT a characteristic of a good hash function?
A.
Deterministic
B.
Uniform distribution
C.
Fast computation
D.
Produces a sorted output
Show solution
Solution
A good hash function should be deterministic, provide a uniform distribution of hash values, and be fast to compute, but it does not need to produce a sorted output.
Correct Answer:
D
— Produces a sorted output
Learn More →
Q. Which of the following is NOT a characteristic of Disjoint Set Union?
A.
Supports dynamic connectivity
B.
Allows for efficient merging of sets
C.
Requires elements to be contiguous in memory
D.
Can be implemented with trees
Show solution
Solution
Disjoint Set Union does not require elements to be contiguous in memory; it can be implemented with trees or arrays.
Correct Answer:
C
— Requires elements to be contiguous in memory
Learn More →
Showing 121 to 150 of 179 (6 Pages)