Adding inequality conditions (#489)

A quick fix to add inequality conditions wherever needed.

Co-authored-by: Oleksii Trekhleb <trehleb@gmail.com>
This commit is contained in:
Suraj Jadhav
2020-07-26 16:49:28 +05:30
committed by GitHub
parent 63f5a27152
commit 194f2133af

View File

@ -66,14 +66,14 @@ Remove(head, value)
return true return true
end if end if
n ← head.next n ← head.next
while n = ø and value !== n.value while n != ø and value !== n.value
n ← n.next n ← n.next
end while end while
if n = tail if n = tail
tail ← tail.previous tail ← tail.previous
tail.next ← ø tail.next ← ø
return true return true
else if n = ø else if n != ø
n.previous.next ← n.next n.previous.next ← n.next
n.next.previous ← n.previous n.next.previous ← n.previous
return true return true
@ -89,7 +89,7 @@ ReverseTraversal(tail)
Pre: tail is the node of the list to traverse Pre: tail is the node of the list to traverse
Post: the list has been traversed in reverse order Post: the list has been traversed in reverse order
n ← tail n ← tail
while n = ø while n != ø
yield n.value yield n.value
n ← n.previous n ← n.previous
end while end while