0% found this document useful (0 votes)
184 views12 pages

Linked List Ques and Ans

A linked list is a data structure where each node contains a data field and a pointer to the next node. The pointer field points to the next node in the list. Operations like inserting a node at the second position or concatenating two lists can be done in constant time using a doubly linked list which allows traversal in both directions. Linked lists are not suitable for binary search because they do not allow random access to elements. They use dynamic memory allocation and the worst case time complexity for searching a singly linked list of length n is O(n).

Uploaded by

Boppana yaswanth
Copyright
© © All Rights Reserved
We take content rights seriously. If you suspect this is your content, claim it here.
Available Formats
Download as PPTX, PDF, TXT or read online on Scribd
0% found this document useful (0 votes)
184 views12 pages

Linked List Ques and Ans

A linked list is a data structure where each node contains a data field and a pointer to the next node. The pointer field points to the next node in the list. Operations like inserting a node at the second position or concatenating two lists can be done in constant time using a doubly linked list which allows traversal in both directions. Linked lists are not suitable for binary search because they do not allow random access to elements. They use dynamic memory allocation and the worst case time complexity for searching a singly linked list of length n is O(n).

Uploaded by

Boppana yaswanth
Copyright
© © All Rights Reserved
We take content rights seriously. If you suspect this is your content, claim it here.
Available Formats
Download as PPTX, PDF, TXT or read online on Scribd
You are on page 1/ 12

LINKED LIST

1 In linked list each node contain


minimum of two fields. One field is data
field to store the data second field is?
a) Pointer to character
b) Pointer to integer
c) Pointer to node
d) Node

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

You might also like