dspm+lab+manual+june dec+2011 (1)

59
GGS COLLEGE OF MODERN TECHNOLOGY, KHARAR DSPM Lab GGS College of Modern Technology, Kharar (Mohali)-Punjab (Approved by AICTE & Affiliated to Punjab Technical University, Jalandhar) PRACTICAL FILE CSE/IT DEPARTMENT GGS COLLEGE OF MODERN TECHNOLOGY, KHARAR Approved by AICTE& Affiliated to PTU, Jalandhar 1

Upload: gurvinder-singh

Post on 24-Aug-2014

116 views

Category:

Documents


3 download

TRANSCRIPT

Page 1: DSPM+Lab+Manual+June Dec+2011 (1)

GGS COLLEGE OF MODERN TECHNOLOGY, KHARAR DSPM Lab

GGS College of Modern Technology,

Kharar (Mohali)-Punjab

(Approved by AICTE & Affiliated to Punjab Technical University, Jalandhar)

PRACTICAL FILECSE/IT DEPARTMENT

GGS COLLEGE OF MODERN TECHNOLOGY, KHARAR

Approved by AICTE& Affiliated to PTU, Jalandhar

1

Page 2: DSPM+Lab+Manual+June Dec+2011 (1)

GGS COLLEGE OF MODERN TECHNOLOGY, KHARAR DSPM Lab

CSE/IT DEPARTMENT

LABORATORY REPORT(DSPM LAB)

NAME OF STUDENT______________________ROLL NO._______________________________SEMESTER _____________________________SESSION ________________________________

STUDENT SIGNATURE__________

FACULTY SIGNATURE_______

2

Page 3: DSPM+Lab+Manual+June Dec+2011 (1)

GGS COLLEGE OF MODERN TECHNOLOGY, KHARAR DSPM Lab

COURSE OBJECTIVE This Guide is designed for helping the students to perform better in various practical

courses. It describes the structure of a good laboratory report, outlines the different sections of the report and explains the need for each of them. It also introduces some standard conventions and rules for writing reports of professional quality. The quality of your written report will strongly affect your grade for the course.

EVALUATION OF PRACTICAL WORK

Each student will be required to perform the experiment individually. Student will be required to write theory, algorithm, program, outputs etc.

during practical session itself. Each experiment will be marked by the teacher on the basis of experiment

performed and write up on the same day. These marks will account for 40% of the sessional marks.

Sessional marks will also include VIVA and Attendance marks as per rules.

GOOD LABORATORY PRACTICES

You must develop good laboratory habits by keeping complete laboratory note books.

Keep all your notes about the laboratory procedures and data in this notebook in pen.

It is always better to read experiment in advance. The expectation is that you will work individually on separate computers. Each

of you will write a separate report. Please bring your laboratory manual to the lab on every turn.

3

Page 4: DSPM+Lab+Manual+June Dec+2011 (1)

GGS COLLEGE OF MODERN TECHNOLOGY, KHARAR DSPM Lab

THINGS TO DO AND DON’T DO IN THE LABORATORY

DO’S

Remember this is a practice laboratory & keep silence. Sit down in proper manner. Laboratory instructor can help to access software and printer. If require more in depth help you can concern lecturer. Proper shut down the computer system before leaving the laboratory. Exit laboratory quickly, if short circuit or any emergency occurs.

DON’T

Write anything on the furniture. Delete or change other student’s file. Uninstall the software. Create, change or remove any password. Play computer games.

List of Experiments

4

Page 5: DSPM+Lab+Manual+June Dec+2011 (1)

GGS COLLEGE OF MODERN TECHNOLOGY, KHARAR DSPM Lab

Sr. No.

List of Experiments Date of performance

Teacher’s signature

Marks

1 Write a program in C++ to traversing an array

2 Write a program in C++ for inserting an array.

3 Write a program in C++ for deleting an array.

4 Write a program in C++ for linear search.

5 Write a program in C++ for binary search.

6 Write a program in C++ for bubble sort.

7 Write a program in C++ to push the elements into stack.

8 Write a program in C++ to pop an element from stack.

9 Write a program in C++ to sort a list using selection sort.

10 Write a program in C++ to sort a list using insertion sort.

11 Write a program in C++ to insert an element into a queue.

AIM Write a program in C++ to Traversing an Array.

5

Page 6: DSPM+Lab+Manual+June Dec+2011 (1)

GGS COLLEGE OF MODERN TECHNOLOGY, KHARAR DSPM Lab

Experiment No 1 Date__/__/_____

