Linked Lists

C++ program to implement stack using Linked List

C++ program to implement stack using Linked List

#include <iostream.h> template<class T> class Node { friend LinkedStack<T>; private: T data; Node<T> *link; }; template<class T> class LinkedStack { public: LinkedStack() {top = 0;} ~LinkedStack(); int IsEmpty() const {return top == 0;} T Top() const; LinkedStack<T>& Add(const T& x); LinkedStack<T>& Delete(T& x); private: Node<T> *top; }; template<class T> LinkedStack<T>::~LinkedStack() {// Stack destructor.. Node<T> *next; […]

Share on FacebookTweet about this on TwitterDigg thisPin on PinterestShare on LinkedInShare on StumbleUponShare on TumblrShare on Google+Email this to someone

C++ program to implement Stack using Formula Based Representation

C++ program to implement Stack using Formula Based Representation

#include<iostream.h> #include<constream.h> template<class T> class Stack { public: Stack(int MaxStackSize); ~Stack(){delete[] S;} int IsEmpty()const{return top==-1;} int IsFull()const{return top==MaxTop;} T Peek()const; void Push(T); T Pop(); void Display(); private: int top; //current top of stack int MaxTop; //max val for top T *S; //element array }; template<class T> Stack<T>::Stack(int MaxStackSize) { //stack constructor MaxTop=MaxStackSize-1; S=new T[MaxStackSize]; top=-1; […]

Share on FacebookTweet about this on TwitterDigg thisPin on PinterestShare on LinkedInShare on StumbleUponShare on TumblrShare on Google+Email this to someone

C++ program to multiply two polynomials maintained as linked lists

C++ program to multiply two polynomials maintained as linked lists

#include <iostream.h> class poly { private : struct polynode { float coeff ; int exp ; polynode *link ; } *p ; public : poly( ) ; void poly_append ( float c, int e ) ; void display_poly( ) ; void poly_multiply ( poly &p1, poly &p2 ) ; void padd ( float c, int […]

Share on FacebookTweet about this on TwitterDigg thisPin on PinterestShare on LinkedInShare on StumbleUponShare on TumblrShare on Google+Email this to someone

C++ program to add two polynomials maintained using Linked Lists

C++ program to add two polynomials maintained using Linked Lists

#include <iostream.h> class poly { private : struct polynode { float coeff ; int exp ; polynode *link ; } *p ; public : poly( ) ; void poly_append ( float c, int e ) ; void display_poly( ) ; void poly_add( poly &l1, poly &l2 ) ; ~poly( ) ; } ; poly :: […]

Share on FacebookTweet about this on TwitterDigg thisPin on PinterestShare on LinkedInShare on StumbleUponShare on TumblrShare on Google+Email this to someone