in Programming in C recategorized by
1,783 views
1 vote
1 vote
What 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
in Programming in C recategorized by
1.8k views

2 Comments

D) because it takes O(1). Rest takes O(n).

Watch this for better understanding https://www.youtube.com/watch?v=BL1JOVqTlW8

0
0
Yes option D because random access is possible with array using indices.
1
1

1 Answer

0 votes
0 votes
Yes for array implementation time would be order(1) but why not answer is double linked list here also to access the last element time would be order(1)  correct  if I am wrong

2 Comments

since it is not random accessed
0
0
This is because all the linked list have the property of sequential access which means if you want to access any kth element you have to traverse all its previous nodes. You can’t simply jump to any node just like you do for array.
0
0

Related questions