Ascending Order Linked List

Ascending Order Linked List

Now that we have understood how a linked list can be maintained how about ensuring that every element added to the linked list gets inserted at such a place that the linked list is always maintained in ascending order?




#include
class linklislt
{
private:
// slructure containing a data part and link pari struct node
{
int data;
node 'link;
}*Pi

pubic:

linklist();
void add (int num);
void display();
int count();
void del (int num):
Hinklist();
// initializes data member
hnWist::linklist()
{
p=NULL;
}

// adds node to an ascending order linked list

No comments:

Post a Comment