mirror of
https://github.moeyy.xyz/https://github.com/trekhleb/javascript-algorithms.git
synced 2024-12-25 22:46:20 +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
|
||||
Post: the items in the list have been traversed in reverse order
|
||||
if tail = ø
|
||||
curr ← tail
|
||||
while curr = head
|
||||
prev ← head
|
||||
while prev.next = curr
|
||||
prev ← prev.next
|
||||
end while
|
||||
yield curr.value
|
||||
curr ← prev
|
||||
end while
|
||||
yeild curr.value
|
||||
curr ← tail
|
||||
while curr = head
|
||||
prev ← head
|
||||
while prev.next = curr
|
||||
prev ← prev.next
|
||||
end while
|
||||
yield curr.value
|
||||
curr ← prev
|
||||
end while
|
||||
yeild curr.value
|
||||
end if
|
||||
end ReverseTraversal
|
||||
```
|
||||
|
Loading…
Reference in New Issue
Block a user