Professional Documents
Culture Documents
DS - Exit - Exam - LinkedList
DS - Exit - Exam - LinkedList
DS - Exit - Exam - LinkedList
1. Which data structure consists of a sequence of nodes where each node contains a reference to the next
node?
a) Stack b) Queue c) Linked list d) Array
2. What is the time complexity for inserting a node at the beginning of a linked list?
a) O(1) b) O(log n) c) O(n) d) O(n^2)
3. The following C code searches for a value (key) in a doubly linked list. Assuming we have initialized the
linked list and temp is a struct type pointer. Answer the questions shown as numbers 1, 2 and 3
inside the code.
What code is correct in place of 1?
a) temp->info b)temp!=null c) temp->next d) none of the above
struct node{
struct node *prev;
int info;
struct node *next;
};
void search(){
int key, count = 0;
struct node *temp;
if (temp == NULL){
printf("List is empty.");
return;
}
printf("Enter value to search : ");
scanf("%d", &key);
while (______1_______){
if (______2_____ == key){
printf("key found in %d position",count+1);
return;
}
else
temp = temp->____3____];
count++; }
printf("Error : %d not found in the list.", key);
}
if (*head == NULL) {
*head = newNode;
} else {
struct Node* current = *head;
while (current->next != NULL) {
current = current->next;
}
current->next = newNode;
}
}
a) InsertingAtBeginning b) InsertionAtTheEnd c) InsertionInTheMiddle d) all
9. Which of the following data structures can be implemented using a linked list?
a) Stack b) Queue c) Binary tree d) All of the above
10. Which operation allows you to access the value of a node in a linked list?
a) Insert b) Delete c) Search d) Traverse
11. Which of the following is not an advantage of using a linked list?
a) Dynamic size
b) Efficient random access
c) Easy insertion and deletion
d) Memory efficiency
12. What is the polynomial representation f(x) of the polynomial linked list representation given below.
a) f(x) = mx3+nx4+kx2+px+q
b) f(x) = mx4+nx3+kx2+px+qx10
c) f(x) = mx4+nx3+kx2+px+0
d) f(x) = mx4+nx3+kx2+px+q
13. Which data structure allows access to elements in a sequential order?
a) Stack
b) Queue
c) Linked list
d) Tree
14. In a circular linked list, which node contains no reference to the next node?
a) First node
b) Last node
c) Middle node
d) None of the above