Q. In which scenario would you prefer a linked list over an array?
-
A.
When you need fast access to elements
-
B.
When the size of the data structure is fixed
-
C.
When you need to frequently insert and delete elements
-
D.
When memory usage is not a concern
Solution
Linked lists allow for efficient insertion and deletion of elements, especially when the size of the data structure is not fixed.
Correct Answer:
C
— When you need to frequently insert and delete elements
Learn More →
Q. What is a common application of arrays in programming?
-
A.
Dynamic memory allocation
-
B.
Implementing hash tables
-
C.
Storing a fixed number of elements
-
D.
Creating linked lists
Solution
Arrays are commonly used to store a fixed number of elements due to their contiguous memory allocation.
Correct Answer:
C
— Storing a fixed number of elements
Learn More →
Q. What is the main disadvantage of using an array compared to a linked list?
-
A.
Arrays have a fixed size
-
B.
Linked lists are slower for access
-
C.
Arrays use more memory
-
D.
Linked lists cannot store data
Solution
Arrays have a fixed size, which can be a limitation when the number of elements is not known in advance.
Correct Answer:
A
— Arrays have a fixed size
Learn More →
Q. What is the primary advantage of using a doubly linked list over a singly linked list?
-
A.
More memory usage
-
B.
Easier traversal in both directions
-
C.
Faster insertion
-
D.
No advantage
Solution
A doubly linked list allows traversal in both directions, making certain operations easier compared to a singly linked list.
Correct Answer:
B
— Easier traversal in both directions
Learn More →
Q. Which data structure is more memory efficient for storing a list of elements 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 as they do not require resizing like arrays.
Correct Answer:
B
— Linked List
Learn More →
Q. Which data structure would you use to implement a queue?
-
A.
Array
-
B.
Linked List
-
C.
Stack
-
D.
Both Array and Linked List
Solution
Both arrays and linked lists can be used to implement a queue, depending on the requirements for size and performance.
Correct Answer:
D
— Both Array and Linked List
Learn More →
Q. Which of the following is a common application of linked lists?
-
A.
Implementing stacks
-
B.
Sorting algorithms
-
C.
Binary search
-
D.
Hash tables
Solution
Linked lists are commonly used to implement stacks due to their dynamic size and ease of adding/removing elements.
Correct Answer:
A
— Implementing stacks
Learn More →
Q. Which of the following operations is not efficient in a linked list?
-
A.
Insertion at the head
-
B.
Deletion from the tail
-
C.
Accessing an element by index
-
D.
Traversal
Solution
Accessing an element by index in a linked list requires traversal from the head, making it O(n) in time complexity.
Correct Answer:
C
— Accessing an element by index
Learn More →
Showing 1 to 8 of 8 (1 Pages)