Implement an algorithm to check if the linked list is in ascending order.
template bool linklist::isAscending() const{
nodeptr ptr = head;
while (ptr->_next)
{
if(ptr->_data > ptr->_next->_data)
return false;
}
ptr=ptr->_next;
return true;
}
template bool linklist::isAscending() const{
nodeptr ptr = head;
while (ptr->_next)
{
if(ptr->_data > ptr->_next->_data)
return false;
}
ptr=ptr->_next;
return true;
}
Comments
Post a Comment
https://gengwg.blogspot.com/