Add pseudocodes to LinkedList.

This commit is contained in:
Oleksii Trekhleb 2018-08-13 10:41:06 +03:00
parent f6c091bcb1
commit 6c9641aa3d

View File

@ -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
``` ```