Académique Documents
Professionnel Documents
Culture Documents
LIST OF PROGRAMS
#include<iostream.h>
#include<process.h>
#include<conio.h>
template<class T>
class stack
{
T *s;
int top,size;
public: stack(int);
~stack();
void push();
void pop();
void display();
};
template<class T>
stack<T>::stack(int k)
{
size=k;
s=new T[size];
top=0;
}
template<class T>
stack<T>::~stack()
{
delete s;
}
template<class T>
void stack<T>::push()
{
if(top==size)
cout<<"Stack Overflow!"<<endl;
else
{
T x;
cout<<"Enter the data value: ";
cin>>x;
s[top]=x;
top++;
}
}
template<class T>
void stack<T>::pop()
{
if(top==0)
cout<<endl<<"Stack Underflow";
else
{
top--;
cout<<"\nThe pop element is: "<<s[top];
}
}
template<class T>
void main()
{
int m;
clrscr();
cout<<endl<<"Enter the size of array: ";
cin>>m;
stack <int> t1(m);
while(1)
{
int ch;
cout<<endl<<"*****STACK MENU*****"<<endl;
cout<<"1.PUSH"<<endl;
cout<<"2.POP"<<endl;
cout<<"3.DISPLAY"<<endl;
cout<<"4.EXIT"<<endl;
cout<<"Enter Choice:";
cin>>ch;
switch(ch)
{
case 1:t1.push();
break;
case 2:t1.pop();
break;
case 3:t1.display();
break;
case 4:exit(0);
break;
}
}
}
#include<iostream.h>
#include<process.h>
#include<conio.h>
template<class T>
class lstack
{
typedef struct node
#include<iostream.h>
#include<process.h>
#include<conio.h>
template<class T>
class lqueue
{
K S V KRISHNA SRIKANTH Page 5
typedef struct node
{
int data;
struct node *link;
}s;
s *head,*tail,*p,*k;
public: lqueue();
void insertion();
void deletion();
void display();
};
template<class T>
lqueue<T>::lqueue()
{
head=tail=NULL;
}
template<class T>
void lqueue<T>::insertion()
{
T x;
p=new s;
cout<<"Enter data value:";
cin>>x;
cout<<endl;
p->data=x;
p->link=NULL;
if(head==NULL)
head=tail=p;
else
{
tail->link=p;
tail=p;
}
}
template<class T>
void lqueue<T>::deletion()
{
if(head==NULL)
cout<<"Queue Underflow"<<endl;
else
{
p=head;
head=head->link;
cout<<"The deleted element is "<<p->data;
delete p;
}
cout<<endl;
}
template<class T>
void lqueue<T>::display()
{
if(head==NULL)
cout<<"Queue Empty"<<endl;
else
#include<iostream.h>
#include<process.h>
#include<conio.h>
template<class T>
class cqueue
{
T *v;
int size,front,rear;
public: cqueue(int);
~cqueue();
void insertion();
void deletion();
void display();
};
template<class T>
cqueue<T>::cqueue(int k)
{
size=k;
#include<iostream.h>
#include<process.h>
#include<conio.h>
template <class T>
class cqueue
{
typedef struct node
{
int data;
struct node *link;
}s;
s *front,*rear,*p,*k;
public: cqueue();
void insertion();
void deletion();
void display();
};
template<class T>
cqueue<T>::cqueue()
{
front=rear=NULL;
}
template<class T>
void cqueue<T>::insertion()
}
template<class T>
void cqueue<T>::display()
{
if(front==NULL)
cout<<endl<<"Queue Empty";
else
{
cout<<endl<<"The elements are: ";
for(p=front;p->link!=front;p=p->link)
{ cout<<p->data<<" ";}
cout<<p->data<<" ";
cout<<endl;
#include<iostream.h>
#include<conio.h>
#inlcude<process.h>
template<class T>
class dequeue
{
typedef struct nnode
{
int data;
node *left,*right;
}s;
s *front,*rear,*p,*q,*k;
public:
dequeue()
{
front=rear=NULL;
}
void insbegin();
void insend();
void delbegin();
void delend();
void display();
};
template<class T>
void dequeue<T>::delbegin()
{
p=front;
front=front->right;
front->left=NULL;
cout<<"Deleted Element is "<<p->data;
delete p;
}
void main()
{
int ch;
clrscr();
dequeue <int> t1;
while(1)
{
cout<<"**Dequeue Menu**"<<endl;
cout<<"1.Insertion at front"<<endl;
cout<<"2.Insertion at rear"<<endl;
cout<<"3.Deletion at front"<<endl;
cout<<"4.Deletion at rear"<<endl;
cout<<"5.Display"<<endl;
cout<<"6.Exit"<<endl;
cout<<"Enter choice: ";
cin>>ch;
switch(ch)
{
case 1: t1.insbegin();
break;
case 2: t1.insend();
break;
case 3: t1.delbegin();
break;
case 4: t1.delend();
break;
case 5: t1.display();
break;
case 6: exit(0);
break;
default: cout<<"Enter valid Option";
break;
}
}
}
#include<iostream.h>
#include<process.h>
#include<conio.h>
#inlcude<math.h>
#inlcude<string.h>
class postfix
OUTPUT 1:
OUTPUT 2:
#include<iostream.h>
#include<conio.h>
#include<process.h>
char stack[30],postfix[30],infix[30];
class intopost
{
public:
int top;
public:
intopost()
{
top=-1;
}
int pri(char);
void push(char);
char stacktop();
int isalnum(char);
char pop();
void conintopost(char[],char[]);
};
int intopost::pri(char x)
{
int value;
switch(x)
{
case ')':value=0;
K S V KRISHNA SRIKANTH Page 15
break;
case '+':value=1;
break;
case '-':value=1;
break;
case '*':value=2;
break;
case '/':value=2;
break;
case '^':value=3;
break;
case '(':value=4;
break;
}
return value;
}
void intopost::push(char x)
{
top=top+1;
stack[top]=x;
}
char intopost::stacktop()
{
return stack[top];
}
int intopost::isalnum(char x)
{
return((x>='0'&&x<='9')||(x>='a'&&x<='z')||(x>='A'&&x<='Z'));
}
char intopost::pop()
{
return stack[top--];
}
void intopost::conintopost(char infix[],char postfix[])
{
int i,j=0;
char c,pc;
for(i=0;(c=infix[i])!='\o';i++)
{
if(isalnum(c))
postfix[j++]=c;
else
{
while(top!=-1 && (pri(stacktop())>=pri(c)))
{
if(stacktop()=='('&&c!=')')
break;
if(stacktop()=='('&&c==')')
{
pop();
break;
}
pc=pop();
if(pc!='(')
void main()
{
clrscr();
intopost t1;
cout<<"Enter infix expression:";
cin>>infix;
t1.conintopost(infix,postfix);
cout<<endl<<"Postfix Expression is ";
cout<<postfix;
getch();
}
OUTPUT 1:
OUTPUT 2:
#include<iostream.h>
#include<conio.h>
#include<process.h>
int main()
{
clrscr();
int sp1[10][3],sp2[10][3],sp3[10][3];
int i,j,m,n,p,q,t1,t2,d,s,element;
int sum[10][3],diff[10][3];
cout<<"Enter the number of rows and columns\n";
cin>>m;
cin>>n;
t1=t2=0;
cout<<" Enter the first matrix("<<m<<"*"<<n<<")\n";
for(i=1;i<=m;i++)
{
if(sp1[i][2]=sp1[j][2])
{
sum[s][1]=diff[d][1]=sp1[i][1];
sum[s][2]=diff[d][2]=sp1[j][2];
}
sum[0][1]=diff[0][1]=m;
sum[0][2]=diff[0][2]=n;
sum[0][3]=s-1;
diff[0][3]=d-1;
cout<<"the sum of two sparse matrices is:";
for(i=0;i<s;i++)
{
cout<<"\n"<<sum[i][1]<<"\t"<<sum[i][2]<<"\t"<<sum[i][3]<<"\n";
}
cout<<"The difference of the two matrices is :";
for(i=0;i<d;i++)
{
cout<<"\n"<<diff[i][1]<<"\t"<<diff[i][2]<<"\t"<<diff[i][3]<<"\n";
}
getch();
return 0;
}
OUTPUT:
0 0 0
0 2 0
0 0 6
3 3 2
2 2 2
3 3 6
3 3 3
1 3 1
2 3 3
3 3 4
3 3 3
1 2 3
2 3 9
3 3 4
3 3 3
1 2 1
2 3 3
3 3 -4
#include<iostream.h>
#include<conio.h>
#include<process.h>
template<class T>
class bstree
{
typedef struct node
template<class T>
bstree<T>::bstree()
{
head=prev=c=NULL;
}
template<class T>
void bstree<T>::creation()
template<class T>
void bstree<T>::insertion()
{
T x;
q=new s;
cout<<endl<<"Enter the data value: ";
cin>>x;
q->data=x;
q->left=q->right=NULL;
c=head;
while(c!=NULL)
{
prev=c;
if(c->data<q->data)
c=c->right;
else
c=c->left;
}
if(prev!=NULL)
template<class T>
void bstree<T>::display()
{
int ch;
cout<<endl<<"The tree elements:\n ";
cout<<"\n---------------------------\n";
cout<<" DISPLAY MENU \n";
cout<<"----------------------------\n";
cout<<" 1. Pre-Order \n";
cout<<" 2. In-Order \n";
cout<<" 3. Post-Order \n";
cout<<"----------------------------\n";
do
{
cout<<endl<<"Enter the display choice: ";
cin>>ch;
switch(ch)
{
case 1: cout<<endl<<"Preorder Display: ";
preorder(head);
cout<<endl;
break;
case 2: cout<<endl<<"Inorder Display: ";
inorder(head);
cout<<endl;
break;
case 3: cout<<endl<<"Postorder Display: ";
postorder(head);
cout<<endl;
break;
}
}while(ch<=3);
}
template<class T>
void bstree<T>::deletion()
{
if(head==NULL)
cout<<endl<<"Deletion not possible";
else
{
int x;
cout<<endl<<"Enter the delete element: ";
cin>>x;
if(head->data==x)
}
}
void main()
{
int ch;
clrscr();
bstree <int> t1;
t1.creation();
while(1)
{
#include<iostream.h>
#include<conio.h>
#include<process.h>
#define TRUE 1
#define FALSE 0
class bstree
{
private: struct node
{
node *lc;
int data;
node *rc;
}*root;
public:
bstree {
root=NULL;
}
void buildtree(int num)
{
insert(&root,num);
}
static void insert(node **sr,int);
static void search(node **sr,int num,node **par,node **x,int *found);
void remove(int num) {
rem(&root,num);
}
static void rem(node **sr,int num);
void display() {
inorder(root);
}
static void inorder(node *sr);
~bstree() {
del(root);
}
void bstree::search(node **sr,int num,node **par,node **x,int *found)
{
node *q;
q=*sr;
*found=FALSE;
*par=NULL;
while(q!=NULL)
{
if(q->data==num)
{
*found=TRUE;
*x=q;
return;
}
*par=q;
if(q->data>num)
q=q->lc;
else
q=q->rc;
}
}
void bstree::inorder(node *sr)
{
if(sr!=NULL)
{
inorder(sr->lc);
cout<<sr->data<<" ";
inorder(sr->rc);
}
}
void main()
{
bstree bst;
int req,i=0,num,a[]={11,9,13,8,10,12,14,15,7};
while(i<=8)
{
bst.buildtree(a[i]);
i++;
OUTPUT:
7 8 9 10 11 12 13 14 15
7 8 9 11 12 13 14 15
7 8 9 11 12 13 15
7 9 11 12 13 15
7 9 11 12 15
#include<iostream.h>
#include<conio.h>
#define n 100
class poly
{
private:
int a[n],b[n],add[n],mul[n],p,q,at;
public:
void init();
void input();
void process();
void display();
};
void main()
{
poly ob;
clrscr();
ob.init();
OUTPUT:
#include<iostream.h>
#include<conio.h>
class hsort
{
private:
int *a,n;
public:
hsort(int x)
{
n=x;
a=new int[n];
}
void getdata()
{
void main()
{
int n;
clrscr();
cout<<"Enter n value:";
cin>>n;
hsort t(n);
t.getdata();
cout<<"\n\nElements before sorting:\n\n\t";
t.display();
t.heapsort(n-1);
cout<<"\n\nElements after sorting are:\n\n\t";
OUTPUT:
Enter n value: 10
Enter 0 th value: 90
Enter 1 th value: 57
Enter 2 th value: 25
Enter 3 th value: 13
Enter 4 th value: 11
Enter 5 th value: 9
Enter 6 th value: 17
Enter 7 th value: 1
Enter 8 th value: 2
Enter 9 th value: 3
#include<iostream.h>
#include<conio.h>
class msort
{
int a[50],n;
public:
msort(int);
void getdata();
void sort(int,int);
void display();
void merge(int,int,int);
};
msort::msort(int size)
{
n=size;
}
void msort::getdata()
{
int m;
cout<<endl;
for(m=0;m<n;m++) {
cout<<"\tEnter "<<m<<" th value:";
cin>>a[m];
}
}
void msort::display()
void main()
{
int m;
clrscr();
cout<<"Enter the array size:";
cin>>m;
msort t(m);
t.getdata();
cout<<"\n\nElements before sorting: \n\n\t";
t.display();
t.sort(0,m-1);
cout<<"\n\nElements after sorting: \n\n\t";
t.display();
}
OUTPUT:
Enter 0 th value: 23
Enter 1 th value: 1
Enter 2 th value: 65
Enter 3 th value: 54
Enter 4 th value: 21
Enter 5 th value: 27
Enter 6 th value: 12
Enter 7 th value: 15
Enter 8 th value: 41
Enter 9 th value: 96
#include<iostream.h>
#include<conio.h>
class isort
{
private:
int array[100],n,i,j,temp;
public:
void init();
void sort();
}
cout<<"\nArray is sorted in ascending order:\n\n";
for(i=0;i<n;i++)
cout<<array[i]<<" ";
}
void main()
{
clrscr();
isort b;
b.init();
b.sort();
getch();
}
#include<iostream.h>
#include<conio.h>
class bsort
{
private:
int array[100],n,i,j,temp;
public:
void init();
void sort();
};
void bsort::init()
{
cout<<"Enter the size of the array: ";
cin>>n;
void main()
{
clrscr();
bsort b;
b.init();
b.sort();
getch();
}
OUTPUT:
#include<iostream.h>
#include<conio.h>
class ssort
{
K S V KRISHNA SRIKANTH Page 37
private:
int array[100],n,i,j,temp,min,x;
public:
void init();
void sort();
};
void ssort::init()
{
cout<<"Enter the size of the array: ";
cin>>n;
cout<<"\nEnter "<<n<<" numbers\n";
for(i=0;i<n;i++)
cin>>array[i];
}
void ssort::sort()
{
for(i=0;i<n-1;i++)
{
x=i;
min=array[i];
for(j=i+1;j<n;j++)
{
if(min>array[j])
{
min=array[j];
x=j;
}
}
temp=array[i];
array[i]=array[x];
array[x]=temp;
}
cout<<"\nArray is sorted in ascending order:\n\n";
for(i=0;i<n;i++)
cout<<array[i]<<" ";
}
void main()
{
clrscr();
ssort b;
b.init();
b.sort();
getch();
}
OUTPUT:
1
5
#include<iostream.h>
#include<conio.h>
#include<process.h>
class bsearch
{
private:
int ar[100],beg,mid,end,i,n,s;
public:
void search();
};
void bsearch::search()
{
cout<<"Enter the size of array: ";
cin>>n;
cout<<"\nEnter "<<n<<" numbers in ascending order: \n";
for(i=0;i<n;i++)
cin>>ar[i];
beg=0;
end=n-1;
cout<<"\nEnter a number to search: ";
cin>>s;
while(beg<=end)
{
mid=(beg+end)/2;
if(ar[mid]==s)
{
cout<<"\nItem "<<s<<" found at position "<<(mid+1);
getch();
exit(0);
}
if(s>ar[mid])
beg=mid+1;
else
end=mid-1;
}
cout<<"\nSorry! "<<s<<" is not found.";
getch();
}
clrscr();
bsearch b;
b.search();
}
OUTPUT 1:
OUPTUT 2:
#include<iostream.h>
#include<conio.h>
class lsearch
{
private:
int c,a[10],i,n,m;
public:
lsearch::lsearch()
{
c=0;
}
void lsearch::init()
{
cout<<"Enter the size of an array: ";
cin>>n;
if(c==0)
cout<<"\nThe number "<<m<< " is not in the list";
else
cout<<"\nThe number "<<m<< " is found";
return 0;
}
int main()
{
clrscr();
lsearch l;
l.init();
l.search();
}
OUTPUT 1:
OUTPUT 2:
#include<iostream.h>
#include<process.h>
#include<conio.h>
int main()
{
int i,n;
clrscr();
cout<<"How many numbers you want to sort: ";
cin>>n;
cout<<"\nEnter "<<n<<" numbers:\n";
for (i = 0; i<n; i++)
cin>>numbers[i];
//perform quick sort on array
qsort(numbers,0,n-1);
// Function to sort
void qsort(int numbers[], int left, int right)
{
int pivot, l_hold, r_hold;
l_hold = left;
r_hold = right;
pivot = numbers[left];
while (left < right)
{
while ((numbers[right] >= pivot) && (left < right))
right--;
if (left != right)
{
numbers[left] = numbers[right];
left++;
}
while ((numbers[left] <= pivot) && (left < right))
left++;
if (left != right)
{
numbers[right] = numbers[left];
right--;
}
}
numbers[left] = pivot;
pivot = left;
left = l_hold;
right = r_hold;
if (left < pivot)
qsort(numbers, left, pivot-1);
if (right > pivot)
qsort(numbers, pivot+1, right);
}
#include<iostream.h>
#include<conio.h>
#define MAX 20
class breadth
{
private:
int a[MAX][MAX],visited[MAX],queue[50];
int n, front, rear;
public:
void init();
void input();
void bfs();
};
void breadth::input()
{
int i,j;
cout<<"\nENTER NUMBER OF NODES IN A GRAPH: ";
cin>>n;
cout<<"\nENTER ADJACENCY MATRIX FOR A GRAPH:\n \n";
for(i=1;i<=n;i++)
for(j=1;j<=n;j++)
cin>>a[i][j];
}
void breadth::bfs()
{
int i,start;
cout<<"\nSTARTING NODE FOR BFS TRAVERSING: ";
cin>>start;
cout<<"\nBREADTH FIRST SEARCH TRAVERSING IS: \n\n \t";
cout<<start;
visited[start] = 1;
rear++;
front++;
queue[rear]=start;
while(front<=rear)
{
start=queue[front];
front++;
for(i=1;i<=n;i++)
{
if(a[start][i]==1 && visited[i]==0)
{
cout<<" -> "<<i;
visited[i]=1;
rear++;
queue[rear]=i;
}
}
}
}
void main ( )
{
breadth ob;
0 1 0 1 1 0 0 0 0
0 0 1 0 1 0 0 0 0
0 0 0 0 0 1 0 0 0
0 0 0 0 0 0 1 0 0
0 0 0 0 0 1 0 1 0
0 0 0 0 0 0 0 0 0
0 0 0 0 1 0 0 1 0
0 0 0 0 0 0 0 0 1
0 0 0 0 0 0 0 0 0
#include<iostream.h>
#include<conio.h>
#define MAX 20
class depth
{
private:
int a[MAX][MAX],visited[MAX];
int n,top;
public:
void init();
void input();
void dfs(int);
};
void depth::init()
{ int i,j;
for(i=0;i<MAX;i++)
{
visited[i]=0;
for(j=0;j<MAX;j++)
a[i][j]=0;
}
K S V KRISHNA SRIKANTH Page 45
top=-1;
}
void depth::input()
{
int i,j;
cout<<"\nENTER NUMBER OF NODES IN A GRAPH: ";
cin>>n;
cout<<"\nENTER ADJACENCY MATRIX FOR A GRAPH: \n\n";
for(i=1;i<=n;i++)
for(j=1;j<=n;xj++)
cin>>a[i][j];
}
void depth::dfs(int v)
{
int i;
visited[v]=1;
cout<<v<<" -> ";
for(i=1;i<=n;i++)
if(a[v][i]==1&&visited[i]==0)
dfs(i);
}
void main()
{
depth ob;
int start;
clrscr();
ob.init();
ob.input();
cout<<"\nSTARTING NODE FOR DFS TRAVERSING: ";
cin>>start;
cout<<"\nDEPTH FIRST SEARCH TRAVERSING IS:\n\n";
ob.dfs(start);
getch();
}
0 1 0 1 1 0 0 0 0
0 0 1 0 1 0 0 0 0
0 0 0 0 0 1 0 0 0
0 0 0 0 0 0 1 0 0
0 0 0 0 0 1 0 1 0
0 0 0 0 0 0 0 0 0
0 0 0 0 1 0 0 1 0
0 0 0 0 0 0 0 0 1
0 0 0 0 0 0 0 0 0
#include <iostream.h>
#include <string.h>
#include <ctype.h>
class infix
{
private:
public:
infix();
void setexpr(char *str);
void push(char c);
char pop();
void convert();
int priority(char c);
void show();
};
while(*s)
{
if(*s==' '||*s=='\t')
{
s++;
continue;
}
if(isdigit(*s)||isalpha(*s))
{
while(isdigit(*s)||isalpha(*s))
{
*t = *s;
s++;
t--;
}
}
if(*s == ')')
{
push(*s);
s++;
}
while(priority(opr)>priority(*s))
{
*t = opr;
t--;
opr = pop();
}
push(opr);
push(*s);
}
else
push(*s);
s++;
}
if(*s == '(')
{
opr = pop();
while((opr)!=')')
{
*t=opr;
t--;
opr=pop();
}
s++;
}
}
while(top != -1)
{
opr = pop();
*t = opr;
t--;
}
t++;
}
void main()
{
char expr[MAX];
infix q;
cout <<"\nEnter an expression in infix form: " ;
cin.getline(expr,MAX);
q.setexpr(expr) ;
q.convert() ;
cout << "The Prefix expression is: " ;
q.show() ;
}
#include <iostream.h>
class revll
{
private:
struct node
{
int data ;
node *link ;
} *p;
public:
revll();
void addatbeg(int num);
void reverse();
void display() ;
int count() ;
~revll() ;
};
revll::revll()
{
p = NULL;
}
revll::~revll()
{
node *q;
while(p != NULL)
{
q = p -> link;
delete p;
p = q;
void main()
{
revll l;
l.addatbeg(7);
l.addatbeg(43);
l.addatbeg(17);
l.addatbeg(3);
l.addatbeg(23);
l.addatbeg(5);
cout << "\nElements in the linked list before reversing: ";
l.display();
cout << "\nNo. of elements in the linked list: " << l.count();
l.reverse();
cout << "\n\nElements in the linked list after reversing: ";
l.display();
cout << "\nNo. of elements in the linked list: " << l.count();
}
#include <iostream.h>
class linklist
{
private:
struct node
{
int data;
node *link;
} *p;
public:
linklist();
void add(int num);
void display();
int count();
void del(int num);
~linklist();
};
linklist::linklist()
{
p = NULL;
}
linklist :: ~linklist()
{
node *q ;
while ( p != NULL )
{
q = p -> link ;
delete p ;
p = q ;
}
}
void main()
{
#include<iostream.h>
#include<string.h>
#include<conio.h>
class pm
{
char ex[30];
int stack[20];
int len;
public:
void main()
{
pm t;
int l;
char ex[30];
clrscr();
cout<<"Enter the expression: ";
cin.getline(ex,30);
Output:
3 matched with 7
11 matched with 15
0 matched with 18
No match for parenthesis at 19
21 matched with 22
No match for parenthesis at 20
#include<iostream.h>
#include<conio.h>
#include<process.h>
class toh
{
public:
void move(int,char,char,char);
};
Output:
Move from A to C
Move from A to B
Move from C to B
#include<iostream.h>
#include<conio.h>
class item
{
int ino;
int icost;
public: item(int a,int b)
{
ino=a;
icost=b;
}
int addTwoItems(item *x)
{
int r=icost+x->icost;
return r;
}
friend int sum(const int *p,const int *q)
{
int total=(*p)+(*q);
return total;
}
};
void main()
{
clrscr();
item c(10,30);
int m=20,n=70;
item y(m,n);
cout<<endl<<"Addition of 2 items= "<<c.addTwoItems(&y)<<endl;
cout<<endl<<"Sum of 2 items= "<<sum(&m,&n);
}
OUTPUT
Sum of 2 items= 90
#include<iostream.h>
#include<process.h>
template<class T>
class queue
{
T *s;
int front,rear,size;
#include <iostream.h>
#include <conio.h>
class LinkedList
{
struct node
{
int data;
node *link;
} *p;
public:
void insbeg(int a)
{
node *q;
q=p;
p=new node;
p->data=a;
p->link=q;
}
void disp()
{
node *q;
q=p;
if(q==NULL)
{
cout<<"Empty List "<< endl;
return;
}
cout<<"List Items ";