Vous êtes sur la page 1sur 141

INDEX

CHAPTER
NO.
1.

2.

3.

4.

TITLE
Introduction
1.1 About the Project Problem
1.2Methods Of Linked List
System Study
2.1 Current system & its limitations
2.2 Proposed system
2.3 Objectives
2.4 Feasibility studies
System Analysis
3.1 Analysis
3.2 System Diagram
System Design
4.1 About the environment

PAGE NO.

11

Code
5.1 Source code
5.2 Input and Output Designs

18

6.

User Manual

132

7.

Conclusion
7.1 Scope
7.2Limitations

134

Bibliography

136

5.

8.

1. Introduction to Project
1.1 About the Project
Stack N Queue using linked list in Graphics is developed by using OOP WITH C++.
It included many features, which not only attract users of it but also inspires the programmers
who want to make good Application in C++. It is extremely user friendly; fully animated with
the additional features that experienced users need not follow in multiple level menus. Also it
gives other important features like calculating the total time for each sorting techniques.
The project named Stack N Queue can be used to perform push and pop operation on
stack and insert and delete operation on queue which you would normally use by a very complex
paper work.

1.2 Description about methods of Linked List


Linked list:
A Linked list is a chain of elements in which each element consists of data as well as a
link to the next element. The link stores the address of the next logically similar element in the
list.

Data
Data

Address
Address
of
of
Next
Next node
node

Stack as a Linked list:


The linked list representation of a stack, commonly termed linked stack
is a stack that is implemented using a singly linked list. The INFO fields of the nodes hold the
elements of the stack and the LINK fields hold pointers to the neighboring element in the stack.
The START pointers of the linked list behaves as the TOP pointers variable of the stack and the
NULL pointers of the last node in the list signals the bottom of stack.

xxx

INFO
Top of stack

yyy

zzz

LINK
Bottom of stack

A push operation into STACK is accomplished by inserting a node into the front or start of the
list and a pop operation is undertaken by deleting the node pointed to by the START pointers.

Push www into Stack


STACK before push operation:
Top
xxx

yyy

zzz

STACK after push operation:


Top
www

xxx

yyy

yyy

zzz

zzz

Pop from STACK


Top
xxx

STACK after pop operations:


Top

Top
xxx

yyy

zzz

Queue as a Linked list:


A linked queue is a queue implemented as a linked list with two pointers
variables FRONT and REAR pointing to the nodes which is in the FRONT and REAR of the
queue. The INFO fields of the list hold the elements of the queue and the LINK fields hold
pointers to the neighboring element in the queue.
Queue Q:
AAA

BBB

CCC

DDD

Front

Rear

The Rear pointer is updated to point to the last node just added to the list. In the case of
deletion, the first node of the list pointed to by FRONT is deleted and the FRONT pointer is
updated to point to the next node in the list.
Insert EEE into queue Q:
AAA

BBB

CCC

Front

DDD

Rear

EEE

Rear

Delete from queue Q


AAA

Front

BBB

Front

CCC

DDD

EEE

Rear

Chapter No.2

SYSTEM STUDY

2. System study
2.1 Current Manual system & its limitations:
In manual system, a paper work is maintained for performing sorting
Techniques. Each technique is performing separately using paper work and there is need
to draw various diagrams to understand the working of Linked list. It consumes lot of
time and some times process will become more confusing and critical and it will become
very difficult to understand how it works. It will take lot of manual efforts for drawing
each diagram of stack & queue using linked list and stack & queue using double ended
linked list..

2.2Proposed System
Computerized System resembles old manual system. It Perform the operation
automatically, which hold track of all operation. It contains correct track. Operation
process is fast and it takes legal inputs so less time required for showing the
process . System will show the animation of selected sorting technique to user so that
user can easily understand how the process is carried out.

2.3 Objectives
By doing computerization of system, many goals can be attained. Computer can achieve
tremendous speed. To show the animated steps for each Linked list is objectives of our
system. These are some other objectives of system.

To computerize the current manual system.

To make system a user friendly so that working on a system becomes


easy for users.

To provide the user with user friendly system that will satisfy his
requirement and help him to work comfortably system.

To reduce man power and associated disadvantages.

2.4 Feasibility Studies


The organization already has required hardware and software other technical
equipments. Hence the system will be technically feasible.
a) Operational Social Feasibility:
This system is very easy to understand for Teachers and students, so that
there is no need to appoint a new person. Hence, computerization of drawing
System would be socially feasible.
b) Economic Feasibility:
The Project does not require any heavy extra expenses for Analysis and design of
new system. Student can operate and maintain the system with available facilities.
Benefits acquire by installation of system are immense. Tangible benefits, which
can be evaluated in money otherwise, quantified.
In tangible benefits include developer satisfaction. It also helpful to students as
they save time and paper cost.

Chapter No 3

SYSTEM ANALYSIS

3 SYSTEM ANALYSIS
3.1Analysis
A) System Analysis:
System analysis & design is concerned with manmade system involving.

INPUT

PROCESS

OUTPUT

A system can be defined as a set of interfacing elements responding from inputs to


outputs. Each system is composed of subsystem, which are further made of sub systems.
The interconnections between sub systems are known as interface. The system concept
requires the system analyst to look after the system as whole.
System will analyze in terms of their objectives and inputs, Processes and outputs
required achieving these objectives.
System analyst is concerned with analyzing system with a view to make them more by
modification or by substantial redesign.
The real essence of system design is dividing a system that needs the proceeding
requirements. It involves creation and development of new, inputs, methods, procedures
and outputs for processing data that continue to objectives. To put it in way creativity
is a requirement for the knowledge of technique itself. It is formed as a science because
its approach is scientific.
*During the system analysis phase, the information about the LINKED LIST was
collected, through various mediums such as, from Books available in library, through
Internet, and through interaction with concerned professor.

Based on the information collected, the it was decided that development of the system is
to be divided in Four different phases, i.e;
i)

Introduction Part

ii)

Information part

iii)

Operation Part

iv)

Introduction to Advanced Concepts.

b) System Design:
As per the points decided , design of the system was carried out.
i)

Introduction Part : Introduction part contains the introduction of the subject


in a brief format.

ii)

Information Part : Information of each topic is given in simple to complex


order . Various related concept is discussed on each page.Information of each
operation and how to perform it is also given along with a solved example.

iii)

Operation Part : User can perform various operations by inputting data and
viewing the output on the same screen or in some cases, on a different screen.
Input design and output design is also prepared for the convenience of the
user.
In Software design phase , it was decided to use C++ as a language.
The code is written using arrays and using in-built Graphics functions.The
code is so written, that user can easily understand it.

iv)

Introduction to Advanced Concepts : The advanced concepts are well


discussed in the end part of the project.

10

3.2 System Diagram


Structured Chart of System work

LINKED LIST

Stack

Queue

DOUBLE ENDED
LINKED LIST

Stack

Queue

11

Chapter No.4

SYSTEM DESIGN

12

4. SYSTEM DESIGN:
4.1 About the Environment
1 Platform Used
C++ has developed by BJARNE STROUSTRUP at AT & T BELL Laboratories.
C++ is derived from the c language .It is compatible With c (it is actually a
superset ).So that exiting c code can be incur ported into c++ programs . The most
important element s added to c to create c++ are concern with classes ,objects and
object oriented programming.
C++ programs are fast and efficient ,qualities , which helped make C an
extremely popular programming language .however, it scarifies Some flexibility in
order to remain efficient . C++ uses compile time Binding ,which means that the
programmer must specified the specific Class of an object or at a very least ,the
most general class that an Object can be belong to. This provides high run time
efficiency & Code size, but it trades off some of the power to reuse classes.
C++ has become so popular most new C compilers are actually C/C++ compilers.
However, to take full advantage of oops ,one must program and think in C++.This
can often be a major problem for experienced c programmers. Many programmers
think they are coding in c++, but instead are only using a small languages object
oriented power.
Applications of C++
1. C++ is versatile language for handling very large programs
2. We can create hierarchy related objects, we build special
Object oriented libraries which can be used later by programmers.
3. C++ is able to map the real world problem properly; C part of C++ gives the
language the ability to get close to machine level details.
4. C++ programs are easily maintained & expandable

1) Arrays :
An Array can be defined as an infinite collection of homogenous (similar
type) elements. The simplest form of array is a one dimensional array, that may
be defined as a finite ordered set of homogenous elements.
One dimensional array can be declared as data_ type var_name [constant]
The declaration int a [100] reserves 100 successive memory locations, each large
enough to contain a single integer. The address of the first of these locations is
called the base address of array a.

13

Arrays like simple variables can also be passed to function. To pass, its
name is written inside the argument list in the call statement. Arrays are by
default passed to function by call by reference method, because array name is
itself a pointer to first memory location of array.
For Example: float avg (float avg [], int size)

2) Inheritance :
A key feature of C++ classes is inheritance. Inheritance allows creating classes
which are derived from other classes, so that they automatically include some of its
"parent's" members, plus its own. For example, we are going to suppose that we want to
declare a series of classes that describe polygons like our CRectangle, or like CTriangle.
They have certain common properties, such as both can be described by means of only
two
sides:
height
and
base.
This could be represented in the world of classes with a class CPolygon from which we
would
derive
the
two
other
ones:
CRectangle
and
CTriangle.

The class CPolygon would contain members that are common for both types of polygon. In our
case: width and height. And CRectangle and CTriangle would be its derived classes, with specific
features that are different from one type of polygon to the other.

In order to derive a class from another, we use a colon (:) in the declaration of the
derived class using the following format:
class derived_class_name: public base_class_name
{ /*...*/ };

3) Polymorphism:
Polymorphism is a powerful feature of the object oriented programming language C++. A single
operator + behaves differently in different contexts such as integer, float or strings referring the concept
of polymorphism. The above concept leads to operator overloading. The concept of overloading is also a
branch of polymorphism. When the exiting operator or function operates on new data type it is
overloaded. This feature of polymorphism leads to the concept of virtual methods.

C++ provides three different types of polymorphism.

Virtual functions
Function name overloading

14

Operator overloading

4) Functions:
Using functions we can structure our programs in a more modular way, accessing
all the potential that structured programming can offer to us in C++.
A function is a group of statements that is executed when it is called from some point
of the program. The following is its format:
type name ( parameter1, parameter2, ...) { statements } where:
Type is the data type specifies of the data returned by the function.
Name is the identifier by which it will be possible to call the function.
Parameters (as many as needed): Each parameter consists of a data type specifies
followed by an identifier, like any regular variable declaration (for example: int
x) and which acts within the function as a regular local variable. They allow
passing arguments to the function when it is called. The different parameters are
separated by commas.
Statements are the function's body. It is a block of statements surrounded by
braces { }.

