|
INTERVIEW QUESTIONS
C
STRUCTURES IN C
DETAILS
Question: How do you sort names using circular linked list in c like sorting names after every insertion?
Answer: Have a Circular linked list, initially empty. Keep track of the start of the list node, initially empty. Call this start as head node. Then take the first item to be inserted. Insert in the list. Take the next item. Move thru the list till you find an element >= the item to be inserted. Insert the item before the element in the circular list. Update head node if required. Take the next item, traverse through the list similarly till you find an element >= the item to be inserted. Insert the item before the element in the circular list. Update head node if required. Thus, you would have the list always sorted on every insertion.
|
|
|
Category |
Structures in C Interview Questions & Answers -
Exam Mode /
Learning Mode
|
Rating |
(0.3) By 7760 users |
Added on |
1/20/2013 |
Views |
72966 |
Rate it! |
|
|
Question:
How do you sort names using circular linked list in c like sorting names after every insertion?
Answer:
Have a Circular linked list, initially empty. Keep track of the start of the list node, initially empty. Call this start as head node. Then take the first item to be inserted. Insert in the list. Take the next item. Move thru the list till you find an element >= the item to be inserted. Insert the item before the element in the circular list. Update head node if required. Take the next item, traverse through the list similarly till you find an element >= the item to be inserted. Insert the item before the element in the circular list. Update head node if required. Thus, you would have the list always sorted on every insertion. Source: CoolInterview.com
Answered by: Akhilesh Shirbhate | Date: 2/13/2008
| Contact Akhilesh Shirbhate
If you have the better answer, then send it to us. We will display your answer after the approval.
Rules to Post Answers in CoolInterview.com:-
- There should not be any Spelling Mistakes.
- There should not be any Gramatical Errors.
- Answers must not contain any bad words.
- Answers should not be the repeat of same answer, already approved.
- Answer should be complete in itself.
|
|
Related Questions |
View Answer |
|
What is the difference between structure and union?
|
View Answer
|
|
Can we use functions within a structure?
|
View Answer
|
|
What use of structure and union?
|
View Answer
|
|
How do display the list in single linked list form last to first?
|
View Answer
|
|
What is the stack?
|
View Answer
|
|
What is Preprocessor?
|
View Answer
|
|
How to perform matrix multiplication using Double linked lists?
|
View Answer
|
|
How to convert Stack in to Queue and v varsa ? c with data structure.
|
View Answer
|
|
struct Foo { char *pName; }; main() { struct Foo *obj = malloc(sizeof(struct Foo)); clrscr(); strcpy(obj->pName,"Your Name"); printf("%s", obj->pName); }
|
View Answer
|
|
union u { union u { int i; int j; }a[10]; int b[10]; }u; main() { printf("n%d", sizeof(u)); printf(" %d", sizeof(u.a)); // printf("%d", sizeof(u.a[4].i)); }
|
View Answer
|
|
What is use of macro arguments in c? what is major difference between normal macro definition and macro arguments.
|
View Answer
|
|
How can you calculate number of nodes in a circular Linked List?
|
View Answer
|
|
What is a NULL Macro? What is the difference between a NULL Pointer and a NULL Macro?
|
View Answer
|
|
c program for delete a node from linked list
|
View Answer
|
|
How to break cycle in circular single link list?
|
View Answer
|
|
Whats is structure padding?Say a given structure Struct{ int a; char c; float d; } the size of structure is 7 here. But structure padding is done what will be the size of the struct?Will it change and how?How to avoid this?is it necessary?
|
View Answer
|
|
What is the implicit name of the parameter that gets passed into the class set method?
|
View Answer
|
|
Why cannot you specify the accessibility modifier for methods inside the interface?
|
View Answer
|
|
When is a switch statement better than multiple if statements?
|
View Answer
|
|
What is the easiest sorting method to use?
|
View Answer
|