#include<iostream.h>

#include<iomanip.h>

#include<conio.h>

void main()

{

void print(long []);

long profit[5]={400000,250000,450000,500000,5500000};

clrscr();

print(profit);

getch();

}

void print(long profit[])

{

int str_year=1950;

cout<<"year"<<setw(15)<<" profit"<<endl;

cout<<"................"<<endl<<endl;

for(int i=0;i<5;i++)

6

Page 7: DSPM+Lab+Manual+June Dec+2011 (1)

GGS COLLEGE OF MODERN TECHNOLOGY, KHARAR DSPM Labcout<<str_year+i<<setw(15)<<profit[i]<<endl;

}

7

Page 8: DSPM+Lab+Manual+June Dec+2011 (1)

GGS COLLEGE OF MODERN TECHNOLOGY, KHARAR DSPM LabOutput:

Year profit

................

1950 400000

1951 250000

1952 450000

1953 500000

1954 5500000

8

Page 9: DSPM+Lab+Manual+June Dec+2011 (1)

GGS COLLEGE OF MODERN TECHNOLOGY, KHARAR DSPM Lab

Viva-voce Questions:

What so you understand by a data structure?

Name any five data structures.

What are arrays?

What are the types of arrays?

How two dimensional arrays are stored in memory?

9

Page 10: DSPM+Lab+Manual+June Dec+2011 (1)

GGS COLLEGE OF MODERN TECHNOLOGY, KHARAR DSPM LabExperiment No 2 Date__/__/_____

AIM Write a program in C++ for Inserting an Array.

#include<iostream.h>

#include<conio.h>

#include<iomanip.h>

void main()

{

int a[20],n,k,item;

clrscr();

void insert(int a[],int n,int k,int item);

cout<<"enter the no of elements";

cin>>n;

for(int i=0;i<n;i++)

{

cout<<"enter the element a[" <<i<<"]=";

cin>>a[i];

}

cout<<"enter the item to insert=";

cin>>item;

cout<<"enter index position of new item";

cin>>k;

10

Page 11: DSPM+Lab+Manual+June Dec+2011 (1)

GGS COLLEGE OF MODERN TECHNOLOGY, KHARAR DSPM Labinsert(a,n,k,item);

cout<<"elements after insertion"<<endl;

for( i=0;i<=n;i++)

{

cout<<setw(4)<<a[i];

}

getch();

}

void insert(int a[],int n,int k,int item)

{

int i=n-1;

while(i>=k)

{

a[i+1]=a[i];

i=i-1;

}

a[k]=item;

n=n+1;

}

11

Page 12: DSPM+Lab+Manual+June Dec+2011 (1)

GGS COLLEGE OF MODERN TECHNOLOGY, KHARAR DSPM Lab

Output:

enter the no of elements5

enter the element a[0]=7

enter the element a[1]=21

enter the element a[2]=9

enter the element a[3]=10

enter the element a[4]=4

enter the item to insert=13

enter index position of new item3

elements after insertion

7 21 9 13 10 4

12

Page 13: DSPM+Lab+Manual+June Dec+2011 (1)

GGS COLLEGE OF MODERN TECHNOLOGY, KHARAR DSPM Lab

Viva-voce Questions :

What will happen when you delete in an empty array?

What will happen when you insert in a completely filled array?

What ‘5’ signifies in “A[5]”?

What is garbage collection?

Can you insert in middle location of an array?

AIM Write a program in C++ for Deleting an Array.

13

Page 14: DSPM+Lab+Manual+June Dec+2011 (1)

GGS COLLEGE OF MODERN TECHNOLOGY, KHARAR DSPM Lab

Experiment No 3 Date__/__/_____

#include<iostream.h>

#include<conio.h>

#include<iomanip.h>

void main()

{

int a[20],n,k,item;

clrscr();

void delete2(int a[],int &n,int k);

cout<<"enter the number of element (<=20) =";

cin>>n;

for (int i=0; i<n; i++)

{

cout <<"enter element a["<<i<<"]=";

cin>>a[i];

}

cout<<"enter position of element you want to delete :";

cin>>k;//index of element to delete is k-1

delete2(a,n,k-1);

14

Page 15: DSPM+Lab+Manual+June Dec+2011 (1)

GGS COLLEGE OF MODERN TECHNOLOGY, KHARAR DSPM Lab cout<<"elements after deletion:\n";

for(i=0;i<n;i++)

cout<<setw(4)<<a[i];

getch();

}

void delete2(int a[],int &n,int k)

