ALLInterview.com :: Home Page KalAajKal.com
 Advertise your Business Here     
Browse  |   Placement Papers  |   Company  |   Code Snippets  |   Certifications  |   Visa Questions
Post Question  |   Post Answer  |   My Panel  |   Search  |   Articles  |   Topics  |   ERRORS new
   Refer this Site  Refer This Site to Your Friends  Site Map  Bookmark this Site  Set it as your HomePage   interview questions urls   External Links  Contact Us     Login  |  Sign Up                      
info       Did you received any Funny E-Mails from your Friends and like to share with rest of our friends? Yeah!! you can post that stuff   HERE
Google
 
Categories  >>  Code Snippets  >>  Programming Code  >>  C Code
 
 


 

 
 C Code interview questions  C Code Interview Questions
 C++ Code interview questions  C++ Code Interview Questions
 VC++ Code interview questions  VC++ Code Interview Questions
 Java Code interview questions  Java Code Interview Questions
 Dot Net Code interview questions  Dot Net Code Interview Questions
 Visual Basic Code interview questions  Visual Basic Code Interview Questions
 Programming Code AllOther interview questions  Programming Code AllOther Interview Questions
Question
How do you sort a Linked List (singly connected) in O(n)
please mail to pawan.10k@gmail.com if u can find an
anser...i m desperate to knw...
 Question Submitted By :: Pawan
I also faced this Question!!     Rank Answer Posted By  
 
  Re: How do you sort a Linked List (singly connected) in O(n) please mail to pawan.10k@gmail.com if u can find an anser...i m desperate to knw...
Answer
# 1
singly linked lists can be sorted in minimum of O(n2) [n
square] time.
 
Is This Answer Correct ?    0 Yes 1 No
Abc
 
  Re: How do you sort a Linked List (singly connected) in O(n) please mail to pawan.10k@gmail.com if u can find an anser...i m desperate to knw...
Answer
# 2
Counting sort is a solution. Kormen 's book will help you.
 
Is This Answer Correct ?    1 Yes 0 No
Alexht
 
 
 
  Re: How do you sort a Linked List (singly connected) in O(n) please mail to pawan.10k@gmail.com if u can find an anser...i m desperate to knw...
Answer
# 3
struct NODE
{
int nodevalue;
struct NODE *next;
}
struct NODE *uslist, *slist;
struct NODE *cur_us, *cur_s; /*pointers to surf the lists*/
main()
{
..
/*uslist and slist have been initialised here*/
/*uslist holds the list to be sorted*/
/*slist is initially empty as nothing is sorted*/
..
..
LLsort();
}

LLsort ( )
{
int delval; 
struct NODE *temp;

slist->nodevalue = 0; /*sorted list will have 0 as its first
element initially*/
slist->next = NULL;
cur_us = uslist;

while( cur_us != NULL)
{
  cur_s = slist;  
 while(cur_s != NULL)
  {
   if(cur_us->nodevalue < cur_s->nodevalue)    /*step-1 of
the algo.*/
   {
    target = cur_s;    /*step-2: make cur_s as your TARGET*/
    delval = delnode(cur_us); /*deletion has to be done to
the UNSORTED list*/
    addnode(delval, target);  /*remember addition has to be
done to the SORTED list*/
   }
   else
     if(cur_s->next == NULL)   /*step-3:if cur_s is the last
element in the sorted list*/
       {
        delval = delnode(cur_us);
        temp_us = (struct NODE *)malloc(sizeof(NODE));   
        temp_us ->nodevalue = delval;
        cur_s->next = temp_us;   /*step-3:append the
unsorted element to the sorted list*/
        temp_us->next = NULL;
       }
   cur_s = cur_s->next;  
  }
cur_us = cur_us->next;
}
}
 
Is This Answer Correct ?    2 Yes 3 No
Ajaay
 

 
 
 
Other C Code Interview Questions
 
  Question Asked @ Answers
 
How we will connect multiple client ? (without using fork,thread) TelDNA2
Write a routine to draw a circle (x ** 2 + y ** 2 = r ** 2) without making use of any floating point computations at all. Microsoft2
Given an array of characters which form a sentence of words, give an efficient algorithm to reverse the order of the words (not characters) in it. Microsoft4
Given an array of size N in which every number is between 1 and N, determine if there are any duplicates in it. You are allowed to destroy the array if you like. Microsoft8
Write a C function to search a number in the given list of numbers. donot use printf and scanf Honeywell4
Write out a function that prints out all the permutations of a string. For example, abc would give you abc, acb, bac, bca, cab, cba. You can assume that all the characters will be unique. Microsoft3
To Write a C program to remove the repeated characters in the entered expression or in entered characters(i.e) removing duplicates. Synergy2
plz send me all data structure related programs  1
How can u say that a given point is in a triangle? 1. with the co-ordinates of the 3 vertices specified. 2. with only the co-ordinates of the top vertex given.  1
Finding a number multiplication of 8 with out using arithmetic operator NetApp7
program to find the roots of a quadratic equation  1
Find your day from your DOB? Microsoft11
How to swap two variables, without using third variable ? HCL26
Give a oneline C expression to test whether a number is a power of 2? Motorola9
What is the main difference between STRUCTURE and UNION?  3
Link list in reverse order. NetApp7
Given n nodes. Find the number of different structural binary trees that can be formed using the nodes. Aricent3
Given a list of numbers ( fixed list) Now given any other list, how can you efficiently find out if there is any element in the second list that is an element of the first list (fixed list) Disney2
How to read a directory in a C program?  3
How will u find whether a linked list has a loop or not? Microsoft3
 
For more C Code Interview Questions Click Here 
 
 
 
 
 
   
Copyright Policy  |  Terms of Service  |  Help  |  Site Map 1  |  Articles  |  Site Map  |   Site Map  |  Contact Us
   
Copyright © 2007  ALLInterview.com.  All Rights Reserved.

ALLInterview.com   ::  Forum9.com   ::  KalAajKal.com