Challenge - 5 Problems
Node Structure Mastery
Get all challenges correct to earn this badge!
Test your skills under time pressure!
❓ Predict Output
intermediateOutput of a singly linked list after insertions
What is the printed state of the singly linked list after inserting nodes with values 10, 20, and 30 in that order?
DSA Typescript
class Node { value: number; next: Node | null; constructor(value: number) { this.value = value; this.next = null; } } class SinglyLinkedList { head: Node | null = null; insert(value: number) { const newNode = new Node(value); if (!this.head) { this.head = newNode; } else { let current = this.head; while (current.next) { current = current.next; } current.next = newNode; } } printList() { let current = this.head; let result = ''; while (current) { result += current.value + ' -> '; current = current.next; } result += 'null'; console.log(result); } } const list = new SinglyLinkedList(); list.insert(10); list.insert(20); list.insert(30); list.printList();
Attempts:
2 left
💡 Hint
Remember that insertion adds nodes at the end of the list.
✗ Incorrect
Nodes are inserted at the end, so the list prints in the order 10, 20, 30 followed by null.
❓ Predict Output
intermediateOutput of doubly linked list after forward and backward traversal
Given a doubly linked list with nodes 1, 2, 3 inserted in order, what is the output of forward and backward traversal?
DSA Typescript
class DNode { value: number; next: DNode | null; prev: DNode | null; constructor(value: number) { this.value = value; this.next = null; this.prev = null; } } class DoublyLinkedList { head: DNode | null = null; tail: DNode | null = null; insert(value: number) { const newNode = new DNode(value); if (!this.head) { this.head = newNode; this.tail = newNode; } else { this.tail!.next = newNode; newNode.prev = this.tail; this.tail = newNode; } } printForward() { let current = this.head; let result = ''; while (current) { result += current.value + ' -> '; current = current.next; } result += 'null'; console.log(result); } printBackward() { let current = this.tail; let result = ''; while (current) { result += current.value + ' -> '; current = current.prev; } result += 'null'; console.log(result); } } const dlist = new DoublyLinkedList(); dlist.insert(1); dlist.insert(2); dlist.insert(3); dlist.printForward(); dlist.printBackward();
Attempts:
2 left
💡 Hint
Forward traversal starts at head, backward at tail.
✗ Incorrect
Insertion adds nodes at tail, so forward prints 1 to 3, backward prints 3 to 1.
🔧 Debug
advancedIdentify the error in circular linked list insertion
What error occurs when running this circular linked list insertion code?
DSA Typescript
class CNode { value: number; next: CNode | null; constructor(value: number) { this.value = value; this.next = null; } } class CircularLinkedList { head: CNode | null = null; insert(value: number) { const newNode = new CNode(value); if (!this.head) { this.head = newNode; newNode.next = this.head; } else { let current = this.head; while (current.next !== this.head) { current = current.next!; } current.next = newNode; newNode.next = this.head; } } printList() { if (!this.head) { console.log('null'); return; } let current = this.head; let result = ''; do { result += current.value + ' -> '; current = current.next!; } while (current !== this.head); result += '(head)'; console.log(result); } } const clist = new CircularLinkedList(); clist.insert(5); clist.insert(10); clist.insert(15); clist.printList();
Attempts:
2 left
💡 Hint
Check how the loop in printList stops.
✗ Incorrect
The do-while loop stops when current returns to head, so no infinite loop occurs.
❓ Predict Output
advancedOutput after reversing a singly linked list
What is the printed state of the singly linked list after reversing it? Initial list: 1 -> 2 -> 3 -> null
DSA Typescript
class Node { value: number; next: Node | null; constructor(value: number) { this.value = value; this.next = null; } } class SinglyLinkedList { head: Node | null = null; insert(value: number) { const newNode = new Node(value); if (!this.head) { this.head = newNode; } else { let current = this.head; while (current.next) { current = current.next; } current.next = newNode; } } reverse() { let prev: Node | null = null; let current = this.head; while (current) { const nextTemp = current.next; current.next = prev; prev = current; current = nextTemp; } this.head = prev; } printList() { let current = this.head; let result = ''; while (current) { result += current.value + ' -> '; current = current.next; } result += 'null'; console.log(result); } } const list = new SinglyLinkedList(); list.insert(1); list.insert(2); list.insert(3); list.reverse(); list.printList();
Attempts:
2 left
💡 Hint
Reversing changes the direction of next pointers.
✗ Incorrect
After reversal, the list order is reversed: 3 -> 2 -> 1 -> null.
🧠 Conceptual
expertPointer design in a skip list node
In a skip list node structure, which pointer design best supports efficient multi-level traversal?
Attempts:
2 left
💡 Hint
Skip lists use multiple levels to skip nodes efficiently.
✗ Incorrect
Skip list nodes have multiple forward pointers to nodes at different levels, enabling fast traversal.
