13.07.2015 Views

Linked List Problems

Linked List Problems

Linked List Problems

SHOW MORE
SHOW LESS

Create successful ePaper yourself

Turn your PDF publications into a flip-book with our unique Google optimized e-Paper software.

1818 — RecursiveReverse()(This problem is difficult and is only possible if you are familiar with recursion.) Thesolution is short and amazing. As before, the code should only make a single pass overthe list. Solving it, or even appreciating how it works requires real understanding ofpointer code and recursion.(Although the code for RecursiveReverse() is quite nice, there is another complex linkedlist recursion algorithm which is the most beautfiul of all — the O(n) conversion of anordered binary tree to a sorted doubly linked circular list. That algorithm may get its ownCS Education Library document someday.)/*Recursively reverses the given linked list by changing its .nextpointers and its head pointer. Takes a pointer (reference) to thehead pointer.*/void RecursiveReverse(struct node** headRef) {// your code...

Hooray! Your file is uploaded and ready to be published.

Saved successfully!

Ooh no, something went wrong!