24.9 DYNAMIC DATA STRUCTURES

Many ADTs like list, stack and queue are popular. One can develop these classes using basic dynamic data structure like linked list.

class Node

    { public:      int key;      Node * next;      Node(int n) ; //for key  };

class LinkList

    { private :      Node *root ;    public :      LinkList();      void addNode(int M);      void show();  };

class LinkList2 : public LinkList

    { private :      Node *ptr ;    public:      LinkList2();      int findNum( int N ); // 1 found - 0 not found      void insert_after(int M);  };

class Stack : public LinkList

    { public :      void pop(int & item);      void push( int item);  } ;

The following definition of class Node is for binary Tree.

class Node

    { public:      str40 ...

Get Object Oriented Programming with C++, Second Edition now with the O’Reilly learning platform.

O’Reilly members experience books, live events, courses curated by job role, and more from O’Reilly and nearly 200 top publishers.