
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
8 questions
L07: Null Object Pattern

Quiz
•
Professional Development
12 questions
Estructura de datos II

Quiz
•
Professional Development
12 questions
Variable, DataType and Operators

Quiz
•
Professional Development
9 questions
MS Registry

Quiz
•
Professional Development
9 questions
SQL - Consultas sin JOIN

Quiz
•
Professional Development
15 questions
Geral - Google GenAI

Quiz
•
Professional Development
10 questions
SQL Programming

Quiz
•
4th Grade - Professio...
13 questions
Strings and Arrays

Quiz
•
Professional Development
Popular Resources on Wayground
10 questions
Lab Safety Procedures and Guidelines

Interactive video
•
6th - 10th Grade
10 questions
Nouns, nouns, nouns

Quiz
•
3rd Grade
10 questions
9/11 Experience and Reflections

Interactive video
•
10th - 12th Grade
25 questions
Multiplication Facts

Quiz
•
5th Grade
11 questions
All about me

Quiz
•
Professional Development
22 questions
Adding Integers

Quiz
•
6th Grade
15 questions
Subtracting Integers

Quiz
•
7th Grade
9 questions
Tips & Tricks

Lesson
•
6th - 8th Grade
Discover more resources for Computers
11 questions
All about me

Quiz
•
Professional Development
10 questions
How to Email your Teacher

Quiz
•
Professional Development
15 questions
Fun Random Trivia

Quiz
•
Professional Development
22 questions
Anne Bradstreet 1612-1672

Quiz
•
Professional Development
18 questions
Spanish Speaking Countries and Capitals

Quiz
•
KG - Professional Dev...
14 questions
Fall Trivia

Quiz
•
11th Grade - Professi...
15 questions
Disney Characters Quiz

Quiz
•
Professional Development
15 questions
Quiz to Highlight Q types & other great features in Wayground

Quiz
•
Professional Development