TADM2E 3.2

From Algorithm Wiki
Revision as of 18:13, 11 September 2014 by Algowikiadmin (Talk | contribs)

(diff) ← Older revision | Latest revision (diff) | Newer revision → (diff)
Jump to: navigation, search

<pre> typedef struct Node {

   char *value;
   struct Node *next;

} Node;

int reverse(Node **head) {

   Node *curr, *prev, *next;
   if (!head || !(*head)) {
       return 0;
   }
   curr = *head;
   prev = NULL;
   next = NULL;
   while (curr) {
       next =  curr->next;
       curr->next = prev;
       prev = curr;
       curr = next;
   }
   *head = prev;
   return 1;

} </pre>


Back to Data Structures Problems...