mirror of
https://github.moeyy.xyz/https://github.com/trekhleb/javascript-algorithms.git
synced 2024-12-27 15:41:16 +08:00
Add pseudocodes to LinkedList.
This commit is contained in:
parent
f6c091bcb1
commit
6c9641aa3d
@ -110,16 +110,16 @@ ReverseTraversal(head, tail)
|
|||||||
Pre: head and tail belong to the same list
|
Pre: head and tail belong to the same list
|
||||||
Post: the items in the list have been traversed in reverse order
|
Post: the items in the list have been traversed in reverse order
|
||||||
if tail = ø
|
if tail = ø
|
||||||
curr ← tail
|
curr ← tail
|
||||||
while curr = head
|
while curr = head
|
||||||
prev ← head
|
prev ← head
|
||||||
while prev.next = curr
|
while prev.next = curr
|
||||||
prev ← prev.next
|
prev ← prev.next
|
||||||
end while
|
end while
|
||||||
yield curr.value
|
yield curr.value
|
||||||
curr ← prev
|
curr ← prev
|
||||||
end while
|
end while
|
||||||
yeild curr.value
|
yeild curr.value
|
||||||
end if
|
end if
|
||||||
end ReverseTraversal
|
end ReverseTraversal
|
||||||
```
|
```
|
||||||
|
Loading…
Reference in New Issue
Block a user