Recent questions tagged linked-list

3 3 votes
1 1 answer
1.9k
1.9k views
Assume that you have a semaphore associated with each item on a doubly linked list. Using No other synchronization primitive, What is the fewest number of semaphore that ...
5 5 votes
3 answers 3 answers
2.6k
2.6k views
You are given a linked list, $L$ of $n$ integers, and another linked list, $P$, of $k$ integers where $k <<< n$. $L$ is sorted in ascending order but $P$ is not necessari...
5 5 votes
2 answers 2 answers
3.6k
3.6k views
For a singly linked list where each node has a pointer to a data array as well as a next pointer, what would be the worst case time complexity to delete an intermediate n...
2 2 votes
1 answers 1 answer
1.0k
1.0k views
The following C function takes a singly-linked list of integers as a parameter and rearranges the elements of the list. The function is called with the list containing th...
4 4 votes
2 answers 2 answers
1.3k
1.3k views
Time complexity of the optimal algorithm to interchange the $m^{th}$ and $n^{th}$ elements of a singly Linked List is $\Theta(m+n)$$\Theta(m)$ when $m\geq n$ otherwise $...
4 4 votes
2 answers 2 answers
1.2k
1.2k views
Two linked lists having n and m elements are stored in sorted order. What is the worst case complexity of program to print common elements of two lists ?$\begin{align*} &...
0 0 votes
1 answers 1 answer
2.5k
2.5k views
Consider an implementation of unsorted single linked list. Suppose it has its representation with a head and a tail pointer (i.e. pointers to the first and last nodes of ...
0 0 votes
1 answers 1 answer
1.0k
1.0k views
Q)The below code returns decimal value of binary linked list int val(struct Node *head) { struct Node *p = head; int val2= 0; while (p!= NULL) { XYZ;//fill the contents o...
0 0 votes
1 1 answer
1.1k
1.1k views
To insert a node at the end of double linked list we need to modify two pointers right??But answer given is one pointer.can someone clarify?
5 5 votes
1 answers 1 answer
4.6k
4.6k views
Consider the following algorithm to build a balanced search tree from a sorted sequence.* Make the mid-point of the sequence the root of the tree* Recursively construct b...
2 2 votes
1 1 answer
743
743 views
How does this code return Nth the node from the end of the linked list in one pass?Node * GetNthNode ( Node* Head , int NthNode ){ Node * pNthNode = NULL; Node ...
2 2 votes
1 1 answer
7.8k
7.8k views
If the queue is implemented with a linked list, keeping track of a front pointer, which of these pointers will change during an insertion into an non-empty queue?Neither ...
3 3 votes
2 answers 2 answers
3.7k
3.7k views
Given a linked list :1->2->3->4->5->6,make the following changes1->6->2->5->3->4What would be the most effiicient way to make this change?
2 2 votes
2 2 answers
5.3k
5.3k views
The efficient data structure to insert/delete a number in a stored set of number isQueueLinked listDoubly linked listBinary tree
7 7 votes
7 answers 7 answers
20.1k
20.1k views
Consider a single linked list where $F$ and $L$ are pointers to the first and last elements respectively of the linked list. The time for performing which of the given op...
5 5 votes
2 answers 2 answers
3.3k
3.3k views
Can Someone explain either Tree or Stack method to trace out this recursion ?What is the output of this Program ?
5 5 votes
3 answers 3 answers
18.4k
18.4k views
Which of the following operations is performed more efficiently by doubly linked list than by linear linked list?Deleting a node whose location is givenSearching an unsor...
2 2 votes
1 answers 1 answer
19.4k
19.4k views
The time required to search an element in a linked list of length n is$O(\log_2 n)$$O(n)$$O(1)$$O(n^2)$
14 14 votes
2 answers 2 answers
3.5k
3.5k views
Consider a linked list containing $n$ nodes, where each node contains two pointers $ptr1$ and $ptr2$. For each node, $ptr1$ points to the next node of the list. Describe ...
9 9 votes
1 answers 1 answer
1.8k
1.8k views
We use the notation $[x1,x2,...,xn]$ to denote a list of integers. $[]$ denotes the empty list, and $[n]$ is the list consisting of one integer $n$. For a nonempty list l...
2 2 votes
0 0 answers
619
619 views
A finite sequence of bits is represented as a list with values from the set $\{0,1\}$—for example, $[0,1,0], [1,0,1,1], \dots [ \: ]$ denotes the empty list, and $[b]$ is...
1 1 vote
0 0 answers
744
744 views
A finite sequence of bits is represented as a list with values from the set {0,1}&mdash;for example, [0,1,0], [1,0,1,1], . . . .[ ] denotes the empty list, and [b] is the...
8 8 votes
4 answers 4 answers
8.9k
8.9k views
The following steps in a linked listp = getnode() info(p) = 10 next (p) = list list = presult in which type of operation?Pop operation in stackRemoval of a nodeInserting ...
0 0 votes
4 4 answers
1.9k
1.9k views
If we are given a linked list then we have to manipulate such that even indexed node are arranged together and oddindexed nodes are arranged together after even indexed n...
162 162 votes
15 answers 15 answers
57.9k
57.9k views
$N$ items are stored in a sorted doubly linked list. For a delete operation, a pointer is provided to the record to be deleted. For a decrease-key operation, a pointer is...
3 3 votes
2 2 answers
3.8k
3.8k views
1 1 vote
1 1 answer
1.2k
1.2k views
Here, what will be the Head->Next , I am confused is it first element 50 or second element 29.
2 2 votes
0 0 answers
694
694 views
A program has just read the $12^{th}$ disk block using linked allocation. If it next want to read the $5^{th}$ disk block, then the number of disk blocks must the program...
0 0 votes
1 1 answer
5.8k
5.8k 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); prin...
1 1 vote
1 1 answer
1.1k
1.1k views
My doubt is that the single list queue is the form : 1->2->3->4->5->6->7->8->9->NULL with 1 as the rear node and 9 as the front node. Also, in a queue, addition takes fro...