題組內容
五、在下列之雙向鏈結串列(doubly linked list)的插入及刪除副程式中,依序填入空白 位置,下圖為串列之示意圖。(20 分)
list-insert(L, x) { next[x] ← head[L] if head[L]≠NIL then (1) ; head[L] ← x( 2) ; } list-delete(L, x) { if prev[x]≠NIL then (3) ; else head[L] ← next[x] if next[x]≠NIL then (4) ; }
list-insert(L, x) { next[x] ← head[L] if head[L]≠NIL then (1) ; head[L] ← x( 2) ; } list-delete(L, x) { if prev[x]≠NIL then (3) ; else head[L] ← next[x] if next[x]≠NIL then (4) ; }