Linked List Ques and Ans
Linked List Ques and Ans
Answer: c
2
What would be the asymptotic time
complexity to insert an element at the
second position in the linked list?
a) O(1)
b) O(n)
c) O(n2)
d) None of the mentioned
Answer: a
3The concatenation of two list can
performed in O(1) time. Which of the
following variation of linked list can be
used?
a) Singly linked list
b) Doubly linked list
c) Circular doubly linked list
d) Array implementation of list
Answer: c
4What kind of linked list is best to
answer question like “What is the
item at position n?”
a) Singly linked list
b) Doubly linked list
c) Circular linked list
d) Array implementation of linked list
Answer: d
5Linked lists are not suitable to for the
implementation of?
a) Insertion sort
b) Radix sort
c) Polynomial manipulation
d) Binary search
Answer: d
Explanation: It cannot be implemented
using linked lists.
6Linked list is considered as an example of
___________ type of memory allocation.
a) Dynamic
b) Static
c) Compile time
d) None of the mentioned
Answer: a
Explanation: As memory is allocated at
the run time.
7 In Linked List implementation, a
node carries information regarding
a) Data
b) Link
c) Data and Link
d) None of the mentioned
Answer: b
8Which of the following sorting algorithms can be used to
sort a random linked list with minimum time complexity?
a) Insertion Sort
b) Quick Sort
c) Heap Sort
d) Merge Sort
Answer: d
Explanation: Both Merge sort and Insertion sort can be used
for linked lists. The slow random-access performance of a
linked list makes other algorithms (such as quicksort)
perform poorly, and others (such as heapsort) completely
impossible. Since worst case time complexity of Merge Sort is
O(nLogn) and Insertion sort is O(n2), merge sort is preferred.
9You are given pointers to first and last nodes of a singly
linked list, which of the following operations are dependent
on the length of the linked list?
a) Delete the first element
b) Insert a new element as a first element
c) Delete the last element of the list
d) Add a new element at the end of the list
Answer: c
Explanation: a) Can be done in O(1) time by deleting memory
and changing the first pointer.
b) Can be done in O(1) time, see push() here
c) Delete the last element requires pointer to previous of last,
which can only be obtained by traversing the list.
d) Can be done in O(1) by changing next of last and then last.
10In the worst case, the number of
comparisons needed to search a singly
linked list of length n for a given element
is
a) log2 n
b) n⁄2
c) log2 n – 1
d) n
Answer: d