Recent questions tagged linked-list

6 6 votes
2 2 answers
215
215 views
A singly linked list contains $n$ nodes. We want to reverse the order of the elements in the linked list by changing links, not by copying all elements into an array.Whic...
7 7 votes
2 2 answers
206
206 views
The following function is supposed to reverse a singly linked list:struct node { int data; struct node *next; }; static void reverse(struct node head_ref) { struct node ...
8 8 votes
2 2 answers
207
207 views
Consider the following C-style code fragment for reversing a non-empty singly linked list:curr = front; next = curr->next; prev = NULL; while (curr != NULL) { (*) } front...
3 3 votes
3 3 answers
219
219 views
Consider the following singly linked list:$\texttt{'B' - 'A' - 'S' - 'E' - NULL}$The pointer $\texttt{head}$ points to the first node containing $\texttt{'B'}$.What chara...
6 6 votes
2 2 answers
223
223 views
A singly linked list maintains two pointers:struct Node *front; // points to first node struct Node *rear; // points to last nodeWhich operation would be inefficient when...
9 9 votes
2 2 answers
238
238 views
Consider the problem of finding the middle node in a list $l$ of size $n$, given that $n$ is odd. Count the number of accesses to positions of list $l$ needed to find the...
7 7 votes
4 4 answers
231
231 views
Consider the following C function intended to delete the last node of a singly linked list:void removeLast(struct Node *head) { struct Node *p = head; struct Node *q = p-...
6 6 votes
3 3 answers
230
230 views
Consider the following structure:struct Node { int data; struct Node *next; };A function should insert a new node containing value $\texttt{x}$ at the beginning of a sing...
5 5 votes
2 2 answers
285
285 views
Consider the following singly linked list:$\texttt{12 - 18 - 25 - 31 - 44 - 57 - NULL}$Now, consider the following function:int Size(struct Node *list) { int count = 0; w...
5 5 votes
2 2 answers
245
245 views
A singly linked list is:$\texttt{5 - 8 - 20 - NULL}$A new node $\texttt{​newP}$ contains data $9$. Pointer $\texttt{​prevP}$ points to the node containing $8$.The inserti...
4 4 votes
2 2 answers
199
199 views
A singly linked list is:$\texttt{5 - 8 - 20 - 9 - 20 - 7 - NULL}$The function $\texttt{deleteByValue(L, val)}$ removes only the first node whose data is equal to $\texttt...
7 7 votes
1 1 answer
358
358 views
A sequence of $n$ elements is implemented in two ways:As a normal array with contiguous memory and no extra empty slot. As a singly linked list with only a $\texttt{head}...
6 6 votes
1 1 answer
197
197 views
For a singly linked list storing only the head pointer, which of the following operations can be done in worst-case $O(1)$ time?Access the $i$-th element Modify the $i$-t...
2 2 votes
1 1 answer
151
151 views
Consider the following Python code:class Node: def __init__(self, data): self.data = data self.next = None a = Node("A") b = Node("B") c = Node("C") d = Node("D") a.next ...
2 2 votes
1 1 answer
130
130 views
Consider the following Python code:class Node: def __init__(self, data): self.data = data self.next = None head = Node(20) tail = head new_first = Node(10) new_first.next...
2 2 votes
1 1 answer
119
119 views
Consider the following Python code:class Node: def __init__(self, data): self.data = data self.next = None n1 = Node(5) n2 = Node(10) n3 = Node(15) n4 = Node(20) n1.next ...
2 2 votes
2 2 answers
179
179 views
Consider the following Python code:class Node: def __init__(self, data): self.data = data self.next = None a = Node("A") b = Node("B") c = Node("C") a.next = b b.next = c...
3 3 votes
2 2 answers
164
164 views
Consider the following Python code:class Node: def __init__(self, value): self.value = value self.next = None n1 = Node(10) n2 = Node(20) print(n1.value, n1.next, n2.valu...
7 7 votes
6 6 answers
1.9k
1.9k views
Consider the following code snippet in C language that computes the number of nodes in a non-empty singly linked list pointed to by the pointer variable head.struct node{...
2 2 votes
1 1 answer
653
653 views
Consider the following code snippet in the C language that computes the number of nodes in a nonempty S.L.L. pointed by the pointer variable $\verb|head.struct node|$ { ...
4 4 votes
1 1 answer
529
529 views
Someone help with this...I am getting option-b but key is opt-aa)b)c)d)
3 3 votes
1 1 answer
618
618 views
Suppose that we use a linked list to represent a queue and that in addition to the enqueue and dequeue functions add a new operation to the queue that deletes the last el...
0 0 votes
1 1 answer
210
210 views
Which one of the following statements is one of the limitations of Waterfall Model?The phases have clearly defined end products (exit criteria), which in turn are conveni...
3 3 votes
1 1 answer
508
508 views
Which collision resolution technique involves maintaining a linked list of collided keys?Linear probingQuadratic probingChainingDouble hashing