51. The following C function takes a simply-linked list as an 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;
}
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;
}52. Which of the following concepts make extensive use of arrays?
53. Elements in an array are accessed . . . . . . . .
54. Consider an implementation of unsorted singly linked list. Suppose it has its representation with a head pointer only. Given the representation, which of the following operation can be implemented in O(1) time?
I. Insertion at the front of the linked list
II. Insertion at the end of the linked list
III. Deletion of the front node of the linked list
IV. Deletion of the last node of the linked list
I. Insertion at the front of the linked list
II. Insertion at the end of the linked list
III. Deletion of the front node of the linked list
IV. Deletion of the last node of the linked list
55. Which of the following array element will return the top-of-the-stack-element for a stack of size N elements(capacity of stack > N)?
56. What is the need for a circular queue?
57. Which of these is not an application of a linked list?
58. Assuming int is of 4bytes, what is the size of int arr[15];?
59. How do you initialize an array in C?
60. 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?
Read More Section(Introduction to Data Structures)
Each Section contains maximum 100 MCQs question on Introduction to Data Structures. To get more questions visit other sections.
