卷別
資料結構
選擇國立中央大學 2026 · 考試 · 第 10 題
考科資料結構
Inserting a node named "new" after a node named "p" in a doubly linked list (assuming p is not the last node), which of the following four lines of code is in the correct order?
1. new->next = p->next;
2. p->next->prev = new;
3. p->next = new;
4. new->prev = p;
- (A)1 -> 3 -> 2 -> 4
- (B)3 -> 4 -> 1 -> 2
- (C)1 -> 2 -> 4 -> 3
- (D)3 -> 1 -> 4 -> 2