C++ program to implement stack using Linked List

Thursday, February 3rd, 2011  »  Posted By  »  Total 1 Comment

#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; […]

C++ program to implement Stack using Formula Based Representation

Thursday, February 3rd, 2011  »  Posted By  »  Total 1 Comment

#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; […]

Program to represent Indirect Addressing of Linear List using Templates

Saturday, January 29th, 2011  »  Posted By  »  Total 0 Comment

IndirectList(int MaxLinearSize=10);
~IndirectList();//destructor
int IsEmpty()const{return length==0;}
int Length()const{return length;}
int Find(int k,T&x)const;
int Search(const T&x)const;
void Delete(int k,T&x);
void Insert(int k,const T&x);
void Output()const;

Program to implement linked representation of Linear list using templates

Friday, January 28th, 2011  »  Posted By  »  Total 0 Comment

#include<iostream.h> #include<constream.h> #include<stdlib.h> template<class T> class ChainNode { friend Chain<T>; private: T data; ChainNode<T>*link; }; template<class T> class Chain { private: ChainNode<T>*first; public: Chain() { first=0; } ~Chain(); int IsEmpty()const; int Length()const; int Find(int k,T&x); int Search(const T&x); void Delete(int k,T&x); void Insert(int k,const T&x); void Output(); }; template<class T> Chain<T>::~Chain() { ChainNode<T>*next; while(first) { […]

Program for Array Based Representation of Linear List using templates

Thursday, January 27th, 2011  »  Posted By  »  Total 0 Comment

LinearList(int MaxLinearSize=10);
~LinearList(){delete[]element;}
int isEmpty()const{return length==0;}
int Length()const{return length;}
int Find(int k,T&x)const;
int Search(const T&x)const;
void Delete(int k,T&x);
void Insert(int k,const T&x);
void Output()const;

Question and Answer
C/C++ Unix & Linux Wordpress
Source codes
C C++ Java

Free email signup

Email: