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
though the ascii is called 7-bit code. why do we use 8-bits to represent a character?

who to write max if statements in a program


convert lower case to uper case

Write a program that counts from 0 to 99 and prints these numbers to the terminal ie it prints 00, 01, 02, 03, 04, 05, ....,99. Graphics 1. Write a program in rPeANUt that

Automatic Variables Automatic variables are variable which are explained within the functions. They lose their value when the function terminates. It can be accessed only in th

Write a program that predicts users’ age (0-128 years old) with at most 7 questions. The game starts with asking the user whether he/she is younger or older than G (an initial gues

Simpson's Rule is a more accurate method of numerical integration than the method described in class. Using Simpson's Rule, the integral of a function f between a and b is approxim

Within programs we very often want to execute a different section of code, depending upon various conditions within C the If statement is used to achieve this. The If statement con

Write a function that takes an array as the argument and returns the second largest element. Bonus (+5): Write a function that takes an array and a number n as arguments and return