Reverse Array:
- Array elements can process using index.
- We access locations in both the directions(forward and backward)
- Hence we can easily reverse an array using loop.

Reverse list: Double linked list:
- Double linked list can reverse easily like array.
- Single linked list is bi-directional.
- The program as follows:
void reverse() { int i, j, n, temp ; struct node *p, *q; n=length(); i=0; j=n-1; p=root; q=root; while(q->right) { q=q->right; } while(i<j) { temp=p->data; p->data=q->data; q->data=temp; p=p->right; q=q->left; ++i; –j; } } |