{

for (int i=k; i<=n-2;i++)

a[i]=a[i+1];

n=n-1;

}

15

Page 16: DSPM+Lab+Manual+June Dec+2011 (1)

GGS COLLEGE OF MODERN TECHNOLOGY, KHARAR DSPM LabOUTPUT:

enter the number of element (<=20) =5

enter element a[0]=10

enter element a[1]=12

enter element a[2]=13

enter element a[3]=15

enter element a[4]=14

enter position of element you want to delete :3

elements after deletion:

10 12 15 14

16

Page 17: DSPM+Lab+Manual+June Dec+2011 (1)

GGS COLLEGE OF MODERN TECHNOLOGY, KHARAR DSPM LabViva-voce Questions:

What is the principle of stack?

What do you understand by top pointer?

What is overflow?

What is underflow?

Can you insert at middle in a stack?

Experiment No 4 Date__/__/_____

17

Page 18: DSPM+Lab+Manual+June Dec+2011 (1)

GGS COLLEGE OF MODERN TECHNOLOGY, KHARAR DSPM LabAIM Write a program in C++ for Linear Search .

#include<iostream.h>

#include<conio.h>

#include<iomanip.h>

void main()

{

clrscr();

int a [15],i,n,item,loc;

int lsrch(int a[],int n,int item);

cout<<"enter the element of array.... ";

cin>>n;

for(i=0;i<5;i++)

{ cout<<"the elements of array a["<<i<<"]..";

cin>>a[i];

}

cout<<"enter the element you want to search......";

cin>>item;

loc=lsrch(a,n,item);

if(loc==-1)

cout<<"item does not exist in the array....";

else

18

Page 19: DSPM+Lab+Manual+June Dec+2011 (1)

GGS COLLEGE OF MODERN TECHNOLOGY, KHARAR DSPM Lab

cout<<"item "<<item<<"....exists at...index.."<<loc;

getch();

}

int lsrch( int a[], int n, int item)

{

int loc=-1, i=1;

while(i<n && a[i]!=item)

i=i+1;

if(a[i]==item)

loc=i;

return(loc);

}

OUTPUT:

19

Page 20: DSPM+Lab+Manual+June Dec+2011 (1)

GGS COLLEGE OF MODERN TECHNOLOGY, KHARAR DSPM Labenter the element of array.... 4

the elements of array a[0]..55

the elements of array a[1]..22

the elements of array a[2]..33

the elements of array a[3]..11

the elements of array a[4]..66

enter the element you want to search......66

item 66....exists at...index..4

Viva-voce Questions:

What are the steps for inserting in stack?

20

Page 21: DSPM+Lab+Manual+June Dec+2011 (1)

GGS COLLEGE OF MODERN TECHNOLOGY, KHARAR DSPM Lab

What are the steps for deleting an element in a stack?

Rest of questions are same as last practical.

Experiment No 5 Date__/__/_____

AIM Write a program in C++ for Binary Search.

21

Page 22: DSPM+Lab+Manual+June Dec+2011 (1)

GGS COLLEGE OF MODERN TECHNOLOGY, KHARAR DSPM Lab

#include<iostream.h>

#include<conio.h>

#include<iomanip.h>

void main()

{

int a[10],i,n,loc,item;

clrscr();

int bsearch(int a[],int n,int item);

cout<<"enter no of sorted elements(<=10)=";

cin>>n;

for(i=0;i<n;i++)

{

cout<<"enter the element a["<<i<<"]=";

cin>>a[i];

}

cout<<"enter item to search=";

cin>>item;

loc=bsearch(a,n,item);

if(loc==-1)

cout<<"item does not exit in array";

else

22

Page 23: DSPM+Lab+Manual+June Dec+2011 (1)

GGS COLLEGE OF MODERN TECHNOLOGY, KHARAR DSPM Labcout<<"item\t"<<item<<"\t exist at index="<<loc;

getch();

}

int bsearch(int a[],int n,int item)

{

int loc=-1,beg=0,end=n-1,mid;

while(beg<=end)

{

mid=(beg+end)/2;

if(item== a[mid])

{

loc=mid;

break;

}

else

if(item>a[mid])

beg=mid+1;

else

end=mid-1;

}

return(loc);

}

23

Page 24: DSPM+Lab+Manual+June Dec+2011 (1)

GGS COLLEGE OF MODERN TECHNOLOGY, KHARAR DSPM Lab

OUTPUT:

24

Page 25: DSPM+Lab+Manual+June Dec+2011 (1)

