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
implementation of the power and factorial in programs

how to convert a general tree into binary tree with example

For your class to work properly, you'll need to define appropriate constructors, extract and insert operators, and of course arithmetic operators. (If you wanted to use it as a gen


A palindrome is a string that reads the same from both the ends. Given a string S convert it to a palindrome by doing character replacement. Your task is to convert S to palindrome

A: Mostly can be overloaded. The only C operators which can't be are. and?: (and sizeof, that is technically an operator). C++ adds a few of its own operators, mostly which can be

The #define Directive The #define directive explains a macro which is a text string represented by a name. Whenever the pre-processor finds this name in the program, it is repl

I need help in the C++ programming assignment. I can send the files the assignment is times 3hrs.

Aim: To implement a program for bank account using static data type. Code: class bank {             static int acc_no;             int acc;             float b

Stack operations - C++: Write a program to define basic stack operations in c++. int Stack::push(int elem) {    int m = getmax();    if (top    {       put_