5) Friend Function:
In principle, private and protected members of a class cannot be accessed from outside the same
class in which they are declared. However, this rule does not affect friends.Friends are functions or
classes declared with the friend keyword.If we want to declare an external function as friend of a
class, thus allowing this function to have access to the private and protected members of this class, we
do it by declaring a prototype of this external function within the class, and preceding it with the
keyword friend:

15

Inbuilt Function
NO

Function

Header File

Explanation

1
2
3

Rectangle
Lline
Bar3d

4
5
6
7
8
9

Settextstyle
Bar
Circle
Closegraph
Getmaxx
Getmaxy

10

Graphresult

coordinate
Returns error code for the last

Initgraph
Outtextxy
restorecrtmode

unsuccessful graphics operations


Initializes the graphics system
Displays a string at the specified location
Restores screen mode to pre-initgraph

Setcolor
Setfillstyle
Settextstyle
Textwidth

setting
Sets the current drawing color
Sets the fill pattern and color
Sets the current text characteristics
Return the width of a string in pixels

11
12
13
14
15
16
17

draw the rectangle


Draw line with coordinates
<graphics.h>
Draw 3d bar
Setting textstyles for text
Draws bar
Draws circle
Shuts down the graphics system
Returns maximum x or y screen

H/W & S/W Requirement :Developer Side:Processor

Pentium I ,II ,III ,IV

16

Windows 98,2000Professional Windows XP

Operating System

Software Requirements
Operating System

windows 98, 2000 professional, Windows XP

Database

Turbo charger - Bin

Recommended Requirements:
Hardware Requirements
CPU

2.0 GHz

RAM

512 + MB

Hard Disc

120 GB

Software Requirements
Operating System

Win98, Win NT or Win 2000

Database

Turbo-charger - Bin

User Side:Processor

Pentium I, II, III, IV

Operating system

Windows 98,2000Professional Windows


XP

Software Requirement for the System:This project can run on any Microsoft Windows platform. This project can
smoothly run on Windows 95/98/2000 and Windows XP with 1024 X 768 resolutions.

17

Hardware Requirement for the System :The Hardware requirement for the system is mainly depend on the operating
system used by the user. The standard requirements are (i) HDD 512 MB(min) (ii)RAM
32 MB

18

Chapter No.5

CODE

5. SYSTEM CODING
a.

Source Code

19

/* Project : Graphical Representation of Linked List


By : Avinash Kumar Sinha
Roll No. :02
Date : 18/04/2011

*/

#include<graphics.h>
#include<string.h>
#include<stdlib.h>
#include<conio.h>
#include<iostream.h>
#include<stdio.h>
#include<dos.h>
#include<alloc.h>
#define size 20
#define STSIZE 20
//----------------------

CONSTANT VARIABLES

-------------//

# define INSERT 0
# define DELETE 1
# define NORMAL 0
# define WARNING 1
# define PUSH 0
# define POP 1
Void screen();
//************************************************************
//----------------------

CLASS DEFINITION

----------------

class Linked_list_Stack
{
private:
char fill_pattern[8];

20

int pushed_element_count;
struct node
{
long data;
node *next;
};
node *top;
node *entry;
node *print;
node *bottom;
node *last_entry;
node *second_last_entry;
public:
Linked_list_Stack( );
long get_element( );
void pop( );
void push( );
void print_linked_list( );
void show_working( );
void show_main_screen( );
void waiting_for_input( );
void show_element_screen(int);
void clear_element_screen(int);
void show_push_pop_screen(int);
void show_output_screen( );
void show_window(int,int,int,int);
};
//---------------------

FUNCTION DEFINITIONS

--------------

//************************************************************
//----------------------

Linked_list_Stack( )

------------

21

Linked_list_Stack::Linked_list_Stack ( )
{
top=NULL;
bottom=NULL;
pushed_element_count=0;
fill_pattern[0]=0xAA;
fill_pattern[1]=0x55;
fill_pattern[2]=0xAA;
fill_pattern[3]=0x55;
fill_pattern[4]=0xAA;
fill_pattern[5]=0x55;
fill_pattern[6]=0xAA;
fill_pattern[7]=0x55;
}
//-------------------void

show_window(int,int,int,int)

Linked_list_Stack::show_window(int

x_1,int

------y_1,int

x_2,int y_2)
{
setcolor(15);
rectangle(x_1,y_1,x_2,y_2);
rectangle(x_1+1,y_1+1,x_2-1,y_2-1);
setcolor(7);
rectangle(x_1+2,y_1+2,x_2-2,y_2-2);
rectangle(x_1+3,y_1+3,x_2-3,y_2-3);
rectangle(x_1+4,y_1+4,x_2-4,y_2-4);
setcolor(8);
rectangle(x_1+5,y_1+5,x_2-5,y_2-5);
rectangle(x_1+6,y_1+6,x_2-6,y_2-6);
rectangle(x_1+7,y_1+7,x_2-7,y_2-7);
}

22

//----------------------

show_main_screen( )

------------

void Linked_list_Stack ::show_main_screen( )


