
SRM RMP-MCA -20.01.2024-FN
Authored by CCC info@ccc.training
English
Professional Development
Used 1+ times

AI Actions
Add similar questions
Adjust reading levels
Convert to real-world scenario
Translate activity
More...
Content View
Student View
15 questions
Show all answers
1.
MULTIPLE CHOICE QUESTION
1 min • 1 pt
What does the following function do? void fun1(struct node* head) { if(head == NULL) return; fun1(head->next); printf("%d ", head->data); }
Prints all nodes of linked lists
Prints all nodes of linked list in reverse order
Prints alternate nodes of Linked List
Prints alternate nodes in reverse order
2.
MULTIPLE CHOICE QUESTION
1 min • 1 pt
What is the modified list after the following double linked list is passed to the function call: NULL<-1 <--> 2 <--> 3 <--> 4 <--> 5 <-->6->NULL void fun(struct node **head_ref) { struct node *temp = NULL; struct node *current = *head_ref; while (current != NULL) { temp = current->prev; current->prev = current->next; current->next = temp; current = current->prev; } if(temp != NULL ) *head_ref = temp->prev; }
2 <--> 1 <--> 4 <--> 3 <--> 6 <--> 5
5 <--> 4 <--> 3 <--> 2 <--> 1 <--> 6
6 <--> 5 <--> 4 <--> 3 <--> 2 <--> 1
6 <--> 5 <--> 4 <--> 3 <--> 1 <--> 2
3.
MULTIPLE CHOICE QUESTION
1 min • 1 pt
What will be the output of the following code snippet for the list 1->2->3->4->5->6? void solve(struct node* start) { if(start == NULL) return; printf("%d ", start->data); if(start->next != NULL ) solve(start->next->next); printf("%d ", start->data); }
1 2 3 4 5 6
1 3 5 5 3 1
1 3 5 1 3 5
2 4 6 1 3 5
4.
MULTIPLE CHOICE QUESTION
1 min • 1 pt
What will the function return if the following list is passed 1 -> 2 -> 3 -> 4 -> 5 int solve(ListNode* root) { int sum = 0; while (root != NULL) { sum += root -> val; root = root -> next; } return sum; }
15
20
5
1
5.
MULTIPLE CHOICE QUESTION
1 min • 1 pt
What does the following code snippet do? ListNode* solve(ListNode* head) { ListNode* prev = NULL; if(head == NULL) { return head; } if(head -> next == NULL) { return head; } ListNode* curr = head -> next; while(head != NULL) { head -> next = prev; prev = head; head = curr; if(curr != NULL) { curr = curr -> next; } } return prev; }
Returns the original linked list
Returns the linked list after reversing it
Returns a linked list containing elements at odd indices only
None of the above
6.
MULTIPLE CHOICE QUESTION
1 min • 1 pt
What will be the output of the following code snippet for 1->2->3->4->5? void solve (ListNode* head) { while(head != NULL) { cout << head -> data << " "; head = head -> next; } }
1 2 3 4 5
5 4 3 2 1
1 3 5 2 4
2 4 1 3 5
7.
MULTIPLE CHOICE QUESTION
1 min • 1 pt
What does the following code snippet do? int solve (ListNode* list) { ListNode* fast = list; ListNode* slow = list; while(fast -> next != NULL && fast -> next -> next != NULL) { fast = fast -> next -> next; slow = slow -> next; } return slow -> data; }
Find middle element in the linked list.
Find last element in the linked list
Find first element in the linked list
None of the above
Access all questions and much more by creating a free account
Create resources
Host any resource
Get auto-graded reports

Continue with Google

Continue with Email

Continue with Classlink

Continue with Clever
or continue with

Microsoft
%20(1).png)
Apple
Others
Already have an account?