
Linked List Reversal
Authored by Madras Institute of Technology
Computers
Professional Development

AI Actions
Add similar questions
Adjust reading levels
Convert to real-world scenario
Translate activity
More...
Content View
Student View
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
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?
Similar Resources on Wayground
15 questions
Website Practical Assessment
Quiz
•
Professional Development
10 questions
AIDE Launch Quizzit!
Quiz
•
Professional Development
12 questions
JavaScript Quiz Day-1
Quiz
•
Professional Development
11 questions
ChatGPT Quiz
Quiz
•
Professional Development
10 questions
SQL Select 1
Quiz
•
Professional Development
15 questions
Data Science / AI
Quiz
•
Professional Development
13 questions
Examen 2
Quiz
•
Professional Development
12 questions
Python Collections Quiz
Quiz
•
Professional Development
Popular Resources on Wayground
15 questions
Fractions on a Number Line
Quiz
•
3rd Grade
20 questions
Equivalent Fractions
Quiz
•
3rd Grade
25 questions
Multiplication Facts
Quiz
•
5th Grade
54 questions
Analyzing Line Graphs & Tables
Quiz
•
4th Grade
22 questions
fractions
Quiz
•
3rd Grade
20 questions
Main Idea and Details
Quiz
•
5th Grade
20 questions
Context Clues
Quiz
•
6th Grade
15 questions
Equivalent Fractions
Quiz
•
4th Grade
Discover more resources for Computers
20 questions
Black History Month Trivia Game #1
Quiz
•
Professional Development
100 questions
Screening Test Customer Service
Quiz
•
Professional Development
20 questions
90s Cartoons
Quiz
•
Professional Development
10 questions
Reading a ruler in Inches
Quiz
•
4th Grade - Professio...
16 questions
Parallel, Perpendicular, and Intersecting Lines
Quiz
•
KG - Professional Dev...
12 questions
Valentines Day Trivia
Quiz
•
Professional Development