Q. In which scenario is binary search NOT applicable?
A.
Finding an element in a sorted array
B.
Finding the square root of a number
C.
Finding an element in an unsorted array
D.
Finding the maximum element in a sorted array
Show solution
Solution
Binary search cannot be applied to an unsorted array as it relies on the order of elements.
Correct Answer:
C
— Finding an element in an unsorted array
Learn More →
Q. In which scenario is Breadth-First Search (BFS) preferred over Depth-First Search (DFS)?
A.
When memory is limited
B.
When the shortest path is required
C.
When the graph is very deep
D.
When cycles are present
Show solution
Solution
BFS is preferred when the shortest path is required because it explores all neighbors at the present depth prior to moving on to nodes at the next depth level.
Correct Answer:
B
— When the shortest path is required
Learn More →
Q. In which scenario is DFS preferred over BFS?
A.
Finding the shortest path
B.
Exploring all possible paths
C.
Finding connected components
D.
Finding the minimum spanning tree
Show solution
Solution
DFS is preferred for exploring all possible paths, especially in scenarios like backtracking.
Correct Answer:
B
— Exploring all possible paths
Learn More →
Q. In which scenario is Dijkstra's algorithm most effective?
A.
When all edge weights are negative
B.
When edge weights are non-negative
C.
When the graph is unweighted
D.
When the graph is a tree
Show solution
Solution
Dijkstra's algorithm is most effective when all edge weights are non-negative, as it relies on this property to ensure the shortest path is found.
Correct Answer:
B
— When edge weights are non-negative
Learn More →
Q. In which scenario is Dijkstra's algorithm most effectively applied?
A.
Finding the shortest path in an unweighted graph
B.
Finding the shortest path in a weighted graph with non-negative weights
C.
Finding the longest path in a graph
D.
Finding a cycle in a graph
Show solution
Solution
Dijkstra's algorithm is most effective in finding the shortest path in a weighted graph where all edge weights are non-negative.
Correct Answer:
B
— Finding the shortest path in a weighted graph with non-negative weights
Learn More →
Q. In which scenario is Dijkstra's algorithm most efficient?
A.
When all edge weights are equal
B.
When the graph is sparse
C.
When the graph is dense
D.
When there are many negative weights
Show solution
Solution
Dijkstra's algorithm is most efficient in sparse graphs where the number of edges is much less than the maximum possible number of edges.
Correct Answer:
B
— When the graph is sparse
Learn More →
Q. In which scenario is Dijkstra's algorithm NOT applicable?
A.
When all edge weights are non-negative
B.
When there are negative edge weights
C.
When the graph is directed
D.
When the graph is undirected
Show solution
Solution
Dijkstra's algorithm cannot handle graphs with negative edge weights.
Correct Answer:
B
— When there are negative edge weights
Learn More →
Q. In which scenario is Dijkstra's algorithm not suitable?
A.
Finding the shortest path in a road network
B.
Finding the shortest path in a graph with negative weights
C.
Finding the shortest path in a weighted graph
D.
Finding the shortest path in a tree
Show solution
Solution
Dijkstra's algorithm is not suitable for graphs with negative weights, as it can produce incorrect results.
Correct Answer:
B
— Finding the shortest path in a graph with negative weights
Learn More →
Q. In which scenario is Heap Sort particularly useful?
A.
When memory usage is a concern
B.
When the data is already sorted
C.
When the data is small
D.
When stability is required
Show solution
Solution
Heap Sort is useful when memory usage is a concern because it sorts in place and requires no additional storage.
Correct Answer:
A
— When memory usage is a concern
Learn More →
Q. In which scenario is Quick Sort generally faster than Merge Sort?
A.
When the array is small
B.
When the array is large
C.
When the array is nearly sorted
D.
When the array is reverse sorted
Show solution
Solution
Quick Sort is generally faster than Merge Sort when the array is nearly sorted.
Correct Answer:
C
— When the array is nearly sorted
Learn More →
Q. In which scenario is Quick Sort generally preferred over Merge Sort?
A.
When memory usage is a concern
B.
When the data is nearly sorted
C.
When stability is required
D.
When the data is small
Show solution
Solution
Quick Sort is generally preferred over Merge Sort when memory usage is a concern, as it is an in-place sorting algorithm.
Correct Answer:
A
— When memory usage is a concern
Learn More →
Q. In which scenario is Quick Sort likely to perform poorly?
A.
When the array is already sorted
B.
When the array is in reverse order
C.
When the array has many duplicate elements
D.
When the array is small
Show solution
Solution
Quick Sort performs poorly when the array is already sorted, as it can lead to unbalanced partitions.
Correct Answer:
A
— When the array is already sorted
Learn More →
Q. In which scenario is Quick Sort preferred over Merge Sort?
A.
When memory usage is a concern
B.
When stability is required
C.
When the data is nearly sorted
D.
When the data is large and random
Show solution
Solution
Quick Sort is preferred when memory usage is a concern because it is an in-place sorting algorithm.
Correct Answer:
A
— When memory usage is a concern
Learn More →
Q. In which scenario is the F1 Score particularly useful?
A.
When false positives are more critical than false negatives
B.
When false negatives are more critical than false positives
C.
When the class distribution is balanced
D.
When the class distribution is imbalanced
Show solution
Solution
F1 Score is useful in imbalanced class distributions as it balances precision and recall.
Correct Answer:
D
— When the class distribution is imbalanced
Learn More →
Q. In which scenario would a circular queue be preferred over a regular queue?
A.
When memory is limited
B.
When elements need to be sorted
C.
When implementing a stack
D.
When processing data in a LIFO manner
Show solution
Solution
Circular queues are preferred in scenarios with limited memory as they efficiently utilize available space.
Correct Answer:
A
— When memory is limited
Learn More →
Q. In which scenario would a linked list be preferred over an array?
A.
When the size of the data is known
B.
When frequent insertions and deletions are required
C.
When random access is needed
D.
When memory is limited
Show solution
Solution
Linked lists are preferred when frequent insertions and deletions are required because they can be done in O(1) time, unlike arrays which require O(n) time.
Correct Answer:
B
— When frequent insertions and deletions are required
Learn More →
Q. In which scenario would a queue be more appropriate than a stack?
A.
When you need to access the last element added
B.
When you need to process elements in the order they were added
C.
When you need to sort elements
D.
When you need to implement recursion
Show solution
Solution
Queues follow First In First Out (FIFO) principle, making them suitable for processing elements in the order they were added.
Correct Answer:
B
— When you need to process elements in the order they were added
Learn More →
Q. In which scenario would a queue be the most appropriate data structure to use?
A.
Reversing a string
B.
Processing tasks in a printer
C.
Evaluating expressions
D.
Implementing a backtracking algorithm
Show solution
Solution
Queues are ideal for processing tasks in a printer, as they follow the First-In-First-Out (FIFO) principle.
Correct Answer:
B
— Processing tasks in a printer
Learn More →
Q. In which scenario would a queue be used in a web server?
A.
To manage user sessions
B.
To handle incoming requests
C.
To store user data
D.
To cache web pages
Show solution
Solution
A queue is used to handle incoming requests in a web server, processing them in the order they arrive.
Correct Answer:
B
— To handle incoming requests
Learn More →
Q. In which scenario would a Random Forest be preferred over a single Decision Tree?
A.
When interpretability is the main goal
B.
When the dataset is small
C.
When overfitting is a concern
D.
When the model needs to run in real-time
Show solution
Solution
Random Forests reduce overfitting by averaging multiple Decision Trees, making them more robust.
Correct Answer:
C
— When overfitting is a concern
Learn More →
Q. In which scenario would a Red-Black tree be preferred over an AVL tree?
A.
When frequent insertions and deletions are expected.
B.
When memory usage is a critical factor.
C.
When the dataset is static and does not change.
D.
When the tree needs to be perfectly balanced.
Show solution
Solution
Red-Black trees are generally preferred when there are frequent insertions and deletions because they are less rigidly balanced than AVL trees, allowing for faster insertions and deletions.
Correct Answer:
A
— When frequent insertions and deletions are expected.
Learn More →
Q. In which scenario would a stack be more beneficial than a queue?
A.
When processing tasks in order of arrival
B.
When reversing a string
C.
When managing print jobs
D.
When implementing breadth-first search
Show solution
Solution
A stack is more beneficial when reversing a string, as it allows for the last character added to be the first one processed.
Correct Answer:
B
— When reversing a string
Learn More →
Q. In which scenario would a stack be preferred over a queue?
A.
When processing tasks in a last-in, first-out manner
B.
When tasks need to be processed in the order they arrive
C.
When implementing breadth-first search
D.
When managing a list of items to be displayed
Show solution
Solution
A stack is preferred when tasks need to be processed in a last-in, first-out (LIFO) manner, such as in backtracking algorithms.
Correct Answer:
A
— When processing tasks in a last-in, first-out manner
Learn More →
Q. In which scenario would an AVL tree be preferred over a Red-Black tree?
A.
When insertions and deletions are more frequent than searches.
B.
When search operations are more frequent than insertions and deletions.
C.
When memory usage is a concern.
D.
When the dataset is small.
Show solution
Solution
AVL trees are preferred when search operations are more frequent than insertions and deletions because they provide faster search times due to stricter balancing.
Correct Answer:
B
— When search operations are more frequent than insertions and deletions.
Learn More →
Q. In which scenario would BFS be preferred over DFS?
A.
Finding the shortest path in an unweighted graph
B.
Finding a path in a maze
C.
Topological sorting
D.
Finding connected components
Show solution
Solution
BFS is preferred for finding the shortest path in an unweighted graph because it explores all neighbors at the present depth prior to moving on to nodes at the next depth level.
Correct Answer:
A
— Finding the shortest path in an unweighted graph
Learn More →
Q. In which scenario would binary search be preferred over linear search?
A.
When the array is small
B.
When the array is unsorted
C.
When the array is large and sorted
D.
When searching for multiple elements
Show solution
Solution
Binary search is more efficient for large sorted arrays compared to linear search.
Correct Answer:
C
— When the array is large and sorted
Learn More →
Q. In which scenario would binary search not be applicable?
A.
Searching in a sorted array
B.
Searching in a linked list
C.
Searching in a sorted linked list
D.
Searching in a sorted array with duplicates
Show solution
Solution
Binary search is not applicable for linked lists because it requires random access to elements, which linked lists do not provide.
Correct Answer:
B
— Searching in a linked list
Learn More →
Q. In which scenario would clustering be most beneficial?
A.
Identifying customer groups in a retail dataset
B.
Predicting future sales
C.
Classifying emails as spam or not spam
D.
Forecasting weather patterns
Show solution
Solution
Clustering is beneficial for identifying customer groups in a retail dataset, as it helps in understanding different customer profiles.
Correct Answer:
A
— Identifying customer groups in a retail dataset
Learn More →
Q. In which scenario would clustering be most useful?
A.
Identifying customer groups in a dataset
B.
Predicting future sales
C.
Classifying emails as spam or not
D.
Forecasting weather patterns
Show solution
Solution
Clustering is most useful for identifying customer groups in a dataset, as it helps to find natural groupings in the data.
Correct Answer:
A
— Identifying customer groups in a dataset
Learn More →
Q. In which scenario would Depth-First Search (DFS) be preferred over Breadth-First Search (BFS)?
A.
Finding the shortest path
B.
Exploring all nodes in a level
C.
When memory is limited
D.
Finding connected components
Show solution
Solution
DFS is more memory efficient than BFS in scenarios where the graph is deep and narrow, as it uses a stack instead of a queue.
Correct Answer:
C
— When memory is limited
Learn More →
Showing 601 to 630 of 3237 (108 Pages)