Recent questions tagged linked-list

6 6 votes
0 0 answers
2.5k
2.5k views
What does the following function do for a given Linked List with first node as head? void fun1(struct node* head) { if(head==NULL) return; fun1(head->next); printf("%d",h...
6 6 votes
0 0 answers
2.0k
2.0k views
Consider the following function that takes reference to head of a Doubly Linked List as parameter. Assume that a node of doubly linked list has previous pointer as $\text...
2 2 votes
2 2 answers
1.6k
1.6k views
Consider the following linked list :Which of the following piece of code will insert the node pointed to by $q$ at the end of the list ?$\text{for (p=list; p !=NULL; p=p ...
0 0 votes
1 1 answer
1.4k
1.4k views
Which one of the following is a physical data structure ?ArrayLinked listsStacksTables
1 1 vote
1 1 answer
677
677 views
What is the time required to insert an element in a stack with linked implementation?$O \left(\log_{2}n \right)$$O \left(n \right)$$O \left(n \log_{2}n \right)$$O \left(1...
2 2 votes
1 1 answer
1.8k
1.8k views
What operation is supported in constant time by the doubly linked list, but not by the singly linked list ?AdvanceBackupFirstRetrieve
62 62 votes
13 answers 13 answers
47.6k
47.6k views
What is the worst case time complexity of inserting $n$ elements into an empty linked list, if the linked list needs to be maintained in sorted order?$\Theta(n)$$\Theta(n...
0 0 votes
0 0 answers
904
904 views
Explain how to implement doubly linked lists using only one pointer value $x.np$ per item instead of the usual two (next and prev). Assume that all pointer values can be ...
0 0 votes
1 1 answer
1.7k
1.7k views
Give a $\Theta(n)$ time nonrecursive procedure that reverses a singly linked list of $n$ elements. The procedure should use no more than constant storage beyond that need...
1 1 vote
1 1 answer
920
920 views
The dynamic-set operation $UNION$ takes two disjoint sets $S_1$ and $S_2$ as input, and it returns a set $S=S_1 \cup S_2$ consisting of all the elements of $S_1$ and $S_2...
1 1 vote
1 1 answer
861
861 views
Implement the dictionary operations $INSERT$, $DELETE$, and $SEARCH$ using singly linked, circular lists. What are the running times of your procedures?
0 0 votes
0 0 answers
561
561 views
LIST-SEARCH’(L, k) 1 x = L.nil.next 2 while x != L.nil and x.key != k 3 x = x.next 4 return xAs written, each loop iteration in the LIST-SEARCH’ procedure requires two te...
2 2 votes
2 2 answers
668
668 views
Implement a queue by a singly linked list $L$. The operations of $ENQUEUE$ and $DEQUEUE$ should still take $O(1)$ time.
1 1 vote
1 1 answer
674
674 views
Implement a stack using a singly linked list $L$. The operations $PUSH$ and $POP$ should still take $O(1)$ time.
0 0 votes
1 1 answer
830
830 views
Can you implement the dynamic-set operation $INSERT$ on a singly linked list in $O(1)$ time? How about $DELETE$?
0 0 votes
0 0 answers
801
801 views
why we use double pointer struct Node head here? can anyone explain with details /* Given a reference (pointer to pointer) to the head of a DLL and an int, appends a new...
0 0 votes
2 2 answers
1.2k
1.2k views
Can somebody write the code or algorithm, how merge sort works efficiently in linked list? Is Heap sort most inefficient in Linked List Sorting? Elaborate plz
1 1 vote
0 0 answers
1.8k
1.8k views
An OS uses virtual memory with paging technique for memory allocation. Which of the following searching technique on given data structure use locality of reference?Linear...
0 0 votes
3 3 answers
885
885 views
The following function attempts to merge two sorted linked lists. ListNode is the custom structure representing a node in the linked list.ListNode* Merge(ListNode* pHead1...
1 1 vote
2 2 answers
4.3k
4.3k views
Consider a singly linked list. What is the worst case time complexity of the best-known algorithm to delete the node $a$, pointer to this node is $q$, from the list?$O(n ...
7 7 votes
1 answers 1 answer
2.9k
2.9k views
Which of the following sorting algorithms performs efficiently to sort a singly linked list containing $\log n$ nodes and the corresponding time complexity is?$\text{Inse...
1 1 vote
3 3 answers
1.7k
1.7k views
What does the following program do on two linked lists? Struct node *myFun (struct node * a, struct node * b) { Struct node *new = NULL ; If (a = = NULL) return (b) ;...
1 1 vote
1 1 answer
735
735 views
2 2 votes
1 1 answer
2.0k
2.0k views
int find (struct node * first, int n) { while (first data ! = n) first = first — next; if (first data = = n) return(1); else return (-1); in the above code segment if th...
2 2 votes
1 1 answer
4.6k
4.6k views
You're entrusted with the task of deleting a node in a singly linkedlist, whose data field is 'x'. Note that, the node which is to be deleted can be at any arbitrary posi...
1 1 vote
0 0 answers
2.2k
2.2k views
Suppose a circular queue of capacity (n – 1) elements is implemented with an array of n elements.Now, in this queue what will be condition for FULL and EMPTY?Full:(REAR+1...
1 1 vote
2 2 answers
2.0k
2.0k views
There is a singly linked list. We have a pointer to a particular node(it is not tail node). what is the time and space complexity required to delete this node?my approach...
0 0 votes
1 1 answer
2.3k
2.3k views
To reverse a Singly Linked List is the below is correct code? (or) need to change Struct node *reverse(struct node *start) { Struct node *prev,*ptr,*next; prev=NULL; ptr=...
1 1 vote
0 0 answers
1.7k
1.7k views
Consider an unrolled linked list with $n$ elements.This list stores multiple elements in each node.What is the worst case time complexity to find the $k^{th}$ element if ...