GGS COLLEGE OF MODERN TECHNOLOGY, KHARAR DSPM Labenter no of sorted elements(<=10)=5

enter the element a[0]=12

enter the element a[1]=35

enter the element a[2]=41

enter the element a[3]=23

enter the element a[4]=24

enter item to search=41

item 41 exist at index=2

Viva-voce Questions:

25

Page 26: DSPM+Lab+Manual+June Dec+2011 (1)

GGS COLLEGE OF MODERN TECHNOLOGY, KHARAR DSPM Lab

What is the principle of queue?

What do you understand by front?

What do you understand by rear?

What will happen if front=rear?

What will happen if front=NULL?

Experiment No 6 Date__/__/_____

AIM Write a program in C++ for Bubble Sort.

26

Page 27: DSPM+Lab+Manual+June Dec+2011 (1)

GGS COLLEGE OF MODERN TECHNOLOGY, KHARAR DSPM Lab

#include<iostream.h>

#include<conio.h>

void main()

{

clrscr();

int a[10],n;

void bubblesort(int a[],int n);

cout<<"enter the elements=";

cin>>n;

for(int i=0;i<n;i++)

{

cout<<"enter the element of a["<<i<<"]=";

cin>>a[i];

}

bubblesort(a,n);

cout<<"sorted elements.........\n";

for(i=0;i<n;i++)

{

27

Page 28: DSPM+Lab+Manual+June Dec+2011 (1)

GGS COLLEGE OF MODERN TECHNOLOGY, KHARAR DSPM Lab

cout<<a[i]<<endl;

}

getch();

}

void bubblesort(int a[],int n)

