What should be added in place of “/*ADD A STATEMENT HERE*/”, so that the function correctly reverses a linked list.

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
*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 Quizizz
10 questions
Linked List Traversal

Quiz
•
Professional Development
10 questions
Diagnóstico Node.js

Quiz
•
Professional Development
10 questions
Fundamentos PL/SQL

Quiz
•
Professional Development
13 questions
DSA 2

Quiz
•
Professional Development
10 questions
Structure Data Review

Quiz
•
University - Professi...
10 questions
PYTHON VOCABULARY

Quiz
•
Professional Development
15 questions
Social Media Basics for Educators

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

Quiz
•
Professional Development
Popular Resources on Quizizz
15 questions
Character Analysis

Quiz
•
4th Grade
17 questions
Chapter 12 - Doing the Right Thing

Quiz
•
9th - 12th Grade
10 questions
American Flag

Quiz
•
1st - 2nd Grade
20 questions
Reading Comprehension

Quiz
•
5th Grade
30 questions
Linear Inequalities

Quiz
•
9th - 12th Grade
20 questions
Types of Credit

Quiz
•
9th - 12th Grade
18 questions
Full S.T.E.A.M. Ahead Summer Academy Pre-Test 24-25

Quiz
•
5th Grade
14 questions
Misplaced and Dangling Modifiers

Quiz
•
6th - 8th Grade