AceTheInterview
Jobs in Pune | Work better in teams | Socialize with friends | Submit Q&A | Tell a friend
Search site for 

Top 100 Interview Questions & Answers in a convenient and easy to read book!

“I bought this guide a few days ago to prepare for my interview with Oracle. Many of the questions they asked me were from this guide. I found this book absolutely great!”

– Ravi, California

Read more comments...

Interview Questions And Answers RSS Feed

Answers »

  1. Submitted By: diab — April 5, 2008
    +2 votes
      + -

    In this case, bubble sort is an obvious way to do it.
    Swapping two (adjacents in this case) elemnts in the linked list shoud not be difficult.

    Comments: O(n*2) running time in the worst case.
    ** No extra memory required.

  2. Submitted By: christan — July 20, 2008
    +1 votes
      + -

    /* Based on insertion sort */
    Node *sort(Node *head)
    {
    Node *i, *j, *previ;

    if (!head) return NULL;

    i = head->next;
    previ = head;

    while (i) {
    if (i->val val) {
    previ->next = i->next;
    i->next = head;
    head = i;

    } else {
    j = head;
    while (j->next != i && j->next->val val) {
    j = j->next;
    }

    if (j->next != i) {
    previ->next = i->next;
    i->next = j->next;
    j->next = i;
    } else {
    previ = previ->next;
    }
    }

    i = previ->next;
    }

    return head;
    }

  3. Leave an Answer/Comment

    To prove you're a person (not a spam script), type the security text shown in the picture. Click here to regenerate some new text.
    Click to hear an audio file of the anti-spam word

Our Sponsors
Our Sponsors
Contact Us | FAQ | Sitemap | Terms of Use | Privacy Policy | Tell a Friend

Copyright © 1999-2006 Jeeve Technologies LLC. All rights reserved.