Implement a algorithm to verify if the link list , C/C++ Programming

Implement a Algorithm to verify if the link list is in Ascending order?

A: template

bool linklist::isAscending() const{

nodeptr ptr = head;

while (ptr->_next)         

{

if(ptr->_data > ptr->_next->_data)

return false;

ptr= ptr->_next;

}

return true;

}

Q: Write down an algorithm to reverse a link list?

A: template

void linklist::reverselist()

{

nodeptr ptr= head;

nodeptr nextptr= ptr->_next;

while(nextptr)

{

nodeptr temp = nextptr->_next;

nextptr->_next = ptr;

ptr = nextptr;

nextptr = temp;

}

head->_next = 0;

head = ptr;

}

Posted Date: 3/20/2013 3:52:36 AM | Location : United States







Related Discussions:- Implement a algorithm to verify if the link list , Assignment Help, Ask Question on Implement a algorithm to verify if the link list , Get Answer, Expert's Help, Implement a algorithm to verify if the link list Discussions

Write discussion on Implement a algorithm to verify if the link list
Your posts are moderated
Related Questions
write a program to find the area under the curve y=f(x) between x=a & x=b

#include stdio.h   struct  complex   {   float real;   float imag;   };   struct complex complexadd(struct complex,struct  complex);   void main()     {          Date: 26

Based on the automobile's model year and weight, the city of Cebu determines the car's weight class and registration fee using the following schedule: Model Year Registration

A: no, can't. The names of, precedence of, associativity of, and arity of operators is fixed through the language. In C++, there is no operator** so you cannot create one for a

recsection method source code for searching position

Memory management by c program: Write a program to memory management in c program unsigned max( unsigned, unsigned );   int BaseMemBlocks::allocBlock( size_t sz )

give an example of function

write short notes about void pointers

Project Description: I have a barber salon I am seeking someone to build me software for my PARTNER PT6910 touch screen till system. This software must add multiple staff login

In this assignment you are required to develop a program that allows the creation, viewing and storage of information about ITECH7603 Students. In order to complete the task you ha