Challenge - 5 Problems
Linked List Mastery
Get all challenges correct to earn this badge!
Test your skills under time pressure!
🧠 Conceptual
intermediateKey difference between Circular and Linear Linked Lists
Which statement correctly describes the main difference between a circular linked list and a linear linked list?
Attempts:
2 left
💡 Hint
Think about how the last node connects in each type of linked list.
✗ Incorrect
A circular linked list connects the last node back to the first node, forming a circle. A linear linked list ends with a node pointing to null.
❓ Predict Output
intermediateOutput of traversing a circular linked list
What will be the output of traversing this circular linked list starting from head and printing 5 nodes?
DSA Go
package main import "fmt" type Node struct { value int next *Node } func main() { n1 := &Node{value: 1} n2 := &Node{value: 2} n3 := &Node{value: 3} n1.next = n2 n2.next = n3 n3.next = n1 // circular link current := n1 for i := 0; i < 5; i++ { fmt.Print(current.value, " -> ") current = current.next } fmt.Print("null") }
Attempts:
2 left
💡 Hint
Remember the loop repeats after the last node points back to the first.
✗ Incorrect
The circular linked list loops back after node 3 to node 1. Printing 5 nodes starting from 1 gives: 1, 2, 3, 1, 2.
🔧 Debug
advancedIdentify the bug in linear linked list traversal
What error will this Go code produce when traversing a linear linked list?
DSA Go
package main import "fmt" type Node struct { value int next *Node } func main() { n1 := &Node{value: 1} n2 := &Node{value: 2} n3 := &Node{value: 3} n1.next = n2 n2.next = n3 n3.next = nil current := n1 for current != nil { fmt.Print(current.value, " -> ") current = current.next } fmt.Print("null") }
Attempts:
2 left
💡 Hint
Check how the loop ends when current is nil.
✗ Incorrect
The code correctly traverses the linear linked list until current is nil, then stops. No errors occur.
❓ Predict Output
advancedOutput after inserting node in circular linked list
What is the printed output after inserting a new node with value 4 after node with value 3 in this circular linked list?
DSA Go
package main import "fmt" type Node struct { value int next *Node } func main() { n1 := &Node{value: 1} n2 := &Node{value: 2} n3 := &Node{value: 3} n1.next = n2 n2.next = n3 n3.next = n1 // circular newNode := &Node{value: 4} newNode.next = n3.next n3.next = newNode current := n1 for i := 0; i < 6; i++ { fmt.Print(current.value, " -> ") current = current.next } fmt.Print("null") }
Attempts:
2 left
💡 Hint
Check how the new node links after node 3 and the circular nature.
✗ Incorrect
After insertion, the list is 1 -> 2 -> 3 -> 4 -> back to 1. Printing 6 nodes gives 1,2,3,4,1,2.
🧠 Conceptual
expertMemory usage difference between circular and linear linked lists
Which statement about memory usage difference between circular and linear linked lists is true?
Attempts:
2 left
💡 Hint
Consider what each node stores in both types of lists.
✗ Incorrect
Each node in both lists stores one pointer to the next node. The difference is the last node's next pointer points to null or head, but memory per node is the same.