{
setcolor(15);
setlinestyle(1,0,3);
rectangle(5,5,getmaxx( )-5,getmaxy( )-5);
setlinestyle(0,0,0);
show_window(5,5,getmaxx( )-5,80);
setfillpattern(fill_pattern,4);
bar(13,13,getmaxx( )-13,72);
settextstyle(3,0,4);
setcolor(0);
outtextxy(17,22,"Implementation of Linked List as
outtextxy(18,22,"Implementation

of

Linked

Stack");
List

as

Stack");
setcolor(14);
outtextxy(19,20,"Implementation of Linked List as Stack");
outtextxy(20,20,"Implementation

of

Linked

List

as

of

Linked

List

as

Stack");
outtextxy(21,20,"Implementation
Stack");
show_window(5,82,305,getmaxy( )-5);
setfillpattern(fill_pattern,9);
bar(14,91,296,getmaxy( )-14);
setcolor(6);
setfillstyle(1,6);
pieslice(215,105,0,360,10);
setcolor(2);
setfillstyle(1,2);
pieslice(245,105,0,360,10);
setcolor(4);
setfillstyle(1,4);
pieslice(275,105,0,360,10);

23

setcolor(7);
circle(215,105,11);
circle(245,105,11);
circle(275,105,11);
show_window(307,82,getmaxx( )-5,getmaxy( )-5);
settextstyle(7,0,4);
setcolor(0);
outtextxy(16,111,"Press:");
setcolor(10);
outtextxy(17,110,"Press:");
outtextxy(18,110,"Press:");
settextstyle(2,0,6);
setcolor(0);
outtextxy(59,151,"<P> to Push an Element");
outtextxy(59,171,"<O> to Pop an Element");
outtextxy(59,191,"<E> to Exit");
setcolor(14);
outtextxy(60,150,"<P> to Push an Element");
outtextxy(61,150,"<P> to Push an Element");
outtextxy(60,170,"<O> to Pop an Element");
outtextxy(61,170,"<O> to Pop an Element");
outtextxy(60,190,"<E> to Exit");
outtextxy(61,190,"<E> to Exit");
setfillstyle(2,1);
bar(317,92,getmaxx( )-15,getmaxy( )-15);
}
//-------------------

show_output_screen( )

----------

void Linked_list_Stack::show_output_screen( )

24

{
for(int count=0;count<=187;count++)
{
setfillstyle(1,0);
bar(317,280,getmaxx( )-15,278-count);
bar(317,280,getmaxx( )-15,278+count);
delay(5);
}
setcolor(12);
settextstyle(2,0,7);
outtextxy(405,400,"Linked List (Stack)");
outtextxy(406,400,"Linked List (Stack)");
outtextxy(407,400,"Linked List (Stack)");
setfillstyle(1,6);
bar(402,420,618,422);
setcolor(15);
setlinestyle(0,0,3);
rectangle(330,405,390,435);
setfillstyle(1,9);
bar(331,406,374,434);
setfillstyle(1,1);
bar(376,406,389,434);
line(375,405,375,435);
setcolor(7);
setlinestyle(0,0,0);
line(352,425,352,455);

/* Entry->Data pointing arrow */

line(352,455,415,455);
line(412,452,415,455);
line(412,458,415,455);

25

line(382,423,382,443);

/* Entry->Next pointing arrow */

line(382,443,415,443);
line(412,440,415,443);
line(412,446,415,443);
setfillstyle(1,15);
pieslice(382,420,0,360,2);
settextstyle(0,0,1);
setcolor(15);
outtextxy(320,402,"*");
setcolor(9);
outtextxy(420,452,"Entry->Data");
outtextxy(420,438,"Entry->Next (x=NULL)");
setcolor(11);
outtextxy(333,417,"00000");
}
//------------------- show_push_pop_screen(int)

--------

Void Linked_list_Stack::show_push_pop_screen(int NORMAL_WARNING)


{
int x_1;
int x_2;
int y_1;
int y_2;
if(NORMAL_WARNING==NORMAL)
{
x_1=20;
x_2=280;

26

y_1=277;
y_2=350;
}
if(NORMAL_WARNING==WARNING)
{
x_1=20;
x_2=280;
y_1=277;
y_2=367;
}
setcolor(15);
setlinestyle(1,0,3);
rectangle(x_1,y_1,x_2,y_2);
setlinestyle(0,0,0);
setcolor(15);
rectangle(x_1,y_1,x_2,y_2);
setcolor(7);
rectangle(x_1+1,y_1+1,x_2-1,y_2-1);
setcolor(8);
rectangle(x_1+2,y_1+2,x_2-2,y_2-2);
setfillstyle(1,9);
bar(x_1+3,y_1+3,x_2-3,y_2-3);
}
//-------------------- show_element_screen(int)

----------

27

void Linked_list_Stack::show_element_screen(int PUSH_POP)


{
show_push_pop_screen(NORMAL);
if(PUSH_POP==PUSH)
{
settextstyle(2,0,6);
setcolor(0);
outtextxy(28,281,"Enter the Element :");
setcolor(11);
outtextxy(29,280,"Enter the Element :");
outtextxy(30,280,"Enter the Element :");
}
else if(PUSH_POP==POP)
{
settextstyle(2,0,6);
setcolor(0);
outtextxy(28,281,"Poped Element is :");
setcolor(11);
outtextxy(29,280,"Poped Element is :");
outtextxy(30,280,"Poped Element is :");
}
delay(300);
for(int count=1;count<=65;count++)
{
setcolor(0);
setfillstyle(1,0);
bar(180-count,306,180+count,330);

28

pieslice(180-count,318,0,360,12);
pieslice(180+count,318,0,360,12);
setcolor(15);
line(180-count,302,180+count,302);
line(180-count,334,180+count,334);
arc(180-count,318,90,270,16);
arc(180+count,318,270,90,16);
setcolor(7);
arc(180-count,318,90,270,15);
arc(180-count,318,90,270,14);
line(180-count,303,180+count,303);
line(180-count,304,180+count,304);
line(180-count,333,180+count,333);
line(180-count,332,180+count,332);
arc(180+count,318,270,90,15);
arc(180+count,318,270,90,14);
setcolor(8);
line(180-count,305,180+count,305);
line(180-count,331,180+count,331);
arc(180-count,318,90,270,13);
arc(180+count,318,270,90,13);
delay(4);
}
}

29

//------------------ clear_element_screen(int)

----------

Void Linked_list_Stack::clear_element_screen(int NORMAL_WARNING)


{
if(NORMAL_WARNING==WARNING)
{
for(int count=1;count<=50;count++)
{
setfillpattern(fill_pattern,9);
bar(18,275,290,275+count);
bar(18,375,290,375-count);
delay(20);
}
}
else if(NORMAL_WARNING==NORMAL)
{
for(int count=1;count<=40;count++)
{
setfillpattern(fill_pattern,9);
bar(18,275,290,275+count);
bar(18,355,290,355-count);
delay(20);
}
}
}

//------------------------- get_element( )

-------------

long Linked_list_Stack::get_element( )

30

{
show_element_screen(PUSH);
int count=0;
char string[6]={'\0'};
do
{
int key_code=0;
char key=NULL;
if(kbhit( ))
key=getch( );
key_code=int(key);
if(key_code>=48 && key_code<=57)
{
string[count]=key;
count++;
}
else if(key_code==8 && count>0)
{
setfillstyle(1,0);
bar(130,306,230,330);
count--;
string[count]='\0';
}
else if(key_code==13 && count>0)
break;

31

setcolor(12);
settextstyle(2,0,7);
moveto(140,305);
outtext(string);
moveto(141,305);
outtext(string);
int x=getx( );
int y=305;
while(!kbhit( ))
{
settextstyle(2,0,7);
setcolor(12);
moveto(x+2,y);
outtext("_");
delay(250);
setcolor(0);
moveto(x+2,y);
outtext("_");
delay(200);
}
}
while(count<5);
if(count==5)
while(int(getch( ))!=13);

32

long element=atol(string);
clear_element_screen(NORMAL);
return element;
}
//-----------------------------

push( )

----------------

void Linked_list_Stack::push( )
{
long num=get_element( );
for(int count=1;count<5;count++)
{
setcolor(0);
setfillstyle(1,0);
pieslice(215,105,0,360,10);
delay(250);
setcolor(6);
setfillstyle(1,6);
pieslice(215,105,0,360,10);
delay(300);
}
if(pushed_element_count<15)
{
setcolor(10);
setfillstyle(1,10);
pieslice(245,105,0,360,10);

33

sound(1500);
delay(800);
nosound( );
setcolor(2);
setfillstyle(1,2);
pieslice(245,105,0,360,10);
}
if(pushed_element_count==15)
{
setcolor(12);
setfillstyle(1,12);
pieslice(275,105,0,360,10);
sound(2500);
delay(1000);
nosound( );
setcolor(4);
setfillstyle(1,4);
pieslice(275,105,0,360,10);
delay(200);
}
entry=new(node);
if(pushed_element_count==15)
{
show_push_pop_screen(WARNING);
settextstyle(7,0,4);
setcolor(0);

34

outtextxy(25,277,"Error:");
outtextxy(26,277,"Error:");
setcolor(14);
outtextxy(27,275,"Error:");
outtextxy(28,275,"Error:");
while(!kbhit( ))
{
settextstyle(2,0,8);
setcolor(0);
outtextxy(46,309,"Not enough heap");
outtextxy(47,309,"Not enough heap");
outtextxy(28,335,"space on Screen.");
outtextxy(29,335,"space on Screen.");
setcolor(12);
outtextxy(48,308,"Not enough heap");
outtextxy(49,308,"Not enough heap");
outtextxy(50,308,"Not enough heap");
outtextxy(30,334,"space on Screen.");
outtextxy(31,334,"space on Screen.");
outtextxy(32,334,"space on Screen.");
delay(500);
setfillstyle(1,9);
bar(23,315,277,362);
delay(400);
}

35

getch( );
clear_element_screen(1);
}
else if(bottom==NULL)
{
entry->data=num;
entry->next=NULL;
bottom=entry;
top=entry;
pushed_element_count++;
}
else
{
entry->data=num;
entry->next=NULL;
top->next=entry;
top=entry;
pushed_element_count++;
}
print_linked_list( );
}
//-------------------------- pop( )

--------------------

void Linked_list_Stack::pop( )
{
for(int count=1;count<5;count++)
{
setcolor(0);

36

setfillstyle(1,0);
pieslice(215,105,0,360,10);
delay(250);
setcolor(6);
setfillstyle(1,6);
pieslice(215,105,0,360,10);
delay(300);
}
if(pushed_element_count==0)
{
setcolor(12);
setfillstyle(1,12);
pieslice(275,105,0,360,10);
sound(2500);
delay(1000);
nosound( );
setcolor(4);
setfillstyle(1,4);
pieslice(275,105,0,360,10);
delay(200);
}
else if(pushed_element_count>0)
{
setcolor(10);
setfillstyle(1,10);
pieslice(245,105,0,360,10);

37

sound(3000);
delay(800);
nosound( );
setcolor(2);
setfillstyle(1,2);
pieslice(245,105,0,360,10);
}
if(bottom==NULL)
{
show_push_pop_screen(WARNING);
settextstyle(7,0,4);
setcolor(0);
outtextxy(25,277,"Error:");
outtextxy(26,277,"Error:");
setcolor(14);
outtextxy(27,275,"Error:");
outtextxy(28,275,"Error:");
while(!kbhit( ))
{
settextstyle(6,0,4);
setcolor(0);
outtextxy(48,306,"Nothing to Pop");
outtextxy(49,306,"Nothing to Pop");
setcolor(12);
outtextxy(50,305,"Nothing to Pop");
outtextxy(51,305,"Nothing to Pop");
outtextxy(52,305,"Nothing to Pop");

38

delay(500);
setfillstyle(1,9);
bar(23,315,277,350);
delay(400);
}
getch( );
}
else
{
for(last_entry=bottom;last_entry->next!=NULL;
last_entry=last_entry->next)
second_last_entry=last_entry;
if(top==bottom)
bottom=NULL;
long poped_element=top->data;
delete(top);
top=second_last_entry;
top->next=NULL;
pushed_element_count--;
char element[6]={'\0'};
ltoa(poped_element,element,10);
show_element_screen(POP);

39

setcolor(12);
settextstyle(2,0,7);
outtextxy(140,305,element);
outtextxy(141,305,element);
delay(2500);
}
clear_element_screen(POP);
print_linked_list( );
}
//---------------------- print_linked_list( )

----------

void Linked_list_Stack::print_linked_list( )
{
int count=0;
int x=340;
int y=100;
print=bottom;
setfillstyle(1,0);
bar(317,92,getmaxx( )-15,getmaxy( )-80);
while(print!=NULL)
{
setcolor(15);
setlinestyle(0,0,3);
rectangle(x,y,x+60,y+30);
char element[6]={'\0'};
ltoa(print->data,element,10);

40

if(count==0 || count==1 || count==2 || count==6 ||


count==7

||

count==8

||

count==12

||

count==13

||

count==14)
{
setfillstyle(1,9);
bar(x+1,y+1,x+44,y+29);
setfillstyle(1,1);
bar(x+46,y+1,x+59,y+29);
setcolor(15);
line(x+45,y,x+45,y+30);
setcolor(11);
settextstyle(0,0,1);
outtextxy(x+3,y+10,element);
if(count==pushed_element_count-1)
{
setcolor(15);
outtextxy(x+50,y+11,"x");
}
}
else
{
setfillstyle(1,9);
bar(x+16,y+1,x+59,y+29);
setfillstyle(1,1);
bar(x+1,y+1,x+14,y+29);
setcolor(15);

41

line(x+15,y,x+15,y+30);
if(count==pushed_element_count-1)
delay(500);
setcolor(11);
settextstyle(0,0,1);
outtextxy(x+18,y+10,element);
if(count==pushed_element_count-1)
{
setcolor(15);
outtextxy(x+4,y+11,"x");
}
}
if(count==1 || count==2 || count==7 || count==8 ||
count==13 || count==14)
{
setcolor(15);
line(x-45,y+15,x,y+15);
setfillstyle(1,15);
pieslice(x-47,y+15,0,360,2);
line(x-6,y+11,x-2,y+15);
line(x-6,y+19,x-2,y+15);
}
else if(count==4 || count==5 || count==10 ||
count==11)
{
setcolor(15);
line(x+60,y+15,x+105,y+15);

42

setfillstyle(1,15);
pieslice(x+107,y+15,0,360,2);
line(x+66,y+11,x+62,y+15);
line(x+66,y+19,x+62,y+15);
}
else if(count==3 || count==9)
{
setcolor(15);
setfillstyle(1,15);
pieslice(x+53,y-45,0,360,2);
setlinestyle(0,0,3);
line(x+55,y-45,x+75,y-45);
line(x+75,y-45,x+75,y+15);
line(x+60,y+15,x+75,y+15);
line(x+62,y+15,x+66,y+11);
line(x+62,y+15,x+66,y+19);
}
else if(count==6 || count==12)
{
setcolor(15);
setfillstyle(1,15);
pieslice(x+7,y-45,0,360,2);
setlinestyle(0,0,3);
line(x-15,y-45,x+10,y-45);
line(x-15,y-45,x-15,y+15);
line(x-15,y+15,x,y+15);

43

line(x-2,y+15,x-6,y+11);
line(x-2,y+15,x-6,y+19);
}
setcolor(7);
setlinestyle(0,0,3);
line(350,125,350,138);

/* Bottom Arrow */

line(346,134,350,138);
line(354,134,350,138);
setcolor(14);
settextstyle(2,0,4);
outtextxy(330,140,"Bottom");
if(count==pushed_element_count-1)
{
setcolor(7);
setlinestyle(0,0,3);
line(x+30,y+25,x+30,y+38);
line(x+26,y+34,x+30,y+38);
line(x+34,y+34,x+30,y+38);
setcolor(14);
settextstyle(2,0,4);
outtextxy(x+30,y+40,"Top");
}
print=print->next;
count++;
if(count==0 || count==1 || count==2 || count==6 ||
count==7

||

count==8

||

count==12

||

count==13

||

count==14)
x+=100;

44

else if(count==3 || count==4 || count==5 || count==9


|| count==10 ||

count==11)

x-=100;
if(count==3 || count==9)
{
x=540;
y+=60;
}
else if(count==6 || count==12)
{
x=340;
y+=60;
}
if(count==15)
break;
}
setlinestyle(0,0,0);
}
//------------------------

waiting_for_input( )

------------

void Linked_list_Stack ::waiting_for_input( )


{
do
{
setfillstyle(1,4);
bar(51,440,99,445);
setfillstyle(1,10);

45

bar(101,440,149,445);
setfillstyle(1,1);
bar(151,440,199,445);
setfillstyle(1,14);
bar(201,440,249,445);
delay(300);
setfillpattern(fill_pattern,9);
bar(51,440,99,445);
delay(150);
bar(101,440,149,445);
delay(150);
bar(151,440,199,445);
delay(150);
bar(201,440,249,445);
delay(150);
setfillstyle(1,4);
bar(51,440,99,445);
delay(150);
setfillstyle(1,10);
bar(101,440,149,445);
delay(150);
setfillstyle(1,1);
bar(151,440,199,445);
delay(150);
setfillstyle(1,14);
bar(201,440,249,445);

46

}
while(!kbhit( ));
setfillpattern(fill_pattern,9);
bar(51,440,249,445);
}
//---------------------------

show_working( )

------------

void Linked_list_Stack ::show_working( )


{
show_main_screen( );
delay(1000);
show_output_screen( );
char ch;
do
{
waiting_for_input( );
ch=getch( );
switch(ch)
{
case 'p': push( );
break;
case 'P': push( );
break;
case 'o': pop( );
break;
case 'O': pop( );

47

break;
case 'e': delay(500);
cleardevice();
ch=27;
break;
case 'E': delay(500);
cleardevice();
ch=27;
}
}
while(int(ch)!=27);
delay(500);
}
//-----------------------------------------------------------

class Double_Ended_Linked_list_as_Queue
{
private:
char fill_pattern[8];
int inserted_element_count;
struct node
{
long data;
node *next;
node *previous;
};

48

node *rear;
node *entry;
node *print;
node *front;
public:
Double_Ended_Linked_list_as_Queue( );
long get_element( );
void Delete( );
void Insert( );
void print_linked_list( );
void show_working( );
void show_main_screen( );
void waiting_for_input( );
void show_element_screen(int);
void clear_element_screen(int);
void show_insert_delete_screen(int);
void show_output_screen( );
void show_window(int,int,int,int);
};
//--------------------//--------------

FUNCTION DEFINITIONS

--------------

Double_Ended_Linked_list_as_Queue ( )

Double_Ended_Linked_list_as_Queue::Double_Ended_Linked_list_as_
Queue

( )
{
rear=NULL;
front=NULL;
inserted_element_count=0;

49

fill_pattern[0]=0xAA;
fill_pattern[1]=0x55;
fill_pattern[2]=0xAA;
fill_pattern[3]=0x55;
fill_pattern[4]=0xAA;
fill_pattern[5]=0x55;
fill_pattern[6]=0xAA;
fill_pattern[7]=0x55;
}
//--------------------

show_window(int,int,int,int)

--------

void Double_Ended_Linked_list_as_Queue::
show_window(int x_1,int y_1,int x_2,int y_2)
{
setcolor(15);
rectangle(x_1,y_1,x_2,y_2);
rectangle(x_1+1,y_1+1,x_2-1,y_2-1);
setcolor(7);
rectangle(x_1+2,y_1+2,x_2-2,y_2-2);
rectangle(x_1+3,y_1+3,x_2-3,y_2-3);
rectangle(x_1+4,y_1+4,x_2-4,y_2-4);
setcolor(8);
rectangle(x_1+5,y_1+5,x_2-5,y_2-5);
rectangle(x_1+6,y_1+6,x_2-6,y_2-6);
rectangle(x_1+7,y_1+7,x_2-7,y_2-7);
}
//----------------------

show_main_screen( )

-------------

void Double_Ended_Linked_list_as_Queue::show_main_screen( )
{

50

cleardevice( );
setcolor(15);
setlinestyle(1,0,3);
rectangle(5,5,getmaxx( )-5,getmaxy( )-5);
setlinestyle(0,0,0);
show_window(5,5,getmaxx( )-5,80);
setfillpattern(fill_pattern,4);
bar(13,13,getmaxx( )-13,72);
settextstyle(2,0,7);
setcolor(0);
outtextxy(18,17,"Implementation of");
outtextxy(18,16,"Implementation of");
setcolor(12);
outtextxy(19,15,"Implementation of");
outtextxy(20,15,"Implementation of");
settextstyle(2,0,9);
setcolor(0);
outtextxy(37,37,"Double Ended Linked List as Queue");
outtextxy(38,37,"Double Ended Linked List as Queue");
outtextxy(38,36,"Double Ended Linked List as Queue");
setcolor(14);
outtextxy(39,35,"Double Ended Linked List as Queue");
outtextxy(40,35,"Double Ended Linked List as Queue");
outtextxy(41,35,"Double Ended Linked List as Queue");
show_window(5,82,305,getmaxy( )-5);
setfillpattern(fill_pattern,9);
bar(14,91,296,getmaxy( )-14);

51

setcolor(6);
setfillstyle(1,6);
pieslice(215,105,0,360,10);
setcolor(2);
setfillstyle(1,2);
pieslice(245,105,0,360,10);
setcolor(4);
setfillstyle(1,4);
pieslice(275,105,0,360,10);
setcolor(7);
circle(215,105,11);
circle(245,105,11);
circle(275,105,11);
show_window(307,82,getmaxx( )-5,getmaxy( )-5);
settextstyle(7,0,4);
setcolor(0);
outtextxy(16,111,"Press:");
setcolor(10);
outtextxy(17,110,"Press:");
outtextxy(18,110,"Press:");
settextstyle(2,0,6);
setcolor(0);
outtextxy(59,151,"<I> to Insert an Element");
outtextxy(59,171,"<D> to Delete an Element");
outtextxy(59,191,"<E> to Exit");
setcolor(14);

52

outtextxy(60,150,"<I> to Insert an Element");


outtextxy(61,150,"<I> to Insert an Element");
outtextxy(60,170,"<D> to Delete an Element");
outtextxy(61,170,"<D> to Delete an Element");
outtextxy(60,190,"<E> to Exit");
outtextxy(61,190,"<E> to Exit");
setfillstyle(2,1);
bar(317,92,getmaxx( )-15,getmaxy( )-15);
}
//---------------------

show_output_screen( )

------------

void Double_Ended_Linked_list_as_Queue::show_output_screen( )
{
for(int count=0;count<=187;count++)
{
setfillstyle(1,0);
bar(317,280,getmaxx( )-15,278-count);
bar(317,280,getmaxx( )-15,278+count);
delay(5);
}
setcolor(12);
settextstyle(2,0,5);
outtextxy(415,405,"Double Ended Linked List");
outtextxy(416,405,"Double Ended Linked List");
outtextxy(560,425,"as Queue");
outtextxy(561,425,"as Queue");

53

setfillstyle(1,6);
bar(414,420,600,422);
bar(560,440,622,442);
setcolor(15);
setlinestyle(0,0,3);
rectangle(330,405,400,435);
setfillstyle(1,9);
bar(346,406,384,434);
setfillstyle(1,1);
bar(331,406,344,434);
bar(386,406,399,434);
setcolor(15);
setlinestyle(0,0,3);
rectangle(345,405,385,435);
setcolor(7);
setlinestyle(0,0,0);
line(337,420,337,460); //Entry->Previous pointing arrow
line(337,460,415,460);
line(412,457,415,460);
line(412,463,415,460);
line(360,428,360,450);

/* Entry->Data pointing arrow */

line(360,450,415,450);
line(412,447,415,450);
line(412,453,415,450);
line(393,420,393,440);

/* Entry->Next pointing arrow */

54

line(393,440,415,440);
line(412,437,415,440);
line(412,443,415,440);
setcolor(15);
setfillstyle(1,15);
pieslice(337,420,0,360,2);
pieslice(393,420,0,360,2);
settextstyle(0,0,1);
setcolor(15);
outtextxy(320,402,"*");
setcolor(9);
settextstyle(2,0,4);
outtextxy(420,454,"Entry->Previous (x=NULL)");
outtextxy(420,442,"Entry->Data");
outtextxy(420,430,"Entry->Next (x=NULL)");
setcolor(11);
settextstyle(0,0,1);
outtextxy(350,417,"0000");
}
//---------------------

show_insert_delete_screen(int)

-----

void Double_Ended_Linked_list_as_Queue::
show_insert_delete_screen(int
NORMAL_WARNING)
{
int x_1;
int x_2;
int y_1;
int y_2;

55

if(NORMAL_WARNING==NORMAL)
{
x_1=20;
x_2=280;
y_1=277;
y_2=350;
}
if(NORMAL_WARNING==WARNING)
{
x_1=20;
x_2=280;
y_1=277;
y_2=367;
}
setcolor(15);
setlinestyle(1,0,3);
rectangle(x_1,y_1,x_2,y_2);
setlinestyle(0,0,0);
setcolor(15);
rectangle(x_1,y_1,x_2,y_2);
setcolor(7);
rectangle(x_1+1,y_1+1,x_2-1,y_2-1);
setcolor(8);
rectangle(x_1+2,y_1+2,x_2-2,y_2-2);
setfillstyle(1,9);
bar(x_1+3,y_1+3,x_2-3,y_2-3);

56

}
//----------------------

show_element_screen(int)

---------

void Double_Ended_Linked_list_as_Queue::
show_element_screen(int
INSERT_DELETE)
{
show_insert_delete_screen(NORMAL);
if(INSERT_DELETE==INSERT)
{
settextstyle(2,0,6);
setcolor(0);
outtextxy(28,281,"Enter the Element :");
setcolor(11);
outtextxy(29,280,"Enter the Element :");
outtextxy(30,280,"Enter the Element :");
}
else if(INSERT_DELETE==DELETE)
{
settextstyle(2,0,6);
setcolor(0);
outtextxy(28,281,"Poped Element is :");
setcolor(11);
outtextxy(29,280,"Poped Element is :");
outtextxy(30,280,"Poped Element is :");
}
delay(300);

57

for(int count=1;count<=65;count++)
{
setcolor(0);
setfillstyle(1,0);
bar(180-count,306,180+count,330);
pieslice(180-count,318,0,360,12);
pieslice(180+count,318,0,360,12);
setcolor(15);
line(180-count,302,180+count,302);
line(180-count,334,180+count,334);
arc(180-count,318,90,270,16);
arc(180+count,318,270,90,16);
setcolor(7);
arc(180-count,318,90,270,15);
arc(180-count,318,90,270,14);
line(180-count,303,180+count,303);
line(180-count,304,180+count,304);
line(180-count,333,180+count,333);
line(180-count,332,180+count,332);
arc(180+count,318,270,90,15);
arc(180+count,318,270,90,14);
setcolor(8);
line(180-count,305,180+count,305);
line(180-count,331,180+count,331);
arc(180-count,318,90,270,13);

58

arc(180+count,318,270,90,13);
delay(4);
}
}
//-------------------

clear_element_screen(int)

-----------

void Double_Ended_Linked_list_as_Queue::
clear_element_screen(int
NORMAL_WARNING)
{
if(NORMAL_WARNING==WARNING)
{
for(int count=1;count<=50;count++)
{
setfillpattern(fill_pattern,9);
bar(18,275,290,275+count);
bar(18,375,290,375-count);
delay(20);
}
}
else if(NORMAL_WARNING==NORMAL)
{
for(int count=1;count<=40;count++)
{
setfillpattern(fill_pattern,9);
bar(18,275,290,275+count);
bar(18,355,290,355-count);
delay(20);
}
}

59

}
//----------------------------

get_element( )

------------

long Double_Ended_Linked_list_as_Queue::get_element( )
{
show_element_screen(INSERT);
int count=0;
char string[6]={'\0'};
do
{
int key_code=0;
char key=NULL;
if(kbhit( ))
key=getch( );
key_code=int(key);
if(key_code>=48 && key_code<=57)
{
string[count]=key;
count++;
}
else if(key_code==8 && count>0)
{
setfillstyle(1,0);
bar(130,306,230,330);
count--;

60

string[count]='\0';
}
else if(key_code==13 && count>0)
break;
setcolor(12);
settextstyle(2,0,7);
moveto(140,305);
outtext(string);
moveto(141,305);
outtext(string);
int x=getx( );
int y=305;
while(!kbhit( ))
{
settextstyle(2,0,7);
setcolor(12);
moveto(x+2,y);
outtext("_");
delay(250);
setcolor(0);
moveto(x+2,y);
outtext("_");
delay(200);
}
}

61

while(count<4);
if(count==4)
while(int(getch( ))!=13);
long element=atol(string);
clear_element_screen(NORMAL);
return element;
}
//-------------------------------

Insert( )

---------------

void Double_Ended_Linked_list_as_Queue::Insert( )
{
long num=get_element( );
for(int count=1;count<5;count++)
{
setcolor(0);
setfillstyle(1,0);
pieslice(215,105,0,360,10);
delay(250);
setcolor(6);
setfillstyle(1,6);
pieslice(215,105,0,360,10);
delay(250);
}
if(inserted_element_count<15)

62

{
setcolor(10);
setfillstyle(1,10);
pieslice(245,105,0,360,10);
sound(1500);
delay(800);
nosound( );
setcolor(2);
setfillstyle(1,2);
pieslice(245,105,0,360,10);
}
if(inserted_element_count==15)
{
setcolor(12);
setfillstyle(1,12);
pieslice(275,105,0,360,10);
sound(2500);
delay(1000);
nosound( );
setcolor(4);
setfillstyle(1,4);
pieslice(275,105,0,360,10);
delay(200);
}
entry=new(node);
entry->next=NULL;
entry->previous=NULL;

63

if(inserted_element_count==15)
{
show_insert_delete_screen(WARNING);
settextstyle(7,0,4);
setcolor(0);
outtextxy(25,277,"Error:");
outtextxy(26,277,"Error:");
setcolor(14);
outtextxy(27,275,"Error:");
outtextxy(28,275,"Error:");
while(!kbhit( ))
{
settextstyle(2,0,8);
setcolor(0);
outtextxy(46,309,"Not enough heap");
outtextxy(47,309,"Not enough heap");
outtextxy(28,335,"space on Screen.");
outtextxy(29,335,"space on Screen.");
setcolor(12);
outtextxy(48,308,"Not enough heap");
outtextxy(49,308,"Not enough heap");
outtextxy(50,308,"Not enough heap");
outtextxy(30,334,"space on Screen.");
outtextxy(31,334,"space on Screen.");
outtextxy(32,334,"space on Screen.");
delay(500);

64

setfillstyle(1,9);
bar(23,315,277,362);
delay(400);
}
getch( );
clear_element_screen(1);
}
else if(rear==NULL)
{
entry->data=num;
rear=entry;
front=rear;
rear->next=NULL;
rear->previous=NULL;
inserted_element_count++;
}
else
{
entry->data=num;
rear->next=entry;
entry->previous=rear;
rear=entry;
rear->next=NULL;
inserted_element_count++;
}
print_linked_list( );

65

}
//----------------------------

Delete( )

------------------

void Double_Ended_Linked_list_as_Queue::Delete( )
{
for(int count=1;count<5;count++)
{
setcolor(0);
setfillstyle(1,0);
pieslice(215,105,0,360,10);
delay(250);
setcolor(6);
setfillstyle(1,6);
pieslice(215,105,0,360,10);
delay(250);
}
if(inserted_element_count==0)
{
setcolor(12);
setfillstyle(1,12);
pieslice(275,105,0,360,10);
sound(2500);
delay(1000);
nosound( );
setcolor(4);
setfillstyle(1,4);
pieslice(275,105,0,360,10);

66

delay(200);
}
else if(inserted_element_count>0)
{
setcolor(10);
setfillstyle(1,10);
pieslice(245,105,0,360,10);
sound(3000);
delay(800);
nosound( );
setcolor(2);
setfillstyle(1,2);
pieslice(245,105,0,360,10);
}
if(front==NULL)
{
show_insert_delete_screen(WARNING);
settextstyle(7,0,4);
setcolor(0);
outtextxy(25,277,"Error:");
outtextxy(26,277,"Error:");
setcolor(14);
outtextxy(27,275,"Error:");
outtextxy(28,275,"Error:");
while(!kbhit( ))
{
settextstyle(6,0,4);

67

setcolor(0);
outtextxy(48,306,"Nothing to Pop");
outtextxy(49,306,"Nothing to Pop");
setcolor(12);
outtextxy(50,305,"Nothing to Pop");
outtextxy(51,305,"Nothing to Pop");
outtextxy(52,305,"Nothing to Pop");
delay(500);
setfillstyle(1,9);
bar(23,315,277,350);
delay(400);
}
getch( );
}
else
{
node *deleted_element;
long poped_data=front->data;
deleted_element=front;
front=front->next;
front->previous=NULL;
delete(deleted_element);
inserted_element_count--;
char element[6]={'\0'};

68

ltoa(poped_data,element,10);
show_element_screen(DELETE);
setcolor(12);
settextstyle(2,0,7);
outtextxy(140,305,element);
outtextxy(141,305,element);
delay(2500);
}
clear_element_screen(DELETE);
print_linked_list( );
}
//-------------------------

print_linked_list( )

----------

void Double_Ended_Linked_list_as_Queue::print_linked_list( )
{
int count=0;
int x=335;
int y=100;
print=front;
setfillstyle(1,0);
bar(317,92,getmaxx( )-15,getmaxy( )-80);
while(print!=NULL)
{
setcolor(15);
setlinestyle(0,0,3);
rectangle(x,y,x+70,y+30);

69

setfillstyle(1,1);
bar(x+1,y+1,x+14,y+29);
setfillstyle(1,9);
bar(x+16,y+1,x+54,y+29);
setfillstyle(1,1);
bar(x+56,y+1,x+69,y+29);
rectangle(x+15,y,x+55,y+30);
char element[6]={'\0'};
ltoa(print->data,element,10);
settextstyle(0,0,1);
setcolor(11);
outtextxy(x+20,y+10,element);
if(count==0 || count==1 || count==2 || count==6 ||
count==7

||

count==8

||

count==12

||

count==13

||

count==14)
{
if(count==0)
{
setcolor(15);
outtextxy(x+4,y+11,"x");
}
if(count==inserted_element_count-1)
{
setcolor(15);
rectangle(x+15,y,x+55,y+30);
outtextxy(x+60,y+11,"x");

70

}
}
else
{
if(count==inserted_element_count-1)
{
setcolor(15);
rectangle(x+15,y,x+55,y+30);
outtextxy(x+4,y+11,"x");
}
}
if(count==1 || count==2 || count==7 || count==8 ||
count==13 || count==14)
{
setcolor(7);
setlinestyle(0,0,3);
line(x-40,y+10,x-2,y+10);
line(x-6,y+6,x-2,y+10);
line(x-6,y+14,x-2,y+10);
line(x-28,y+20,x+7,y+20);
line(x-28,y+20,x-24,y+16);
line(x-28,y+20,x-24,y+24);
setcolor(15);
setfillstyle(1,15);
pieslice(x-37,y+10,0,360,2);
pieslice(x+7,y+20,0,360,2);
}
else

if(count==4

||

count==5

||

count==10

||

count==11)
{

71

setcolor(7);
setlinestyle(0,0,3);
line(x+64,y+10,x+98,y+10);
line(x+94,y+6,x+98,y+10);
line(x+94,y+14,x+98,y+10);
line(x+72,y+20,x+107,y+20);
line(x+72,y+20,x+76,y+16);
line(x+72,y+20,x+76,y+24);
setcolor(15);
setfillstyle(1,15);
pieslice(x+63,y+10,0,360,2);
pieslice(x+107,y+20,0,360,2);
}
else if(count==3 || count==9)
{
setcolor(7);
setlinestyle(0,0,3);
line(x+60,y-50,x+80,y-50);
line(x+80,y-50,x+80,y+20);
line(x+72,y+20,x+80,y+20);
line(x+72,y+20,x+76,y+16);
line(x+72,y+20,x+76,y+24);
line(x+63,y-30,x+63,y+10);
line(x+63,y-28,x+59,y-24);
line(x+63,y-28,x+67,y-24);

72

setcolor(15);
setfillstyle(1,15);
pieslice(x+63,y+10,0,360,2);
pieslice(x+63,y-50,0,360,2);
}
else if(count==6 || count==12)
{
setcolor(7);
setlinestyle(0,0,3);
line(x-15,y-50,x+10,y-50);
line(x-15,y-50,x-15,y+20);
line(x-15,y+20,x,y+20);
line(x-2,y+20,x-6,y+16);
line(x-2,y+20,x-6,y+24);
line(x+7,y-30,x+7,y+10);
line(x+3,y-24,x+7,y-28);
line(x+11,y-24,x+7,y-28);
setcolor(15);
setfillstyle(1,15);
pieslice(x+7,y+10,0,360,2);
pieslice(x+7,y-50,0,360,2);
}
setcolor(7);
setlinestyle(0,0,3);
line(360,125,360,138);

/* Front Arrow */

line(356,134,360,138);
line(364,134,360,138);
setcolor(14);

73

settextstyle(2,0,4);
outtextxy(338,140,"front");
if(count==inserted_element_count-1)
{
setcolor(7);
setlinestyle(0,0,3);
line(x+40,y+25,x+40,y+38);
line(x+36,y+34,x+40,y+38);
line(x+44,y+34,x+40,y+38);
setcolor(14);
settextstyle(2,0,4);
outtextxy(x+38,y+40,"rear");
}
print=print->next;
count++;
if(count==0 || count==1 || count==2 || count==6 ||
count==7

||

count==8

||

count==12

||

count==13

||

count==14)
x+=100;
else if(count==3 || count==4 || count==5 || count==9
|| count==10 ||

count==11)

x-=100;
if(count==3 || count==9)
{
x=535;
y+=60;
}
else if(count==6 || count==12)
{
x=335;

74

y+=60;
}
if(count==15)
break;
}
setlinestyle(0,0,0);
}
//------------------------

waiting_for_input( )

-----------

void Double_Ended_Linked_list_as_Queue::waiting_for_input( )
{
do
{
setfillstyle(1,4);
bar(51,440,99,445);
setfillstyle(1,10);
bar(101,440,149,445);
setfillstyle(1,11);
bar(151,440,199,445);
setfillstyle(1,14);
bar(201,440,249,445);
delay(300);
setfillpattern(fill_pattern,9);
bar(51,440,99,445);
delay(150);

75

bar(101,440,149,445);
delay(150);
bar(151,440,199,445);
delay(150);
bar(201,440,249,445);
delay(150);
setfillstyle(1,4);
bar(51,440,99,445);
delay(150);
setfillstyle(1,10);
bar(101,440,149,445);
delay(150);
setfillstyle(1,11);
bar(151,440,199,445);
delay(150);
setfillstyle(1,14);
bar(201,440,249,445);
}
while(!kbhit( ));
setfillpattern(fill_pattern,9);
bar(51,440,249,445);
}
//---------------------------

show_working( )

-------------

void Double_Ended_Linked_list_as_Queue::show_working( )
{
show_main_screen( );
delay(1000);
show_output_screen( );
char ch;
int selected=0;
do

76

{
waiting_for_input( );
ch=getch( );
switch(ch)
{
case 'i': Insert( );
break;
case 'I': Insert( );
break;
case 'd': Delete( );
break;
case 'D': Delete( );
break;
case 'e': selected=1;
break;
case 'E': selected=1;
break;
}
}
while(!selected && int(ch)!=27);
delay(500);
}
//------------------------------------------------------------

//----------------------

CLASS DEFINITION

-----------------

class Linked_list_Queue

77

{
private:
char fill_pattern[8];
int inserted_element_count;
struct node
{
long data;
node *next;
};
node *rear;
node *entry;
node *print;
node *front;
public:
Linked_list_Queue( );
long get_element( );
void Delete( );
void Insert( );
void print_linked_list( );
void show_working( );
void show_main_screen( );
void waiting_for_input( );
void show_element_screen(int);
void clear_element_screen(int);
void show_linked_list_screen( );
void show_output_screen(int);
void show_window(int,int,int,int);
};

78

//--------------------//----------------------

FUNCTION DEFINITIONS
Linked_list_Queue( )

--------------------------

Linked_list_Queue::Linked_list_Queue ( )
{
rear=NULL;
front=NULL;
inserted_element_count=0;
fill_pattern[0]=0xAA;
fill_pattern[1]=0x55;
fill_pattern[2]=0xAA;
fill_pattern[3]=0x55;
fill_pattern[4]=0xAA;
fill_pattern[5]=0x55;
fill_pattern[6]=0xAA;
fill_pattern[7]=0x55;
}

//--------------------

show_window(int,int,int,int)

-------

void Linked_list_Queue::show_window(int x_1,int y_1,int x_2,int


y_2)
{
setcolor(15);
rectangle(x_1,y_1,x_2,y_2);
rectangle(x_1+1,y_1+1,x_2-1,y_2-1);

79

setcolor(7);
rectangle(x_1+2,y_1+2,x_2-2,y_2-2);
rectangle(x_1+3,y_1+3,x_2-3,y_2-3);
rectangle(x_1+4,y_1+4,x_2-4,y_2-4);
setcolor(8);
rectangle(x_1+5,y_1+5,x_2-5,y_2-5);
rectangle(x_1+6,y_1+6,x_2-6,y_2-6);
rectangle(x_1+7,y_1+7,x_2-7,y_2-7);
}
//----------------------

show_main_screen( )

--------------

void Linked_list_Queue ::show_main_screen( )


{
setcolor(15);
setlinestyle(1,0,3);
rectangle(5,5,getmaxx( )-5,getmaxy( )-5);
setlinestyle(0,0,0);
show_window(5,5,getmaxx( )-5,80);
setfillpattern(fill_pattern,4);
bar(13,13,getmaxx( )-13,72);
settextstyle(3,0,4);
setcolor(0);
outtextxy(17,22,"Implementation of Linked List as Queue");
outtextxy(18,22,"Implementation

of

Linked

List

as

Queue");
setcolor(14);
outtextxy(19,20,"Implementation of Linked List as Queue");

80

outtextxy(20,20,"Implementation

of

Linked

List

as

of

Linked

List

as

Queue");
outtextxy(21,20,"Implementation
Queue");
show_window(5,82,305,getmaxy( )-5);
setfillpattern(fill_pattern,9);
bar(14,91,296,getmaxy( )-14);
setcolor(6);
setfillstyle(1,6);
pieslice(215,105,0,360,10);
setcolor(2);
setfillstyle(1,2);
pieslice(245,105,0,360,10);
setcolor(4);
setfillstyle(1,4);
pieslice(275,105,0,360,10);
setcolor(7);
circle(215,105,11);
circle(245,105,11);
circle(275,105,11);
show_window(307,82,getmaxx( )-5,getmaxy( )-5);
settextstyle(7,0,4);
setcolor(0);
outtextxy(16,111,"Press:");
setcolor(10);

81

outtextxy(17,110,"Press:");
outtextxy(18,110,"Press:");
settextstyle(2,0,6);
setcolor(0);
outtextxy(59,151,"<I> to Insert an Element");
outtextxy(59,171,"<D> to Delete an Element");
outtextxy(59,191,"<E> to Exit");
setcolor(14);
outtextxy(60,150,"<I> to Insert an Element");
outtextxy(61,150,"<I> to Insert an Element");
outtextxy(60,170,"<D> to Delete an Element");
outtextxy(61,170,"<D> to Delete an Element");
outtextxy(60,190,"<E> to Exit");
outtextxy(61,190,"<E> to Exit");
setfillstyle(2,1);
bar(317,92,getmaxx( )-15,getmaxy( )-15);
}
//---------------------

show_linked_list_screen( )

---------

void Linked_list_Queue::show_linked_list_screen( )
{
for(int count=0;count<=187;count++)
{
setfillstyle(1,0);
bar(317,280,getmaxx( )-15,278-count);
bar(317,280,getmaxx( )-15,278+count);
delay(5);

82

}
setcolor(12);
settextstyle(2,0,7);
outtextxy(405,400,"Linked List (Queue)");
outtextxy(406,400,"Linked List (Queue)");
outtextxy(407,400,"Linked List (Queue)");
setfillstyle(1,6);
bar(402,420,618,422);
setcolor(15);
setlinestyle(0,0,3);
rectangle(330,405,390,435);
setfillstyle(1,9);
bar(331,406,374,434);
setfillstyle(1,1);
bar(376,406,389,434);
line(375,405,375,435);
setcolor(7);
setlinestyle(0,0,0);
line(352,425,352,455);

/* Entry->Data pointing arrow */

line(352,455,415,455);
line(412,452,415,455);
line(412,458,415,455);
line(382,423,382,443);

/* Entry->Next pointing arrow */

line(382,443,415,443);
line(412,440,415,443);

83

line(412,446,415,443);
setfillstyle(1,15);
pieslice(382,420,0,360,2);
settextstyle(0,0,1);
setcolor(15);
outtextxy(320,402,"*");
setcolor(9);
outtextxy(420,452,"Entry->Data");
outtextxy(420,438,"Entry->Next (x=NULL)");
setcolor(11);
outtextxy(333,417,"00000");
}

//-----------------------

show_output_screen(int)

---------

Void Linked_list_Queue::show_output_screen(int NORMAL_WARNING)


{
int x_1;
int x_2;
int y_1;
int y_2;
if(NORMAL_WARNING==NORMAL)
{
x_1=20;
x_2=280;
y_1=277;
y_2=350;
}
if(NORMAL_WARNING==WARNING)

84

{
x_1=20;
x_2=280;
y_1=277;
y_2=367;
}
setcolor(15);
setlinestyle(1,0,3);
rectangle(x_1,y_1,x_2,y_2);
setlinestyle(0,0,0);
setcolor(15);
rectangle(x_1,y_1,x_2,y_2);
setcolor(7);
rectangle(x_1+1,y_1+1,x_2-1,y_2-1);
setcolor(8);
rectangle(x_1+2,y_1+2,x_2-2,y_2-2);
setfillstyle(1,9);
bar(x_1+3,y_1+3,x_2-3,y_2-3);
}
//----------------------

show_element_screen(int)

---------

Void Linked_list_Queue::show_element_screen(int INSERT_DELETE)


{
show_output_screen(NORMAL);
if(INSERT_DELETE==INSERT)
{
settextstyle(2,0,6);
setcolor(0);
outtextxy(28,281,"Enter the Element :");

85

setcolor(11);
outtextxy(29,280,"Enter the Element :");
outtextxy(30,280,"Enter the Element :");
}
else if(INSERT_DELETE==DELETE)
{
settextstyle(2,0,6);
setcolor(0);
outtextxy(28,281,"Deleted Element is :");
setcolor(11);
outtextxy(29,280,"Deleted Element is :");
outtextxy(30,280,"Deleted Element is :");
}
delay(300);
for(int count=1;count<=65;count++)
{
setcolor(0);
setfillstyle(1,0);
bar(180-count,306,180+count,330);
pieslice(180-count,318,0,360,12);
pieslice(180+count,318,0,360,12);
setcolor(15);
line(180-count,302,180+count,302);
line(180-count,334,180+count,334);
arc(180-count,318,90,270,16);
arc(180+count,318,270,90,16);
setcolor(7);
arc(180-count,318,90,270,15);

86

arc(180-count,318,90,270,14);
line(180-count,303,180+count,303);
line(180-count,304,180+count,304);
line(180-count,333,180+count,333);
line(180-count,332,180+count,332);
arc(180+count,318,270,90,15);
arc(180+count,318,270,90,14);
setcolor(8);
line(180-count,305,180+count,305);
line(180-count,331,180+count,331);
arc(180-count,318,90,270,13);
arc(180+count,318,270,90,13);
delay(4);
}
}
//-------------------

clear_element_screen(int)

-----------

Void Linked_list_Queue::clear_element_screen(int NORMAL_WARNING)


{
if(NORMAL_WARNING==WARNING)
{
for(int count=1;count<=50;count++)
{
setfillpattern(fill_pattern,9);
bar(18,275,290,275+count);
bar(18,375,290,375-count);
delay(20);

87

}
}
else if(NORMAL_WARNING==NORMAL)
{
for(int count=1;count<=40;count++)
{
setfillpattern(fill_pattern,9);
bar(18,275,290,275+count);
bar(18,355,290,355-count);
delay(20);
}
}
}
//----------------------------

get_element( )

-------------

long Linked_list_Queue::get_element( )
{
show_element_screen(INSERT);
int count=0;
char string[6]={'\0'};
do
{
int key_code=0;
char key=NULL;
if(kbhit( ))
key=getch( );
key_code=int(key);

88

if(key_code>=48 && key_code<=57)


{
string[count]=key;
count++;
}
else if(key_code==8 && count>0)
{
setfillstyle(1,0);
bar(130,306,230,330);
count--;
string[count]='\0';
}
else if(key_code==13 && count>0)
break;
setcolor(12);
settextstyle(2,0,7);
moveto(140,305);
outtext(string);
moveto(141,305);
outtext(string);
int x=getx( );
int y=305;
while(!kbhit( ))
{
settextstyle(2,0,7);
setcolor(12);
moveto(x+2,y);

89

outtext("_");
delay(250);
setcolor(0);
moveto(x+2,y);
outtext("_");
delay(200);
}
}
while(count<5);
if(count==5)
while(int(getch( ))!=13);
long element=atol(string);
clear_element_screen(NORMAL);
return element;
}
//-----------------------------

Insert( )

------------------

void Linked_list_Queue::Insert( )
{
long num=get_element( );
for(int count=1;count<5;count++)
{
setcolor(0);
setfillstyle(1,0);
pieslice(215,105,0,360,10);
delay(250);
setcolor(6);
setfillstyle(1,6);
pieslice(215,105,0,360,10);
delay(300);
}

90

if(inserted_element_count<15)
{
setcolor(10);
setfillstyle(1,10);
pieslice(245,105,0,360,10);
sound(1500);
delay(800);
nosound( );
setcolor(2);
setfillstyle(1,2);
pieslice(245,105,0,360,10);
}
if(inserted_element_count==15)
{
setcolor(12);
setfillstyle(1,12);
pieslice(275,105,0,360,10);
sound(2500);
delay(1000);
nosound( );
setcolor(4);
setfillstyle(1,4);
pieslice(275,105,0,360,10);
delay(200);
}
entry=new(node);
if(inserted_element_count==15)

91

{
show_output_screen(WARNING);
settextstyle(7,0,4);
setcolor(0);
outtextxy(25,277,"Error:");
outtextxy(26,277,"Error:");
setcolor(14);
outtextxy(27,275,"Error:");
outtextxy(28,275,"Error:");
while(!kbhit( ))
{
settextstyle(2,0,8);
setcolor(0);
outtextxy(46,309,"Not enough heap");
outtextxy(47,309,"Not enough heap");
outtextxy(28,335,"space on Screen.");
outtextxy(29,335,"space on Screen.");
setcolor(12);
outtextxy(48,308,"Not enough heap");
outtextxy(49,308,"Not enough heap");
outtextxy(50,308,"Not enough heap");
outtextxy(30,334,"space on Screen.");
outtextxy(31,334,"space on Screen.");
outtextxy(32,334,"space on Screen.");
delay(500);
setfillstyle(1,9);
bar(23,315,277,362);
delay(400);

92

}
getch( );
clear_element_screen(1);
}
else if(rear==NULL)
{
entry->data=num;
entry->next=NULL;
rear=entry;
front=rear;
inserted_element_count++;
}
else
{
entry->data=num;
entry->next=NULL;
rear->next=entry;
rear=entry;
inserted_element_count++;
}
print_linked_list( );
}
//---------------------------

Delete( )

-------------------

void Linked_list_Queue::Delete( )
{
for(int count=1;count<5;count++)
{
setcolor(0);
setfillstyle(1,0);
pieslice(215,105,0,360,10);
delay(250);

93

setcolor(6);
setfillstyle(1,6);
pieslice(215,105,0,360,10);
delay(300);
}
if(inserted_element_count==0)
{
setcolor(12);
setfillstyle(1,12);
pieslice(275,105,0,360,10);
sound(2500);
delay(1000);
nosound( );
setcolor(4);
setfillstyle(1,4);
pieslice(275,105,0,360,10);
delay(200);
}
else if(inserted_element_count>0)
{
setcolor(10);
setfillstyle(1,10);
pieslice(245,105,0,360,10);
sound(3000);
delay(800);
nosound( );
setcolor(2);
setfillstyle(1,2);
pieslice(245,105,0,360,10);
}

94

if(front==NULL)
{
show_output_screen(WARNING);
settextstyle(7,0,4);
setcolor(0);
outtextxy(25,277,"Error:");
outtextxy(26,277,"Error:");
setcolor(14);
outtextxy(27,275,"Error:");
outtextxy(28,275,"Error:");
while(!kbhit( ))
{
settextstyle(6,0,4);
setcolor(0);
outtextxy(48,306,"Nothing to Delete");
outtextxy(49,306,"Nothing to Delete");
setcolor(12);
outtextxy(50,305,"Nothing to Delete");
outtextxy(51,305,"Nothing to Delete");
outtextxy(52,305,"Nothing to Delete");
delay(500);
setfillstyle(1,9);
bar(23,315,277,350);
delay(400);
}
getch( );
}
else
{
long Deleted_element=front->data;
node *temp;

95

temp=front;
front=front->next;
inserted_element_count--;
delete (temp);
char element[6]={'\0'};
ltoa(Deleted_element,element,10);
show_element_screen(DELETE);
setcolor(12);
settextstyle(2,0,7);
outtextxy(140,305,element);
outtextxy(141,305,element);
delay(2500);
}
clear_element_screen(DELETE);
print_linked_list( );
}
//-----------------------

print_linked_list( )

------------

void Linked_list_Queue::print_linked_list( )
{
int count=0;
int x=340;
int y=100;
print=front;
setfillstyle(1,0);
bar(317,92,getmaxx( )-15,getmaxy( )-80);
while(print!=NULL)
{
setcolor(15);
setlinestyle(0,0,3);
rectangle(x,y,x+60,y+30);
char element[6]={'\0'};
ltoa(print->data,element,10);

96

if(count==0 || count==1 || count==2 || count==6 ||


count==7

||

count==8

||

count==12

||

count==13

||

count==14)
{
setfillstyle(1,9);
bar(x+1,y+1,x+44,y+29);
setfillstyle(1,1);
bar(x+46,y+1,x+59,y+29);
setcolor(15);
line(x+45,y,x+45,y+30);
setcolor(11);
settextstyle(0,0,1);
outtextxy(x+3,y+10,element);
if(count==inserted_element_count-1)
{
setcolor(15);
outtextxy(x+50,y+11,"x");
}
}
else
{
setfillstyle(1,9);
bar(x+16,y+1,x+59,y+29);
setfillstyle(1,1);
bar(x+1,y+1,x+14,y+29);
setcolor(15);
line(x+15,y,x+15,y+30);
setcolor(11);
settextstyle(0,0,1);
outtextxy(x+18,y+10,element);

97

if(count==inserted_element_count-1)
{
setcolor(15);
outtextxy(x+4,y+11,"x");
}
}
if(count==1 || count==2 || count==7 || count==8 ||
count==13 || count==14)
{
setcolor(15);
line(x-45,y+15,x,y+15);
setfillstyle(1,15);
pieslice(x-47,y+15,0,360,2);
line(x-6,y+11,x-2,y+15);
line(x-6,y+19,x-2,y+15);
}
else

if(count==4

||

count==5

||

count==10

||

count==11)
{
setcolor(15);
line(x+60,y+15,x+105,y+15);
setfillstyle(1,15);
pieslice(x+107,y+15,0,360,2);
line(x+66,y+11,x+62,y+15);
line(x+66,y+19,x+62,y+15);
}
else if(count==3 || count==9)
{
setcolor(15);
setfillstyle(1,15);
pieslice(x+53,y-45,0,360,2);

98

setlinestyle(0,0,3);
line(x+55,y-45,x+75,y-45);
line(x+75,y-45,x+75,y+15);
line(x+60,y+15,x+75,y+15);
line(x+62,y+15,x+66,y+11);
line(x+62,y+15,x+66,y+19);
}
else if(count==6 || count==12)
{
setcolor(15);
setfillstyle(1,15);
pieslice(x+7,y-45,0,360,2);
setlinestyle(0,0,3);
line(x-15,y-45,x+10,y-45);
line(x-15,y-45,x-15,y+15);
line(x-15,y+15,x,y+15);
line(x-2,y+15,x-6,y+11);
line(x-2,y+15,x-6,y+19);
}
setcolor(7);
setlinestyle(0,0,3);
line(350,125,350,138);

/* Bottom Arrow */

line(346,134,350,138);
line(354,134,350,138);
setcolor(14);
settextstyle(2,0,4);
outtextxy(332,140,"Front");

99

if(count==inserted_element_count-1)
{
setcolor(7);
setlinestyle(0,0,3);
line(x+30,y+25,x+30,y+38);
line(x+26,y+34,x+30,y+38);
line(x+34,y+34,x+30,y+38);
setcolor(14);
settextstyle(2,0,4);
outtextxy(x+30,y+40,"Rear");
}
print=print->next;
count++;
if(count==0 || count==1 || count==2 || count==6 || count==7
|| count==8 || count==12 || count==13 || count==14)
x+=100;
else if(count==3 || count==4 || count==5 || count==9
|| count==10 ||

count==11)

x-=100;
if(count==3 || count==9)
{
x=540;
y+=60;
}
else if(count==6 || count==12)
{
x=340;
y+=60;
}
if(count==15)
break;
}

100

setlinestyle(0,0,0);
}
//------------------------

waiting_for_input( )

-----------

void Linked_list_Queue ::waiting_for_input( )


{
do
{
setfillstyle(1,4);
bar(51,440,99,445);
setfillstyle(1,10);
bar(101,440,149,445);
setfillstyle(1,1);
bar(151,440,199,445);
setfillstyle(1,14);
bar(201,440,249,445);
delay(300);
setfillpattern(fill_pattern,9);
bar(51,440,99,445);
delay(150);
bar(101,440,149,445);
delay(150);
bar(151,440,199,445);
delay(150);
bar(201,440,249,445);
delay(150);
setfillstyle(1,4);
bar(51,440,99,445);
delay(150);
setfillstyle(1,10);
bar(101,440,149,445);
delay(150);
setfillstyle(1,1);

101

bar(151,440,199,445);
delay(150);
setfillstyle(1,14);
bar(201,440,249,445);
}
while(!kbhit( ));
setfillpattern(fill_pattern,9);
bar(51,440,249,445);
}
//---------------------------

show_working( )

-------------

void Linked_list_Queue ::show_working( )


{
show_main_screen( );
delay(1000);
show_linked_list_screen( );
char ch;
do
{
waiting_for_input( );
ch=getch( );
switch(ch)
{
case 'i': Insert( );
break;
case 'I': Insert( );
break;
case 'd': Delete( );
break;
case 'D': Delete( );
break;

102

case 'e': delay(500);


cleardevice();
ch=27;
case 'E': delay(500);
cleardevice();
ch=27;
}
} while((int)ch!=27);
}
class skstack
{ private:
struct stack
{
int top;
int items[size];
char s2[STSIZE];
}s;
struct node
{
int info;
struct node *next;
}*top;
typedef struct node *NODEPTR;
NODEPTR s1;
public:
void lpush(NODEPTR *,int);
void ldisplay(NODEPTR *);
void ldisplay1(NODEPTR *);
int empty1(NODEPTR *);
int empty(struct stack *);

103

char stacktop(struct stack *);


void lpop(NODEPTR *);
void button(int,int,int,int,char[]);
void buttonon(int,int,int,int);
void buttonoff(int,int,int,int);
void closebyslash();
void closebyslash1();
void stack(void);
void push(struct stack *,int);
int pop(struct stack *);
void display(struct stack *);
void display1(struct stack *);
void rdisplay(struct stack *);
void esolve();
void call();
void edisplay(struct stack *);
void edisplay1(struct stack *);
void gotorc(int,int);
void dis(int,int);
void closebyline();
void push1(struct stack *,char);
char pop1(struct stack *);
void display2(struct stack *);
void linklist();
NODEPTR getnode();
void freenode(NODEPTR);
}sk;
//Fourth window for select the Implementation & Application
void screen1(int c)
{
int n,d;
while(1)
{
switch(c)

104

{
case 1 : setbkcolor(BLUE);
cleardevice();
settextstyle(1,0,3);
outtextxy(160,50," IMPLIMENTATION OF LINKED LIST");
setcolor(GREEN);
outtextxy(140,110,"1 : LINKED LIST AS STACK");
outtextxy(140,150,"2 : LINKED LIST AS QUEUE");
outtextxy(140,190,"3 : Double Ended LINKED LIST
AS STACK");
outtextxy(140,230,"4 : Double Ended LINKED LIST
AS QUEUE");
outtextxy(140,270,"5 : EXIT");
setcolor(4);
settextstyle(7,0,2);
outtextxy(180,350,"ENTER THE CHOICE. . .");
cin>>n;
switch(n)
{
case 1 :
Linked_list_Stack

obj0;

obj0.show_working( );
break;
case 2 :
Linked_list_Queue

obj;

obj.show_working( );
break;
case 3 :
Double_ended_Linked_list_as_Stack

obj1;

obj1.show_working( );
break;
case 4 :
Double_Ended_Linked_list_as_Queue

obj2;

obj2.show_working( );

105

break;
case 5 : cleardevice();
screen();
break;
default:
outtextxy(160,370,"Enter Number Between 1 to 5");
delay(1000);
cleardevice();
}
break;
case 3 : cleardevice();
setcolor(YELLOW);
settextstyle(8,0,6);
setbkcolor(6);
outtextxy(150,200,"THANK YOU");
delay(2000);
exit(1);
break;
}
}
}
/* thied window in button is used */
void screen()
{
settextstyle(3,0,4);
setcolor(YELLOW);
setbkcolor(7);
outtextxy(90,30,"IMPLEMENTATION

");

outtextxy(210,80," OF LINKED LIST");


setcolor(7);
settextstyle(1,0,2);
sk.button(190,150,230,50," IMPLIMENTATION");
sk.buttonon(190,150,230,50);
sk.button(250,350,100,50," EXIT");

106

int no=0,but=1;
while(no==0)
{
no=getch();
switch(no)
{
case 80 :
no=0;
switch(but)
{
case 3:
sk.buttonoff(250,350,100,50);//3
but=1;
break;
case 2:
sk.buttonon(250,350,100,50);//3
but=3;
break;
case 1:
sk.buttonoff(190,150,230,50);//1
but=2;
break;
}
break;
case 72 :
no=0;
switch(but)
{
case 1:
sk.buttonoff(190,150,230,50);//1
sk.buttonon(250,350,100,50);//3
but=3;
break;

107

case 2:
sk.buttonon(190,150,230,50);//1
but=1;
break;
case 3:
sk.buttonoff(250,350,100,50);//3
but=2;
break;
}
break;
case 13 : no=but;
}
}
sk.closebyslash();
screen1(no);
}
void main()
{
int gd=DETECT,gm,x,y,c;
initgraph(&gd,&gm,"..\\bgi");
x=getmaxx();
y=getmaxy();
/*

first window */

rectangle(0,0,x,y);
setcolor(GREEN);
settextstyle(7,0,8);
outtextxy(130,50,"WELLCOME");
outtextxy(230,170,"TO");
outtextxy(160,280,"PROJECT");
delay(2500);
sk.closebyline();
setcolor(GREEN);
/* second window */
rectangle(0,0,getmaxx(),getmaxy());

108

setcolor(RED);
settextstyle(1,0,6);
outtextxy(160,30,"PROJECT BY");
setcolor(YELLOW);
settextstyle(1,0,4);
outtextxy(150,140,"MR.Avinash Kumar Sinha");
setcolor(GREEN);
settextstyle(1,0,4);
outtextxy(120,230,"UNDER GUIDENCE OF");
outtextxy(200,270,"MRS. Shivangi Patil");
settextstyle(3,0,5);
setcolor(6);
outtextxy(300,350,"FROM");
setcolor(6);
outtextxy(400,400,"MCA(I)");
delay(3000);
cleardevice();
setbkcolor(7);
settextstyle(1,0,2);
textcolor(3);
screen();
getch();
restorecrtmode();
closegraph();
}
/* standered operation of stack */
void skstack::stack(void)
{
int p,z,n,temp;
char a[10];
s.top=-1;
rectangle(0,0,getmaxx(),getmaxy());
do
{

109

sk.gotorc(1,2);
cout<<"ENTER

THE

CHOICE

FOR

PUSH,2

FOR

POP

AND

FOR

EXIT"<<endl;
sk.gotorc(2,2);
cin>>n;
switch(n)
{
case 1:setbkcolor(BLACK);
settextstyle(1,0,2);
cout<<"ENTER THE NUMBER FOR PUSH IN STACK"<<endl;
cin>>p;
sk.push(&s,p);
cleardevice();
sk.display(&s);
break;
case 2:cout<<"THE NUMBER WHICH IS POPED" ;
cleardevice();
temp=sk.pop(&s);
setcolor(GREEN);
outtextxy(10,40,"THE POPED ELEMENT IS");
itoa(temp,a,10);
outtextxy(10,55,a);
sk.display1(&s);
break;
case 3:cleardevice();
}
}
while(n!=3);
}

110

5.2 INPUT AND OUTPUT DESIGNS


SCREEN DESIGN

WELCOME WINDOW

111

112

113

114

115

116

117

118

119

120

121

122

123

124

125

126

127

128

129

130

131

132

133

134

135

Chapter No.6

User Manual

136

User manual
How to use application?
Step1:
First run .exe file of the application. After running .exe file you will see the
welcome screen and developer screen one after another.
Step2:
Now press any key to continue. After pressing the key current window will close
and you will see menu of the of the application.
Step3:
To select any method of the application click left mouse button on that particular
button and if you want get an help of that particular method click right mouse button of
that button.
Step4:
After performing particular method press any key to go back to the menu.
Step5:
Click on the exit button to get an exit from the application.

137

Chapter No.7

CONCLUSIONS

138

7.1 Scope
1.
2.
3.
4.

It can be useful for performing stack and queue using linked list.
This application is simple to use and easy to understand.
It enables user to easily understand complicated diagrams.
Use of switch cases makes it user friendly.

7.2 Limitations
1. The system can done only two types of linked list like stack & queue.
2. User can not enter elements more than 10 . System will restricted user to input
only 10 elements so that animation can be well fitted to screen and resolution.
3. The system is purely based on graphical interface and will not maintaining any
files that can be used for storing purpose.
There are few limits otherwise; the system is satisfactory, easily
understandable and attractive one.

139

Chapter No. 8

Bibliography

140

Bibliography

Advanced Graphics Programming Programming Using C/C++.

C++ Complete Reference Herbert Schildt

Object Oriented Programming with C++ - E. Balgurusami

TURBOC3 HELPS MENU.

141