Q. What is the average time complexity for searching an element in an unsorted array?
-
A.
O(1)
-
B.
O(n)
-
C.
O(log n)
-
D.
O(n log n)
Solution
In an unsorted array, you may need to check each element, leading to an average time complexity of O(n).
Correct Answer:
B
— O(n)
Learn More →
Q. What is the time complexity of deleting an element from a linked list when you have a pointer to that node?
-
A.
O(1)
-
B.
O(n)
-
C.
O(log n)
-
D.
O(n^2)
Solution
If you have a pointer to the node to be deleted, the deletion can be done in constant time, O(1).
Correct Answer:
A
— O(1)
Learn More →
Q. What is the worst-case time complexity for bubble sort?
-
A.
O(n)
-
B.
O(n log n)
-
C.
O(n^2)
-
D.
O(log n)
Solution
The worst-case time complexity for bubble sort occurs when the array is sorted in reverse order, resulting in O(n^2).
Correct Answer:
C
— O(n^2)
Learn More →
Q. Which data structure is more memory efficient for dynamic data storage?
-
A.
Array
-
B.
Linked List
-
C.
Stack
-
D.
Queue
Solution
Linked lists are more memory efficient for dynamic data storage as they do not require a predefined size like arrays.
Correct Answer:
B
— Linked List
Learn More →
Q. Which data structure is more memory efficient for storing a list of items with frequent insertions and deletions?
-
A.
Array
-
B.
Linked List
-
C.
Stack
-
D.
Queue
Solution
Linked lists are more memory efficient for frequent insertions and deletions compared to arrays, which may require resizing.
Correct Answer:
B
— Linked List
Learn More →
Q. Which of the following is a real-world application of linked lists?
-
A.
Implementing a stack
-
B.
Storing a collection of items
-
C.
Maintaining a playlist of songs
-
D.
All of the above
Solution
Linked lists can be used to implement stacks, store collections, and maintain playlists, making option 'All of the above' correct.
Correct Answer:
D
— All of the above
Learn More →
Q. Which of the following is NOT a characteristic of arrays?
-
A.
Fixed size
-
B.
Random access
-
C.
Dynamic resizing
-
D.
Contiguous memory allocation
Solution
Arrays have a fixed size and do not support dynamic resizing; this is a characteristic of linked lists.
Correct Answer:
C
— Dynamic resizing
Learn More →
Showing 1 to 7 of 7 (1 Pages)