Saved Bookmarks
| 1. |
Give an algorithm for a singly linked list, which reverses the direction of the links. |
|
Answer» The algorithm to reverse the direction of a singly link list is as follows: reverse (struct node **st) { struct node *p, *q, *r; p = *st; q = NULL; while (p != NULL) { r =q; q = p; p = p → link; q → link = r; } *st = q; } |
|