Files
beyond-interviews/analysis/04-reverse-linked-list/diagrams/02_reverse_current_link.puml

39 lines
557 B
Plaintext

@startuml
title Step 2 — Reverse current->next
object "Node 1" as n1 {
value = 1
}
object "Node 2" as n2 {
value = 2
}
object "Node 3" as n3 {
value = 3
}
n1 --> "null" : next
n2 --> n3 : next
n3 --> "null" : next
object "previous" as prev
object "current" as cur
object "next" as nxt
prev --> "null"
cur --> n1
nxt --> n2
note right of n1
current->next = previous
Node 1 no longer points to Node 2.
It now points to the already reversed part.
At the first iteration, the reversed part is empty,
so Node 1 points to null.
end note
@enduml