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 function that takes in a number n and divides the screen into n vertical bars, alternating black and white. (What should you do if someone puts in n=0 or n=-99?)

Cross Platform Clinet app for a vpn Project Description: We want a cross platform client app for VPN. The app must have the subsequent options below: 1. Must be an open


Pointer Arithmetic We can manipulate the pointers too. We can perform operations such as addition, subtraction, increment and decrement etc.,. As the pointer variables have add

How much does it cost to complete a C++ assignment that is 80% finished??

WAP TO PRINT ANY NAME ON SCREEN 10 TIMES void main () { int a=1; clrscr(); do { printf ("expertsmind\n"); a++; } while (a getch (); }


array of class objects and single inheritance

n this problem u given a board in which some of the elements are placed as shown in diagram below .each element represent a color .fill the other elements in the board such that no

Write a program called A1Q3, that reads it the radius of a circle as an integer and prints the circle's diameter, circumference and area.  Use a constant value for pi.  Do all calc