Q. What is the main disadvantage of using an array?
-
A.
Fixed size
-
B.
Slow access time
-
C.
High memory usage
-
D.
Complex implementation
Solution
The main disadvantage of arrays is their fixed size, which limits their flexibility compared to linked lists.
Correct Answer:
A
— Fixed size
Learn More →
Q. What is the primary use of a stack in programming?
-
A.
Storing data in a sorted manner
-
B.
Managing function calls
-
C.
Implementing queues
-
D.
Searching data
Solution
Stacks are primarily used to manage function calls in programming, following the Last In First Out (LIFO) principle.
Correct Answer:
B
— Managing function calls
Learn More →
Q. What is the time complexity of searching for an element in a sorted array using binary search?
-
A.
O(n)
-
B.
O(log n)
-
C.
O(n log n)
-
D.
O(1)
Solution
The time complexity of searching for an element in a sorted array using binary search is O(log n).
Correct Answer:
B
— O(log n)
Learn More →
Q. Which data structure can be used to implement a priority queue?
-
A.
Array
-
B.
Linked List
-
C.
Heap
-
D.
Stack
Solution
A heap is commonly used to implement a priority queue because it allows efficient retrieval of the highest (or lowest) priority element.
Correct Answer:
C
— Heap
Learn More →
Q. Which of the following sorting algorithms is not based on comparisons?
-
A.
Quick Sort
-
B.
Merge Sort
-
C.
Bubble Sort
-
D.
Counting Sort
Solution
Counting Sort is a non-comparison-based sorting algorithm that sorts integers by counting occurrences.
Correct Answer:
D
— Counting Sort
Learn More →
Showing 1 to 5 of 5 (1 Pages)