{

int temp;

for(int i=0;i<n-1;i++)

{

for(int j=0;j<n-i-1;j++)

{

if(a[j]>a[j+1])

{

temp=a[j];

a[j]=a[j+1];

a[j+1]=temp;

}

}

}

OUTPUT:

28

Page 29: DSPM+Lab+Manual+June Dec+2011 (1)

GGS COLLEGE OF MODERN TECHNOLOGY, KHARAR DSPM Lab

enter the elements=4

enter the element of a[0]=55

enter the element of a[1]=11

enter the element of a[2]=22

enter the element of a[3]=33

sorted elements.........

11

22

33

55

Viva-voce Questions:

29

Page 30: DSPM+Lab+Manual+June Dec+2011 (1)

GGS COLLEGE OF MODERN TECHNOLOGY, KHARAR DSPM Lab

Write the steps for inserting in queue.

Write the steps for deletion in queue.

What will happen if front=rear+1?

How will you check overflow in queue?

How will you check underflow in queue?

Experiment No 7 Date__/__/_____

AIM Write a program in C++ to push the elements into Stack.

30

Page 31: DSPM+Lab+Manual+June Dec+2011 (1)

GGS COLLEGE OF MODERN TECHNOLOGY, KHARAR DSPM Lab

#include<iostream.h>

#include<conio.h>

void main()

{ clrscr();

int stack[10];

int item,top=-1,i,a;

int max=9;

do

{

if(top==max)

{ cout<<"overflow";

getch();

break;

}

else

{

top=top+1;

cout<<"enter the element to be inserted in the stack=";

cin>>item;

stack[top]=item;

31

Page 32: DSPM+Lab+Manual+June Dec+2011 (1)

GGS COLLEGE OF MODERN TECHNOLOGY, KHARAR DSPM Labcout<<"stack elements are :"<<endl;

for(i=top;i>=0;i--)

cout<<"\n\t"<<stack[i]<<endl;

}

cout<<"do you want to push more elements into stack?{type 1 for yes & 2 for no}\n";

cin>>a;

}

while(a==1);

getch();

}

Output: 32

Page 33: DSPM+Lab+Manual+June Dec+2011 (1)

GGS COLLEGE OF MODERN TECHNOLOGY, KHARAR DSPM Labenter the element to be inserted in the stack=12

stack elements are :

12

do you want to push more elements into stack?{type 1 for yes & 2 for no}

1

enter the element to be inserted in the stack=25

stack elements are :

25

12

do you want to push more elements into stack?{type 1 for yes & 2 for no}

1

enter the element to be inserted in the stack=54

stack elements are :

54

25

12

do you want to push more elements into stack?{type 1 for yes & 2 for no}

1

enter the element to be inserted in the stack=35

stack elements are :

35

54

25

12

do you want to push more elements into stack?{type 1 for yes & 2 for no}

33

Page 34: DSPM+Lab+Manual+June Dec+2011 (1)

GGS COLLEGE OF MODERN TECHNOLOGY, KHARAR DSPM LabViva-voce Questions:

Which data structure is used in linear search?

What do you understand by complexity?

What is “Big O” notation?

What do you understand by best case and worst case?

What will happen if list is empty?

Experiment No 8 Date__/__/_____

AIM Write a program in C++ to pop an element from Stack.

34

Page 35: DSPM+Lab+Manual+June Dec+2011 (1)

GGS COLLEGE OF MODERN TECHNOLOGY, KHARAR DSPM Lab

#include<iostream.h>

#include<conio.h>

void main()

{

clrscr();

int stack [7]={7,4,5,8,2,9,1};

int item,top=4,i,a;

do

{

if(top<0)

{

cout<<"\n underflow";

getch();

break;

}

else

{

item=stack[top];

top=top-1;

cout<<"\n\n stack elements are:\n";

for(i=top;i>=0;i--)

35

Page 36: DSPM+Lab+Manual+June Dec+2011 (1)

GGS COLLEGE OF MODERN TECHNOLOGY, KHARAR DSPM Lab {

cout<<"\n\t"<<stack[i];

}

}

cout<<"\n\n do you want to pop more elements from stack?{type 1 for yes & 2 for no}\n";

cin>>a;

}

while(a==1);

getch();

}

OUTPUT:

stack elements are:

8

36

Page 37: DSPM+Lab+Manual+June Dec+2011 (1)

GGS COLLEGE OF MODERN TECHNOLOGY, KHARAR DSPM Lab5

4

7

do you want to pop more elements from stack?{type 1 for yes & 2 for no}

1

stack elements are:

5

4

7

do you want to pop more elements from stack?{type 1 for yes & 2 for no}

1

stack elements are:

4

7

do you want to pop more elements from stack?{type 1 for yes & 2 for no}

1

stack elements are:

7

do you want to pop more elements from stack?{type 1 for yes & 2 for no}

1

stack elements are:

do you want to pop more elements from stack?{type 1 for yes & 2 for no}

1

underflow

Viva-voce Questions:

37

Page 38: DSPM+Lab+Manual+June Dec+2011 (1)

GGS COLLEGE OF MODERN TECHNOLOGY, KHARAR DSPM Lab

Can binary search operate in unsorted list?

How binary search works?

How binary search is different from linear search?

Name the various pointers used in binary search.

What will happen when beg=end?

Experiment No 9 Date__/__/_____

AIM Write a program in C++ to sort a list using Selection Sort.

38

Page 39: DSPM+Lab+Manual+June Dec+2011 (1)

GGS COLLEGE OF MODERN TECHNOLOGY, KHARAR DSPM Lab

#include<iostream.h>

#include<conio.h>

class sel

{

int a[10],loc,min,t,j,n,i;

public:

sort();

create();

};

sel::create()

{

cout<<"enter the no. of elements=";

cin>>n;

for(i=0;i<n;i++)

{

cin>>a[i];

}

}

sel::sort()

{

for(i=0;i<n-1;i++)

39

Page 40: DSPM+Lab+Manual+June Dec+2011 (1)

GGS COLLEGE OF MODERN TECHNOLOGY, KHARAR DSPM Lab {

min=a[i];

loc=i;

for(j=i+1;j<=n-1;j++)

{

if(a[j]<min)

{

min=a[j];

loc=j;

}

}

if(loc!=0)

{

t=a[i];

a[i]=a[loc];

a[loc]=t;

}

}

cout<<"the sorted lidt is:";

for(j=0;j<n;

j++)

{

40

Page 41: DSPM+Lab+Manual+June Dec+2011 (1)

GGS COLLEGE OF MODERN TECHNOLOGY, KHARAR DSPM Lab cout<<"\n"<<a[j];

}

}

main()

{

clrscr();

sel z;

z.create();

z.sort();

getch();

}

Output:

41

Page 42: DSPM+Lab+Manual+June Dec+2011 (1)

GGS COLLEGE OF MODERN TECHNOLOGY, KHARAR DSPM Labenter the no. of elements=8

54

8

25

63

15

24

48

95

the sorted lidt is:

8

15

24

25

48

54

63

95

Viva-voce Questions:42

Page 43: DSPM+Lab+Manual+June Dec+2011 (1)

GGS COLLEGE OF MODERN TECHNOLOGY, KHARAR DSPM Lab

What is complexity of bubble sort?

How many comparisons will be there if list contains 20 elements?

What is sorting?

How sorting is different from searching?

Name various pointers used in program.

Experiment No 10 Date__/__/_____

AIM Write a program in C++to sort a list using insertion sort.

43

Page 44: DSPM+Lab+Manual+June Dec+2011 (1)

GGS COLLEGE OF MODERN TECHNOLOGY, KHARAR DSPM Lab

#include<iostream.h>

#include<conio.h>

void main()

{

clrscr();

int i,n,t,j;

int a[50];

cout<<"enter the no. of elements:";

cin>>n;

cout<<"enter"<<n<<"unsorted elements :\n";

for(i=1;i<=n;i++)

cin>>a[i];

for(i=1;i<=n;i++)

{

t=a[i];

j=i-1;

while((t<a[j]) && (j>=0))

{

a[j+1]=a[j];

j--;

}

44

Page 45: DSPM+Lab+Manual+June Dec+2011 (1)

GGS COLLEGE OF MODERN TECHNOLOGY, KHARAR DSPM Laba[j+1]=t;

}

cout<<"list after sorting:\n";

for(i=1;i<=n;i++)

cout<<a[i]<<"\n";

getch();

}

OUTPUT:-

45

Page 46: DSPM+Lab+Manual+June Dec+2011 (1)

GGS COLLEGE OF MODERN TECHNOLOGY, KHARAR DSPM Labenter the no. of elements:4

enter4unsorted elements :

12

45

10

15

list after sorting:

10

12

15

45

Viva-voce Questions:

46

Page 47: DSPM+Lab+Manual+June Dec+2011 (1)

GGS COLLEGE OF MODERN TECHNOLOGY, KHARAR DSPM Lab

What are differences between quick sort and bubble sort?

What is complexity of quick sort?

Why quick sort is named so?

List various pointers used in the program.

Is quick sort better than bubble sort?

Experiment No 11 Date__/__/_____

AIM Write a program in C++ to Insert an element into a Queue.

47

Page 48: DSPM+Lab+Manual+June Dec+2011 (1)

GGS COLLEGE OF MODERN TECHNOLOGY, KHARAR DSPM Lab

#include<iostream.h>

#include<conio.h>

void main()

{

clrscr();

int queue[10]={2,5,6,9};

int item,front=0,rear=3,i,a;

int max=0;

cout<<"the queue is:\n";

for(int j=0;j<=3;j++)

{

cout<<queue[j]<<"\n";

}

do

{

if((front==0&&rear==max)||(front==rear+1))

{

cout<<"\n\n\tOVERFLOW\n";

getch();

break;

}

48

Page 49: DSPM+Lab+Manual+June Dec+2011 (1)

GGS COLLEGE OF MODERN TECHNOLOGY, KHARAR DSPM Labelse

{

if(front<0)

{

front=0;

rear=0;

}

else

{

if(rear==max)

{

rear=0;

}

else

{

rear=rear+1;

}

}

cout<<"\nenter the element to be inserted in queue:";

cin>>item;

queue[rear]=item;

cout<<"\n\tNow queue elements are:";

49

Page 50: DSPM+Lab+Manual+June Dec+2011 (1)

GGS COLLEGE OF MODERN TECHNOLOGY, KHARAR DSPM Labfor(i=0;i<=rear;i++)

{

cout<<queue[i]<<"\n";

}

cout<<"\n\tFRONT: "<<front<<"th location,REAR:"<<rear<<"th location";

}

cout<<"\n\nDo you want to push more elements into queue?{type 1 for yes & 2 for no}\n";

cin>>a;

}

while(a==1);

getch();

}

Output:

50

Page 51: DSPM+Lab+Manual+June Dec+2011 (1)

GGS COLLEGE OF MODERN TECHNOLOGY, KHARAR DSPM Labthe queue is:

2

5

6

9

enter the element to be inserted in queue:15

Now queue elements are:2

5

6

9

15

FRONT: 0th location,REAR:4th location

Do you want to push more elements into queue?{type 1 for yes & 2 for no}

1

enter the element to be inserted in queue:25

Now queue elements are:2

5

6

9

Viva-voce Questions:

51

Page 52: DSPM+Lab+Manual+June Dec+2011 (1)

GGS COLLEGE OF MODERN TECHNOLOGY, KHARAR DSPM Lab

What is the principle of insertion sort?

What is the complexity of insertion sort?

Write down the pointers used in insertion sort program.

Is insertion sort superior to other sorting techniques?

What is time-space trade-off?

Date of Submission__________________

Faculty Signature___________________

52