Questions Unit 2 Simple
Questions Unit 2 Simple
5. What is the time complexity for inserting a node at the beginning of a singly linked list?
a. O(1)
b. O(n)
c. O(log n)
d. O(n log n)
6. What is the time complexity for inserting a node at the end of a singly linked list?
a. O(1)
b. O(n)
c. O(log n)
d. O(n log n)
7. What is the time complexity for searching for a specific element in a singly linked list?
a. O(1)
b. O(n)
c. O(log n)
d. O(n log n)
8. How can you delete a node in a singly linked list if you have a reference to that node and
the head of the list?
a. Traverse from the head and find the node to delete
b. Update the node's data and pointer
c. Replace the node with the last node and update the pointers
d. It's not possible to delete a node with only these references
10. Which of the following is an advantage of a doubly linked list over a singly linked list?
a. Efficient insertion and deletion at any position
b. Less memory usage
c. Faster traversal
d. None of the above
11. What type of linked list is best suited for implementing a stack?
a. Singly linked list
b. Doubly linked list
c. Circular linked list
d. None of the above
12. In a circular linked list, the last node's pointer points to:
a. The first node
b. Null
c. The second last node
d. None of the above
13. Which of the following operations can be performed efficiently on a linked list?
a. Accessing elements at a specific index
b. Traversing the list backwards
c. Sorting the list
d. None of the above
15. Which of the following is not a disadvantage of arrays compared to linked lists?
a. Fixed size
b. Inefficient insertion and deletion
c. Random access
d. None of the above
16. Which type of linked list allows traversal only in one direction?
a. Singly linked list
b. Doubly linked list
c. Circular linked list
d. None of the above
17. What is the time complexity for deleting the first node in a singly linked list?
a. O(1)
b. O(n)
c. O(log n)
d. O(n log n)
18. What is the space complexity for inserting a node at a specific position in a linked list?
a. O(1)
b. O(n)
c. O(log n)
d. O(n log n)
19. Which type of linked list has a connection between the last node and the first node?
a. Singly linked list
b. Doubly linked list
c. Circular linked list
d. None of the above
20. In a doubly linked list, the first node's previous pointer points to:
a. The last node
b. Null
c. The second node
d. None of the above
23. Which of the following is true regarding a self-referential structure in linked lists?
a. It points to the next node
b. It points to the previous node
c. It points to itself
d. None of the above
24. Which of the following is true regarding a dummy node in linked lists?
a. It is the last node in the list
b. It contains no data
c. It is the first node in the list
d. None of the above
25. Which type of linked list has the least memory overhead for each element?
a. Singly linked list
b. Doubly linked list
c. Circular linked list
d. All have the same memory overhead
26. Which of the following is not a valid operation on a linked list?
a. Searching for an element
b. Merging two linked lists
c. Accessing an element by index
d. None of the above
27. What is the time complexity for finding the middle element of a linked list?
a. O(1)
b. O(n)
c. O(log n)
d. O(n log n)
29. Which type of linked list allows for efficient reversal of the list?
a. Singly linked list
b. Doubly linked list
c. Circular linked list
d. None of the above
31. Which type of linked list is best suited for implementing adjacency lists in graphs?
a. Singly linked list
b. Doubly linked list
c. Circular linked list
d. None of the above
32. Which of the following statements about a tail pointer in a linked list is true?
a. It points to the first node
b. It points to the last node
c. It is null
d. None of the above
33. Which type of linked list is commonly used to implement symbol tables in compilers?
a. Singly linked list
b. Doubly linked list
c. Circular linked list
d. None of the above
34. Which of the following is true about a sentinel node in a linked list?
a. It is the last node in the list
b. It contains data
c. It is used for simplifying list operations
d. None of the above
35. Which type of linked list is suitable for applications where elements need to be accessed
in a circular manner?
a. Singly linked list
b. Doubly linked list
c. Circular linked list
d. None of the above
36. Which of the following is true regarding a header node in a linked list?
a. It is the last node in the list
b. It contains data
c. It is used for simplifying list operations
d. None of the above
37. In a circular linked list, what is the time complexity for inserting a node at a specific
position?
a. O(1)
b. O(n)
c. O(log n)
d. O(n log n)
38. What is the time complexity for merging two linked lists?
a. O(1)
b. O(n)
c. O(log n)
d. O(n log n)
39. Which of the following is a valid approach to detect a cycle in a linked list?
a. Hashing
b. Floyd's cycle detection algorithm
c. Using a visited flag for each node
d. All of the above
40. In a circular linked list, what is the time complexity for deleting the last node?
a. O(1)
b. O(n)
c. O(log n)
d. O(n log n)
41. In a circular linked list, what is the time complexity for deleting a node at a specific
position?
a. O(1)
b. O(n)
c. O(log n)
d. O(n log n)
42. Which of the following is true about a NULL pointer in a linked list?
a. It points to the first node
b. It points to the last node
c. It indicates the end of the list
d. None of the above
43. What is the space complexity for reversing a linked list iteratively?
a. O(1)
b. O(n)
c. O(log n)
d. O(n log n)
44. Which of the following is true regarding a tail sentinel node in a linked list?
a. It is the last node in the list
b. It contains data
c. It is used for simplifying list operations
d. None of the above
45. What is the time complexity for finding the k-th node from the end of a linked list?
a. O(1)
b. O(n)
c. O(log n)
d. O(n log n)
46. Which of the following is true about a head sentinel node in a linked list?
a. It is the last node in the list
b. It contains data
c. It is used for simplifying list operations
d. None of the above
47. Which type of linked list is suitable for representing sparse matrices?
a. Singly linked list
b. Doubly linked list
c. Circular linked list
d. None of the above
48. What is the time complexity for finding the intersection point of two linked lists?
a. O(1)
b. O(n)
c. O(log n)
d. O(n log n)
49. Which of the following is not a valid way to remove duplicates from a sorted linked list?
a. Using a hash set
b. Iterating through the list and removing duplicates
c. Using recursion
d. None of the above
50. In a circular linked list, what is the time complexity for finding the middle element?
a. O(1)
b. O(n)
c. O(log n)
d. O(n log n)