
Linked List Reversal

Quiz
•
Computers
•
Professional Development
•
Hard
Madras Institute of Technology
FREE Resource
10 questions
Show all answers
1.
MULTIPLE CHOICE QUESTION
30 sec • 1 pt
What should be added in place of “/*ADD A STATEMENT HERE*/”, so that the function correctly reverses a linked list.
*head_ref = current;
*head_ref = prev;
*head_ref = next;
*head_ref = NULL;
Answer explanation
*head_ref = prev; At the end of while loop, the prev pointer points to the last node of original linked list.
We need to change *head_ref so that the head pointer now starts pointing to the last node.
2.
MULTIPLE CHOICE QUESTION
30 sec • 1 pt
What does the following function do for a given Linked List with first node as head?
Prints all nodes of linked lists
Prints alternate nodes of Linked List
Prints all nodes of linked list in reverse order
Prints alternate nodes in reverse order
Answer explanation
fun1() prints the given Linked List in reverse manner.
3.
MULTIPLE CHOICE QUESTION
30 sec • 1 pt
How many pointers will be required to perform reversal in linked list?
2
3
1
4
Answer explanation
The idea is to use three pointers curr, prev, and next to keep track of nodes to update reverse links.
4.
MULTIPLE CHOICE QUESTION
30 sec • 1 pt
1. Initialize three pointers prev as NULL, curr as head, and next as NULL.
2. Iterate through the linked list. In a loop, do the following:
3. Before changing the next of curr, store the next node
next = curr -> next
4. Now update the next pointer of curr to the prev
curr -> next = prev
5. Update prev as curr and curr as next
Complete the step 5 with proper code snippet
-------
-------
prev = curr
curr = next
prev=next
curr=prev
curr=next
prev=next
curr = next
prev = curr
Answer explanation
prev = curr ;curr = next completes the linked list reversal
5.
MULTIPLE CHOICE QUESTION
30 sec • 1 pt
What is the time complexity to perform reversal operation in linked list?
O(1)
O(n)
O(logn)
O(n logn)
Answer explanation
It takes time complexity of O(n) to perform linked list reversal.
6.
MULTIPLE CHOICE QUESTION
30 sec • 1 pt
While reversing a linked list we initialize the pointer prev,curr,next as
NULL,head,NULL
NULL,NULL,head
NULL,NULL,NULL
head,head,NULL
Answer explanation
Initialize three pointers prev as NULL, curr as head, and next as NULL.
7.
MULTIPLE CHOICE QUESTION
30 sec • 1 pt
Which of the following statement is false with respect to reversing a linked list?
The loop statement while(curr!=NULL) helps in traversing the entire list inorder to reverse the list
Before changing the next of curr, store the next node as next = curr -> next
prev=current keeps prev pointer moving ahead of next pointer
None of the above
Answer explanation
Update prev as curr and curr as next so that prev ->curr->next order is maintained
Create a free account and access millions of resources
Similar Resources on Wayground
15 questions
Data Structures and Algorithms Quiz

Quiz
•
Professional Development
10 questions
Java Collections

Quiz
•
Professional Development
10 questions
Port Scanning

Quiz
•
Professional Development
11 questions
Javascript Function Quiz

Quiz
•
Professional Development
15 questions
Queues

Quiz
•
11th Grade - Professi...
14 questions
SELECT - Clausula WHERE y Operadores

Quiz
•
Professional Development
14 questions
Preguntas de JavaScript

Quiz
•
Professional Development
11 questions
JavaScript

Quiz
•
Professional Development
Popular Resources on Wayground
10 questions
Video Games

Quiz
•
6th - 12th Grade
20 questions
Brand Labels

Quiz
•
5th - 12th Grade
15 questions
Core 4 of Customer Service - Student Edition

Quiz
•
6th - 8th Grade
15 questions
What is Bullying?- Bullying Lesson Series 6-12

Lesson
•
11th Grade
25 questions
Multiplication Facts

Quiz
•
5th Grade
15 questions
Subtracting Integers

Quiz
•
7th Grade
22 questions
Adding Integers

Quiz
•
6th Grade
10 questions
Exploring Digital Citizenship Essentials

Interactive video
•
6th - 10th Grade