
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
Social Media Basics for Educators

Quiz
•
9th Grade - Professio...
6 questions
Demo1

Quiz
•
Professional Development
10 questions
Linked List Traversal

Quiz
•
Professional Development
10 questions
SQL Select 1

Quiz
•
Professional Development
10 questions
Data Structure

Quiz
•
Professional Development
12 questions
JavaScript Quiz Day-1

Quiz
•
Professional Development
15 questions
SQL Reboot Quiz

Quiz
•
Professional Development
10 questions
Întrebări despre Colecții în Java

Quiz
•
Professional Development
Popular Resources on Wayground
18 questions
Writing Launch Day 1

Lesson
•
3rd Grade
11 questions
Hallway & Bathroom Expectations

Quiz
•
6th - 8th Grade
11 questions
Standard Response Protocol

Quiz
•
6th - 8th Grade
40 questions
Algebra Review Topics

Quiz
•
9th - 12th Grade
4 questions
Exit Ticket 7/29

Quiz
•
8th Grade
10 questions
Lab Safety Procedures and Guidelines

Interactive video
•
6th - 10th Grade
19 questions
Handbook Overview

Lesson
•
9th - 12th Grade
20 questions
Subject-Verb Agreement

Quiz
•
9th Grade