IT Placement Papers Programming DataStructure
This category contains DataStructure Interview Questions and Answers |
|
//sorting in descending order struct node { int value; node* NEXT; } //Assume HEAD pointer denotes the first element in the //linked list // only change the values…don’t have to change the //pointers
Sort( Node *Head) { node* first,second,temp; first= Head; while(first!=null) { second=first->NEXT; while(second!=null) { if(first->value < second->value) { temp = new node(); temp->value=first->value; first->value=second->value; second->value=temp->value; delete temp; } second=second->NEXT; }
first=first->NEXT; } }
Only registered users can write comments. Please login or register.
|