search
Log In
0 votes
675 views
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 675 views
0

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

Watch this for better understanding

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

1 Answer

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
0
since it is not random accessed

Related questions

0 votes
0 answers
1
254 views
struct node* foo(struct node* a, struct node* b) { struct node* result, *rec; if(a==null) return b; else if(b==null) return a; else { rec=foo(a->next,b->next); result=a; a->next=b; b->next=rec; return result; } }
asked Sep 17, 2018 in Programming Vaishnavi01 254 views
1 vote
0 answers
2
590 views
Let P be a single linked list.Let Q be a pointer to an intermediate node 'X' in the list.What is the worst case time complexity of best known algorithm to delete the node 'X ' from the list
asked Nov 25, 2017 in Programming saipriyab 590 views
5 votes
1 answer
3
1.9k views
What would be the asymptotic time complexity to add a node at the end of singly linked list, if the pointer is initially pointing to the head of the list? O(n) O(1) θ(n2) θ(n)
asked Nov 14, 2017 in Programming hacker16 1.9k views
4 votes
1 answer
4
333 views
I was trying to implement the Linked List code in C. It compiles fine but doesn't give any output. What seems to be the error? I think I messed up at passing pointer references as function parameters. My Code (Insert At Beginning): #include <stdio.h> ... to the head node(pointer to pointer) to the function. - Return the modified head node by the function. Please read about Reference Semantics.
asked Apr 26, 2017 in Programming RahulVerma 333 views
...