Question 11
What are the time complexities of finding 8th element from beginning and 8th element from end in a singly linked list? Let n be the number of nodes in linked list, you may assume that n > 8.
Question 12
Is it possible to create a doubly linked list using only one pointer with every node.
Question 13
Given pointer to a node X in a singly linked list. Only one pointer is given, pointer to head node is not given, can we delete the node X from given linked list?
Question 15
Consider the following function to traverse a linked list.
void traverse(struct Node *head)
{
while (head->next != NULL)
{
printf(\"%d \", head->data);
head = head->next;
}
}
Which of the following is FALSE about above function?
Question 16
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 provided to the record on which the operation is to be performed. An algorithm performs the following operations on the list in this order: Θ(N) delete, O(log N) insert, O(log N) find, and Θ(N) decrease-key What is the time complexity of all these operations put together?
Question 18
The concatenation of two lists is to be performed in O(1) time. Which of the following implementations of a list should be used?
Question 19
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 = 1;
if(t2 == NULL)
return head;
while t2 != NULL)
{
if (t1.val != t2.val) --------------------------→ (S1)
{
(*j)++; t1 -> next = t2; t1 = t2: ----------→ (S2)
}
t2 = t2 →next;
}
t1 →next = NULL;
return head;
}
Assume the list contains n elements (n≥2) in the following questions. a). How many times is the comparison in statement S1 made? b). What is the minimum and the maximum number of times statements marked S2 get executed? c). What is the significance of the value in the integer pointed to by j when the function completes?
Question 20
Suppose there are two singly linked lists both of which intersect at some point and become a single linked list. The head or start pointers of both the lists are known, but the intersecting node and lengths of lists are not known. What is worst case time complexity of optimal algorithm to find intersecting node from two intersecting linked lists?
There are 42 questions to complete.