資料結構›Ch4 鏈結串列第 18 題/共 22 題
18. Doubly Linked List
#DS-04-018易Doubly Linked List
Consider the following function that takes reference to head of a Doubly Linked List as parameter. Assume that a node of doubly linked list has previous pointer as prev and next pointer as next.
void fun(struct node **head_ref)
{
struct node *temp = NULL;
struct node *current = *head_ref;
while (current != NULL)
{
temp = current->prev;
current->prev = current->next;
current->next = temp;
current = current->prev;
}
if(temp != NULL )
*head_ref = temp->prev;
}
Assume that reference of head of a doubly linked list L is passed to above function. What is the resulting linked list after the function call?
📄 中央113
▤完整推導請見《WH 資工筆記 · 資料結構》Ch4 鏈結串列