Tuesday, April 2, 2013

Link List Algorithm Questions


  1. write a code to remove duplicates from unsorted link list. How would you solve it if temp buffer is not given.
  2. write algo to find nth to last element of singly link list.
  3. implement the algorithm to delete a node in the middle of a singly link list given only access to that node.
  4. write a algo to partition a linked list around a value such that all nodes less than x come before it and all nodes with value greater than x comes after it.
  5. suppose number are represented by singly linked list in reverse order. Eg . 123 is represented as       3->2->1. Write a function which could add these numbers and represent in link list.
  6. suppose number are represented by singly linked list in same order. Eg . 123 is represented as          1->2->3. Write a function which could add these numbers and represent in link list.
  7. Detect the loop in the link list. Also detect the loop node. Eg . a->b->c->d->e->b.   E is pointing to b so there is loop in link list.
  8. Implement a method to check if link list is palindrome.

No comments: