Files
beyond-interviews/analysis/04-reverse-linked-list/exapmle/reverse-linked-list/README.md

459 B

Reverse Linked List Example

This directory contains a small standalone C++ example for the classic three-pointer linked list reversal algorithm.

Build

g++ -std=c++17 -Wall -Wextra -pedantic main.cpp -o reverse_linked_list

Run

./reverse_linked_list

Expected Output

Original list:
1 -> 2 -> 3 -> 4 -> 5 -> null

Reversed list:
5 -> 4 -> 3 -> 2 -> 1 -> null

Memory walkthrough

see memory_walkthrough.md