Q. In a circular linked list, what is the main characteristic?
A.
Last node points to null
B.
First node points to last node
C.
All nodes are connected in a circle
D.
None of the above
Show solution
Solution
In a circular linked list, the last node points back to the first node, forming a circle.
Correct Answer:
C
— All nodes are connected in a circle
Learn More →
Q. In a singly linked list, how do you delete a node given only access to that node?
A.
Set the node to null
B.
Copy the next node's data
C.
Change the previous node's pointer
D.
You cannot delete it
Show solution
Solution
To delete a node in a singly linked list when you only have access to that node, you can copy the data from the next node and then delete the next node.
Correct Answer:
B
— Copy the next node's data
Learn More →
Q. What is the primary advantage of using a linked list over an array?
A.
Faster access time
B.
Dynamic size
C.
Better memory locality
D.
Easier sorting
Show solution
Solution
Linked lists can grow and shrink in size dynamically, unlike arrays which have a fixed size.
Correct Answer:
B
— Dynamic size
Learn More →
Q. What is the time complexity of merging two sorted arrays?
A.
O(n)
B.
O(n log n)
C.
O(log n)
D.
O(n^2)
Show solution
Solution
Merging two sorted arrays can be done in linear time, O(n), where n is the total number of elements in both arrays.
Correct Answer:
A
— O(n)
Learn More →
Q. What is the worst-case 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)
Show solution
Solution
In the worst case, you may need to check every element in the array, leading to O(n) time complexity.
Correct Answer:
B
— O(n)
Learn More →
Q. Which data structure allows for efficient last-in, first-out (LIFO) operations?
A.
Queue
B.
Array
C.
Stack
D.
Linked List
Show solution
Solution
A stack is designed for LIFO operations, allowing the last element added to be the first one removed.
Correct Answer:
C
— Stack
Learn More →
Q. Which data structure is more memory efficient for storing a list of elements?
A.
Array
B.
Linked List
C.
Both are equal
D.
None of the above
Show solution
Solution
Linked lists can be more memory efficient for dynamic lists since they do not require a contiguous block of memory like arrays.
Correct Answer:
B
— Linked List
Learn More →
Q. Which of the following is a characteristic of arrays?
A.
Dynamic size
B.
Random access
C.
Non-contiguous memory allocation
D.
No fixed size
Show solution
Solution
Arrays allow random access to elements using indices, which is a key characteristic.
Correct Answer:
B
— Random access
Learn More →
Q. Which of the following is a disadvantage of using arrays?
A.
Fixed size
B.
Random access
C.
Easy to implement
D.
Memory locality
Show solution
Solution
Arrays have a fixed size, which can be a disadvantage when the number of elements is not known in advance.
Correct Answer:
A
— Fixed size
Learn More →
Q. Which of the following operations can be performed in constant time on an array?
A.
Insertion at end
B.
Deletion from beginning
C.
Accessing an element
D.
Insertion at beginning
Show solution
Solution
Accessing an element in an array by its index is done in constant time, O(1).
Correct Answer:
C
— Accessing an element
Learn More →
Q. Which of the following operations is NOT efficient for linked lists?
A.
Insertion at head
B.
Insertion at tail
C.
Accessing an element by index
D.
Deletion from head
Show solution
Solution
Accessing an element by index in a linked list requires O(n) time, as it must traverse the list sequentially.
Correct Answer:
C
— Accessing an element by index
Learn More →
Showing 1 to 11 of 11 (1 Pages)