Thursday, March 8, 2012

Technical Interview Questions - Linked List


1. Implement enqueue and dequeue operations using stack(s).
2. Sort a link list using merge sort.
3. You are given two numbers in the form of linked list.Add them without reversing the linked lists. linked lists can be of any length.
4. Randomly select an element from a linked list. The length of linked list is unknown.
5. Reverse a linked list, recursion or non-recursion.
6. Given a circular linked list where the length of the stem can be arbitrary (the shape of the list can be like number 6). What is the size of the list? Or determine if a linked list has a loop.
7. How would you find the nth to last element in a linked list?
Use two pointers. Initalize both pointers to the front of the list then use a loop to traverse one pointer Nth times. Then moves both pointers until one reaches the end of the list. The second pointer is Nth to last element.

1 comment:

  1. These are great questions! I especially love question #3 & #4!

    I recently launched a service that emails you a new technical interview question every other day. I think you and your reader might be interested in it. I thought I'd share it with you and would love to get your expert feedback! Here's the site with more info: InterTechTion - Technical Interview Questions

    ReplyDelete