Q.
The following C function takes a simply-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. Choose the correct alternative to replace the blank line.
typedef struct node
{
int value;
struct node *next;
}Node;
Node *move_to_front(Node *head)
{
Node *p, *q;
if ((head == NULL: || (head->next == NULL))
return head;
q = NULL; p = head;
while (p-> next !=NULL)
{
q = p;
p = p->next;
}
_______________________________
return head;
}
Similar Questions
1.
In linked lists there are no NULL links in
2. Can we read a data item at any location of a list within a constant time (i.e.
O(1))?
3. node.next -> node.next.next; will make
4. A circular linked list can be used for
5. In doubly linked lists
6. The advantage of …………….. is that they solve the problem if sequential storage representation. But disadvantage in that is they are sequential lists.
7. There is an extra element at the head of the list called a ……….
8. Each node in a linked list has two pairs of ………….. and ……………….
9. The disadvantage in using a circular linked list is …………………….
10. A linear list in which each node has pointers to point to the predecessor and successors nodes is called as
DATA STRUCTURE TOPICS