1.
Assume a linked list has been created and start pointer is referring the first node of that linked list. select the following code that can add a new node that address hold by temp pointer, at beginning of that linked list
Correct Answer
A. Temp->link=start; start=temp;
Explanation
The correct answer is "temp->link=start; start=temp;". This code snippet first assigns the link of the new node to the start pointer, which ensures that the new node points to the previous first node in the linked list. Then, the start pointer is updated to point to the new node, effectively adding it to the beginning of the linked list.
2.
Insertion of a node at the beginning of the singly linked list involves modification of
Correct Answer
B. Two pointer
Explanation
When inserting a node at the beginning of a singly linked list, we need to modify two pointers. First, we need to update the "next" pointer of the new node to point to the current head of the list. This ensures that the new node is now the first node in the list. Second, we need to update the pointer of the head of the list to point to the new node. This ensures that the new node becomes the new head of the list and the rest of the list remains connected. Therefore, two pointers need to be modified in this operation.
3.
Assume a linked list referred by start pointer. which of the following set of statements will result into deletion of a node at position pos
Correct Answer
A. If(pos==1)
start=start->link;
else
{
t1=start;
for(int i=2;ilink;
}
t1->link=t1->link->link;
}
Explanation
This set of statements will result in the deletion of a node at position pos. If pos is equal to 1, it means that the node to be deleted is the first node. In this case, the start pointer is updated to point to the second node, effectively removing the first node from the linked list. If pos is not equal to 1, it means that the node to be deleted is not the first node. The t1 pointer is set to point to the start pointer, and a loop is executed until i is equal to pos-1. This loop moves the t1 pointer to the node just before the node to be deleted. Finally, the link of the t1 pointer is updated to skip over the node to be deleted, effectively removing it from the linked list.
4.
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?
Correct Answer
A. Possible if size of linked list is even
5.
Which of the following points is/are true about Linked List data structure when it is compared with array
Correct Answer
D. All of the mentioned
Explanation
The statement "All of the mentioned" is the correct answer because all three points mentioned in the options are true about the Linked List data structure when compared with an array. Arrays have better cache locality, meaning that accessing elements in an array is faster due to their contiguous memory allocation. It is easier to insert and delete elements in a Linked List because it involves adjusting pointers, whereas in an array, it requires shifting elements. Lastly, random access is not allowed in a typical implementation of Linked Lists, as elements can only be accessed sequentially by following the pointers.
6.
What is the output of following function for start pointing to first node of following linked list?1->2->3->4->5->6void fun(struct node* start){ if(start==NULL) return; while(start->link!=NULL) { printf("%d ",(start->link)->info); start=start->link; } }
Correct Answer
B. 2 3 4 5 6
Explanation
The function starts by checking if the start node is NULL. If it is, the function returns. Otherwise, it enters a while loop that continues as long as the link of the current node is not NULL. Inside the loop, it prints the info of the next node and updates the start pointer to point to the next node. This process continues until the end of the linked list is reached. Therefore, the output of the function for the given linked list would be "2 3 4 5 6".
7.
What is the change in linked list after execution of the following code?start:- points to first node of linkedstart->info=start->link->info;
Correct Answer
A. The values of first node and second node will be same
Explanation
The code is assigning the value of the first node to the second node. Therefore, after executing the code, the values of the first and second nodes will be the same.
8.
Linked is a ......
Correct Answer
A. Linear data structure
Explanation
The given answer is "Linear data structure" because a linked list is a type of data structure where each element is connected to the next element through a pointer. It maintains a linear order of elements and allows sequential access to its elements. This makes it a linear data structure.
9.
You are given pointers to first and last nodes of a singly linked list, which of the following operations are dependent on the length of the linked list?
Correct Answer
C. Delete the last element of the list
Explanation
The operation of deleting the last element of the list is dependent on the length of the linked list. If the linked list has only one element, deleting the last element would result in an empty list. However, if the linked list has more than one element, deleting the last element would require traversing the entire list to reach the second-to-last element and update its next pointer. Therefore, the length of the linked list affects the complexity and feasibility of deleting the last element.
10.
Binary search is possible in Linked list
Correct Answer
B. False
Explanation
Binary search is not possible in a linked list because in order to perform binary search, we need random access to elements, which is not possible in a linked list. In a linked list, we can only access elements one by one starting from the head node. Binary search requires accessing the middle element of a sorted list, which is not feasible in a linked list. Therefore, the correct answer is False.