search
Log In

Recent questions tagged linked-lists

23 votes
3 answers
1
Linked lists are not suitable data structures for which one of the following problems? Insertion sort Binary search Radix sort Polynomial manipulation
asked Oct 4, 2014 in DS Kathleen 8.2k views
27 votes
2 answers
2
The following C function takes a singly-linked list as input argument. It modifies the list by moving the last element to the front of the list and returns the modified list. Some part of the code is left blank. typedef struct node { int value; struct node *next; } node; Node * ... $q \rightarrow next = NULL; p \rightarrow next = head; head = p$;
asked Sep 30, 2014 in DS jothee 5.2k views
8 votes
3 answers
3
Consider a singly linked list having $n$ nodes. The data items $d_1, d_2, \dots d_n$ are stored in these $n$ nodes. Let $X$ be a pointer to the $j^{th}$ node $(1 \leq j \leq n)$ in which $d_j$ is stored. A new data item $d$ ... algorithm to insert $d$ into the list to obtain a list having items $d_1, d_2, \dots, d_{j}, d,\dots, d_n$ in order without using the header.
asked Sep 30, 2014 in DS Kathleen 1.6k views
16 votes
3 answers
4
Consider the following piece of 'C' code fragment that removes duplicates from an ordered list of integers. Node *remove-duplicates (Node* head, int *j) { Node *t1, *t2; *j=0; t1 = head; if (t1! = NULL) t2 = t1 ->next; else return head; *j = ... number of times statements marked $S2$ get executed? What is the significance of the value in the integer pointed to by $j$ when the function completes?
asked Sep 29, 2014 in DS Kathleen 2.4k views
31 votes
5 answers
5
The concatenation of two lists is to be performed on $O(1)$ time. Which of the following implementations of a list should be used? Singly linked list Doubly linked list Circular doubly linked list Array implementation of list
asked Sep 29, 2014 in DS Kathleen 8.6k views
18 votes
5 answers
6
Let $p$ be a pointer as shown in the figure in a single linked list. What do the following assignment statements achieve? q: = p -> next p -> next:= q -> next q -> next:=(q -> next) -> next (p -> next) -> next:= q
asked Sep 26, 2014 in DS Kathleen 3.3k views
43 votes
4 answers
7
Suppose each set is represented as a linked list with elements in arbitrary order. Which of the operations among $\text{union, intersection, membership, cardinality}$ will be the slowest? $\text{union}$ only $\text{intersection, membership}$ $\text{membership, cardinality}$ $\text{union, intersection}$
asked Sep 19, 2014 in DS Kathleen 7.7k views
35 votes
7 answers
8
A circularly linked list is used to represent a Queue. A single variable $p$ is used to access the Queue. To which node should $p$ point such that both the operations $\text{enQueue}$ and $\text{deQueue}$ can be performed in constant time? rear node front node not possible with a single pointer node next to front
asked Sep 19, 2014 in DS Kathleen 12.7k views
36 votes
4 answers
9
Consider the function $f$ defined below. struct item { int data; struct item * next; }; int f(struct item *p) { return ((p == NULL) || (p->next == NULL)|| ((p->data <= p ->next -> data) && f(p->next))); } For a given linked list ... in non-decreasing order of data value the elements in the list are sorted in non-increasing order of data value not all elements in the list have the same data value
asked Sep 17, 2014 in DS Kathleen 6.9k views
16 votes
7 answers
10
In the worst case, the number of comparisons needed to search a single linked list of length $n$ for a given element is $\log n$ $\frac{n}{2}$ $\log_2 {n} - 1$ $n$
asked Sep 15, 2014 in DS Kathleen 7.6k views
30 votes
5 answers
11
The following C function takes a single-linked list of integers as a parameter and rearranges the elements of the list. The function is called with the list containing the integers $1, 2, 3, 4, 5, 6, 7$ in the given order. What will be the contents of the list after function completes execution? struct node { int value; struct ... $2, 1, 4 ,3, 6, 5, 7$ $1, 3, 2, 5, 4, 7, 6$ $2, 3, 4, 5, 6, 7, 1$
asked Sep 12, 2014 in DS Kathleen 7.6k views
...