mirror of
https://github.moeyy.xyz/https://github.com/trekhleb/javascript-algorithms.git
synced 2024-11-10 11:09:43 +08:00
Update README.zh-CN.md (#804)
* Update README.zh-CN.md 双向链表的删除部分,逻辑修改 * Update README.zh-CN.md
This commit is contained in:
parent
9671b0c4b9
commit
e844a2f894
@ -19,7 +19,7 @@ Add(value)
|
|||||||
Pre: value is the value to add to the list
|
Pre: value is the value to add to the list
|
||||||
Post: value has been placed at the tail of the list
|
Post: value has been placed at the tail of the list
|
||||||
n ← node(value)
|
n ← node(value)
|
||||||
if head = ø
|
if head != ø
|
||||||
head ← n
|
head ← n
|
||||||
tail ← n
|
tail ← n
|
||||||
else
|
else
|
||||||
@ -51,14 +51,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
|
||||||
@ -74,7 +74,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
|
||||||
|
Loading…
Reference in New Issue
Block a user