315 14 - Lab Data Structure Using C ++
315 14 - Lab Data Structure Using C ++
sruIncrease
oC eht fothe
ezifont
s tnosize
f ehof
t esthe
aerCourse
cnI .1 Name.
.egaP revoC e2.ht nuse
i rethe
daefollowing
h a sa gniwasolaloheader
f eht esin
u the
.2 Cover Page.
YTISREVINUALAGAPPA
APPAGALAUNIVERSITY
Master of Computer Applications
elcyC drihT eht ni )46.3:APGC( CA[Accredited
AN yb edarGwith
’+A’’A+’
htiwGrade
detidby
ercNAAC
cA[ (CGPA:3.64) in the Third Cycle
]CGU-DRHM yb ytisrevinU I–yrogeand
taC Graded
sa dedarasG Category–I
dna University by MHRD-UGC]
300 036 – IDUKIARA
KARAIKUDI
K – 630 003
315 14 NOITACUDE ECNATSIDDIRECTORATE
FO ETAROTCEOF
RIDDISTANCE EDUCATION
itnem sYou
a egaare
p reinstructed
voc eht etatodpupdate
u ot dethe
tcurcover
tsni erpage
a uoYas mentioned below:
.emaN e1.sruIncrease
oC eht fothe
ezifont
s tnosize
f ehof
t esthe
aerCourse
cnI .1 Name.
aP revoC e2.ht nuse
i rethe
daefollowing
h a sa gniwasolaloheader
f eht esin
u the
.2 Cover Page.
ISREVINUALAGAPPA
APPAGALAUNIVERSITY
Master of Computer Applications
rihT eht ni )46.3:APGC( CA[Accredited
AN yb edarGwith
’+A’’A+’
htiwGrade
detidby
ercNAAC
cA[ (CGPA:3.64) in the Third Cycle
]CGU-DRHM yb ytisrevinU I–yrogeand
taC Graded
sa dedarasG Category–I
dna University by MHRD-UGC]
300 036 – IDUKIARA
KARAIKUDI
TACUDE ECNATSIDDIRECTORATE
K
FO ETAROTCEOF
– 630 003
RIDDISTANCE EDUCATION
LAB: DATA STRUCTURE USING C++
I - Semester
ALAGAPPA UNIVERSITY
[Accredited with ‘A+’ Grade by NAAC (CGPA:3.64) in the Third Cycle
and Graded as Category–I University by MHRD-UGC]
(A State University Established by the Government of Tamil Nadu)
KARAIKUDI – 630 003
All rights reserved. No part of this publication which is material protected by this copyright notice
may be reproduced or transmitted or utilized or stored in any form or by any means now known or
hereinafter invented, electronic, digital or mechanical, including photocopying, scanning, recording
or by any information storage or retrieval system, without prior written permission from the Alagappa
University, Karaikudi, Tamil Nadu.
Information contained in this book has been published by VIKAS® Publishing House Pvt. Ltd. and has
been obtained by its Authors from sources believed to be reliable and are correct to the best of their
knowledge. However, the Alagappa University, Publisher and its Authors shall in no event be liable for
any errors, omissions or damages arising out of use of this information and specifically disclaim any
implied warranties or merchantability or fitness for any particular use.
Work Order No. AU/DDE/DE1-238/Preparation and Printing of Course Materials/2018 Dated 30.08.2018 Copies - 500
SYLLABI-BOOK MAPPING TABLE
Lab: Data Structure Using C++
Syllabi Mapping in Book
Self-Instructional
8 Material
Simple C++ Programs
Step 2: Click on Start Turbo C++. After clicking on Start Turbo C++ button
following screen will appear:
Self-Instructional
2 Material
Simple C++ Programs
NOTES
Self-Instructional
Material 3
Simple C++ Programs Step 5: Compile program by hello.cpp by pressing Alt+F9 keys or by using menu
option Compile-> Compile:
NOTES
Output:
Self-Instructional
4 Material
Simple C++ Programs Simple C++ Programs
1. Write a program to take two numbers as input and print their sum and
average.
//Program to take input in two numbers and print sum and NOTES
average
#include<iostream.h>
void main()
{
int num1,num2,sum,avg;
NOTES
Try yourself:
(i) Write a program to calculate volume of cylinder.
Volume of cylinder= PI*r*r*h
(ii) Write a program to calculate curved surface area of cylinder.
Curved surface area of cylinder= 2*PI*r*h
(iii) Write a program to print ASCII value of digits, uppercase and lowercase
alphabets.
Control Structures: Using if and switch constructs Programs:
3. Write a program to check whether the number provided is even or odd.
#include <iostream.h>
void main()
{
int num;
cout<<“Enter a number: “;
cin>>num;
if(num%2==0)
{
cout<<“Number is even “;
}
else
{
cout<<“Number is odd “;
}
}
Output:
Enter a number: 2
Number is even
4. Write a program to print the largest number among three numbers given
by the user.
Self-Instructional
6 Material
// program to print the largest number among three numbers Simple C++ Programs
#include <iostream.h>
void main()
{
NOTES
int num1,num2,num3;
cout<<“Enter three numbers”<<endl;
cin>>num1>>num2>>num3;
}
Output:
#include <iostream.h>
void main()
{
int num, i;
cout<<“Enter a number: “;
cin>>num;
cout<<“Table of “<<num<<endl;
Self-Instructional for (i=1;i<=10;i++)
8 Material
{ Simple C++ Programs
cout<<num*i<<endl;
}
}
NOTES
Output:
Self-Instructional
Material 9
Simple C++ Programs 8. Write a program to check the number is Armstrong or not.
A number is known as Armstrong number if sum of the cubes of its digits is
equal to the number itself.
NOTES For example
370 is an Armstrong number because:
370 = 3*3*3 + 7*7*7 + 0*0*0
= 27 + 343 + 0
= 370
// C++ Program to check Armstrong Number
#include <iostream.h>
void main()
{
int num, sum = 0, rem,temp;
cout<<“Enter a number: “;
cin>>num;
temp =num;
while (num>0)
{
rem= num%10;
sum= sum+(rem*rem*rem);
num= num/10;
}
if (temp==sum)
cout<<“Number in armstrong “<<endl;
else
cout<<“Number is not armstrong .”<<endl;
}
Output:
Output:
Try yourself:
(1) Write a program to reverse a number.
(2) Write a program to check whether a number is prime number or not.
(3) Write a program to convert binary number to decimal number.
10 Write a program that takes values in an array and also display them.
//C++ program to scan and print values using array
#include <iostream.h>
int main()
{
int arr[5],i;
cout << “Enter 5 numbers:\n “;
for (i=0;i<5;i++)
cin >> arr[i];
cout<<“\n Array values are “<<endl;
for (i=0;i<5;i++)
cout<<arr[i]<<endl;
}
Self-Instructional
Material 11
Simple C++ Programs Output:
NOTES
11. Write a program that take a string as input and print it.
//C++ Program to take input in string and print
#include <iostream.h>
#include <conio.h>
void main()
{
char str[15];
cout<<“Enter your name: “;
cin>>str;
cout<<“\n Welcome “<<str;
getch ();
}
12. Write a program to print length of a string provided.
//C++program to count string length
#include<iostream.h>
void main( )
{
int i,count=0;
char str[50];
cout<<“Enter any string “;
cin.getline (str, 50); //getline function allows
user to input string with space
//loop will run till it reaches to string terminator
‘\0’
for (i = 0; str[i] != ‘\0’; i++)
{
count ++;
}
cout << “\n Length of string is “ << count;
}
Self-Instructional
12 Material
Output: Simple C++ Programs
NOTES
Output:
Self-Instructional
14 Material
Simple C++ Programs
Try yourself
(1) Write a program to insert an element in an array.
(2) Write a program to find sum of elements of an array.
NOTES
(3) Write a program to find largest number from an array.
15. Write a program that provides the sum of two matrices.
//C++ program to print sum of two matrices
#include<iostream.h>
int main()
{
int i, j, m1[10][10], m2[10][10], sum[10][10];
cout << “Enter the elements of first matrix\n”;
for ( i = 0; i < 3; i++ )
{
cout<<“\n enter values for row “<<i+1<<endl;
for ( j = 0 ; j<3 ; j++ )
{ cin >> m1[i][j];}
}
}
cout<<endl;
}
}
Self-Instructional
Material 15
Simple C++ Programs Output:
NOTES
Self-Instructional
16 Material
for (j = 0; j < 3; ++j) Simple C++ Programs
{
res [i][j]=0;
for (k = 0; k < 3; ++k)
NOTES
{
res[i][j] += m1[i][k] * m2[k][j];
}
}
}
cout << “Multiplication of two matrices \n”;
for ( i = 0 ;i < 3 ; i++ )
{
for ( j = 0 ; j<3 ; j++ )
{
cout << res[i][j] << “\t”;
}
cout<<endl;
}
}
Output:
Try yourself:
(1) Write a program to print sum of diagonal values of a square matrix.
(2) Write a program to find highest and lowest element of a matrix.
(3) Write a program to convert first letter of each word of a string to uppercase
and other to lowercase.
(4) Write a program to find substring in string (pattern matching).
Self-Instructional
Material 17
OOPs Concepts
Self-Instructional
18 Material
Keywords: private and public OOPs Concepts
You may have noticed two keywords: private and public in the above program.
The private keyword makes data and functions private. Private data and
functions can be accessed only from inside the same class. NOTES
The public keyword makes data and functions public. Public data and
functions can be accessed out of the class.
2. Write a program to demonstrate the use of constructor in a class.
Self-Instructional
Material 19
OOPs Concepts student obj;
obj.input();
obj.display();
}
NOTES
Output:
//class
class student
{
private:
//member variables
int rno;
char name[10];
public
// constructor
student()
{
cout<<“Constructor \n”;
rno=0;
}
// member functions
void input()
{
cout<<“\n Enter student roll number :”;
cin>>rno;
Self-Instructional
20 Material
cout<<“\n Enter student name :”; OOPs Concepts
cin>>name;
}
NOTES
void display()
{
cout<<“\n Roll Number :”<<rno;
cout<<“\n Name :”<<name;
}
//destructor
~student()
{
cout<<“\n Destructor \n”;
}
} ;
int main()
{
student obj;
obj.input();
obj.display();
}
Output:
Self-Instructional
Material 23
OOPs Concepts 6. Write a program to demonstrate the use of static function and variable.
//C++ Program to count the object value using the keyword
static variable.
#include<iostream.h>
NOTES class static_class {
int n;
static int count; //static variable
public:
//constructor
static_class()
{
n = ++count;
}
void obj_number()
{
cout << “\n\tObject number is :” << n;
}
static void obj_count()
{
cout << “\nNumber of Objects :” << count;
}
};
int static_class::count;
int main()
{
static_class obj1, obj2;
obj1.obj_count();
obj1.obj_number();
obj2.obj_count();
obj2.obj_number();
return 0;
}
Try yourself:
(1) Write a program to swap two numbers using class
(2) Write a Program to Print Numbers From 1 to n using class
(3) Write a program to calculate area of a circle,a rectangle or a triangle
depending upon user’s choice using class
Self-Instructional
24 Material
7. Write a program to get and print student data using inheritance. OOPs Concepts
void display ()
{
cout<<“\n Roll Number :”<<rno;
cout<<“\n Name :”<<name;
}
} ; //class closed
public:
void input_data ()
{
input (); //call of input function of student
class
cout<<“\n Enter Fee :”;
cin>>fee;
}
Self-Instructional
Material 25
OOPs Concepts void display_data ()
{
display (); //call of display function of student
class
NOTES cout<<“\n Fee :”<<fee;
}
};
int main()
{
fee obj; //object of fee class
obj.input_data ();
obj.display_data ();
}
Output:
Self-Instructional
26 Material
Test obj; OOPs Concepts
cout<<“Sum of two integers “<<obj.sum(310, 220)<<endl;
cout<<“Sum of three integers “<<obj.sum(12, 20, 23);
}
NOTES
Output:
Try yourself:
(1) Write a program to swap two numbers using class
(2) Write a Program to Print Numbers From 1 to n using class
(3) Write a program to calculate area of a circle, a rectangle or a triangle
depending on input using overloaded calculate function.
(4) Write a program that overloads the + operator and relational operators
(suitable) to perform the following operations:
a) Concatenation of two strings.
b) Comparison of two strings.
9. Write a program to print factorial of a given number using recursive
function.
//C++ Program to print factorial using recursive function
#include<iostream.h>
// Factorial Function
int factorial(int n)
{
if (n > 1)
return n * factorial(n - 1); //recursive call of
factorial function
else
return 1;
}
int main()
{
int n;
cout << “Enter a number : “;
cin >> n;
Self-Instructional
Material 27
OOPs Concepts
cout << “Factorial of “ << n << “ is “ << factorial(n);
return 0;
}
NOTES
Output:
#include<iostream.h>
int fibonacci (int n)
{
if ((n==1)||(n==0))
{
return (n);
}
else
{
int main()
{
int n, i;
Self-Instructional
28 Material
cout<<“ “<<fibonacci (i); OOPs Concepts
}
return 0;
}
NOTES
Output:
Try yourself:
(1) Write a program that uses a recursive function to find the binary equivalent
of a given non-negative integer n.
(2) Write a programs functions to find the GCD of two given integers using
recursive function.
Input/Output with files
C++ provides various header files for Input/output to/from data files. These header
files are ofstream.h, ifstream.h and fstream.h.
ifstream: Stream class to read from files.
ofstream: Stream class to write on files.
fstream: Stream class to both read and write from/to files.
11. Write a C++ program to create a file (data.txt).
/ /basic file operations
#include <iostream.h>
#include <fstream.h>
#include <conio.h>
void main ()
{
ofstream file1;
file1.open (“data.txt”);
file1 << “This is my first file.\n”;
file1.close ();
getch();
}
The above code will create a file called data.txt. We have inserted “This is my first
file.” text in our file.
Self-Instructional
Material 29
OOPs Concepts Opening a file
open () function is used with filename and mode parameters
for opening a file.
NOTES Syntax:
open (filename, mode);
Filename parameter is used to give a filename to be opened and mode parameter
is used to give modes in which file should be open. There are various modes
available such as ios::in, ios::out, ios::binary, ios::ate etc. All these modes can be
combined using bitwise OR (|) operator.
Example of combining file modes is:
ofstream file1;
file1.open (“data.bin”, ios::out | ios::app | ios::binary);
Table 1.1 Modes of opening a file.
Closing a file
Close () function is used for closing a file.
Syntax:
filename.close ();
12. Write a program for creating and writing on a text file.
// C++ program of writing on a text file
#include<iostream.h>
#include<conio.h>
#include<fstream.h>
void main()
{
ofstream file_out;
char file_name[20];
char str[80];
clrscr ();
cout<<“Enter file name to be created “;
cin>> file_name;
Self-Instructional
30 Material
//create a new file in output mode OOPs Concepts
file_out.open (file_name, ios::out);
//close file
file_out.close ();
getch();
}
13. Write a program to retrieve/read data from a text file.
// C++ program of retrieve data from a text file
#include<iostream.h>
#include<fstream.h>
#include<conio.h>
void main()
{
ifstream file_in;
char file_name[20];
char str[80];
clrscr ();
file_in.close ();
getch ();
}
Self-Instructional
Material 31
OOPs Concepts Creating Binary file
File streams include two functions to perform read () and write () operations on a
binary file.
NOTES write (void *buffer, int size);
read (void *buffer, int size);
The buffer is of type char* which represents the address of an array of bytes
where the read data elements are stored. The size parameter is an integer value
that specifies the number of characters to be read or written from/to the memory
block.
14. Write a program for reading and writing on a binary file.
//Read and Writing in a Binary File
#include<iostream.h>
#include<fstream.h>
#include<cstdio.h>
class Student
{
int rno;
char name[50];
public:
void setData()
{
cout << “\n Enter roll number”;
cin >>rno;
cout << “Enter name “;
cin.getline (name, 50);
}
void showData ()
{
cout << “\nAdmission no. : “ << rno;
cout << “\nStudent Name : “ << name;
}
};
// function to write in a binary file.
void write_data()
{
Self-Instructional
32 Material
ofstream file_out; OOPs Concepts
file_out.open (“student.dat”, ios::binary | ios::app);
Student obj;
NOTES
obj.setData ();
file_out.write((char*)&obj, sizeof(obj));
file_out.close();
}
void display()
{
ifstream file_in;
file_in.open(“student.dat”, ios::binary);
Student obj;
while(file_in.read((char*)&obj, sizeof(obj)))
{
obj.showData();
}
file_in.close();
}
};
int main()
{
for(int i = 1; i <= 4; i++)
write_record ();
//Search record
cout << “\nSearch result”;
search (100);
Self-Instructional
Material 33
OOPs Concepts //Delete record
delete_record(100);
cout << “\nRecord Deleted”;
NOTES
//Modify record
cout << “\nModify Record 101 “;
modify_record (101);
return 0;
}
Try yourself
(1) What task does the following program perform?
#include<iostream.h>
#include<fstream.h>
int main()
{ ofstream ofile;
ofile.open (“text.txt”);
ofile << “geeksforgeeks” << endl;
cout << “Data written to file” << endl; ofile.close();
}
(2) Write a program which copies one file to another.
(3) Write a program to that counts the characters, lines and words in the text
file.
15. Write a Program to print values of array using Pointers.
//C++ program of pointers with arrays
#include <iostream.h>
void main()
{
int arr[5],i,*ptr;
ptr = arr; //ptr pointer is holding address of arr[0]
element.
cout << “Enter 5 numbers:\n “;
for(i=0;i<5;i++)
cin >> arr[i];
cout<<“\n Array values using pointer “<<endl;
for(i=0;i<5;i++)
cout<<*(ptr + i)<<endl; //*(ptr+i) will
print array values
}
Self-Instructional
34 Material
Linear Data Structure
top—;
}
return item;
}
//DISPLAY function
void display ()
{
if( top==-1 )
{
cout<<“\nStack Underflow”;
}
else
{
int i;
cout<<“Stack value are “<<endl;
for(i=top;i>=0;i—)
cout<<ele[i]<<endl;
}
}
}; //class closed
void main()
{
int item = 0, choice, value; char ans;
stack s = stack();
do
{
cout<<“1. Push”<<endl<<”2. Pop”<<endl<<”3.
Display”<<endl<<”4. Exit”;
cout<<“\nEnter your choice: “;
cin>>choice;
Self-Instructional
36 Material
switch(choice) Linear Data Structure
{
case 1:
cout<<“Enter the value to be insert: “;
NOTES
cin>>value;
s.push(value);
break;
case 2:
value=s.pop();
cout<<“\nDeleted value is “<<value;
break;
case 3:
s.display();
break;
case 4:
// exit(0);
default:
cout<<“Invalid choice”;
}
}
Output:
Self-Instructional
Material 37
Linear Data Structure Algorithm: To transform infix expression to postfix expression value from stack
using array.
Description: Here Q is an arithmetic expression written in Infix expression.
Algorithm finds P as a Postfix expression
NOTES
Stack is an array where we will PUSH and POP values.
MAX is a constant used to define maximum limit of TOP is the top most element
of Stack where insertion and deletion is allowed.
DATA is data to be inserted in Stack.
1. Push “(“ onto Stack, and add “)” to the end of Q.
2. Scan Q from left to right and repeat Step 3 to 6 for each element of Q until
the Stack is empty.
3. If an operand is encountered, add it to P.
4. If a “(“ left parenthesis is encountered THEN push it onto Stack.
5. If an operator is encountered ,then:
1. Repeatedly POP from Stack and add to P each operator (on the top of
Stack) which has the same precedence as or higher precedence than
operator.
2. Add operator to Stack.
[End of If]
6. If a right parenthesis is encountered ,then:
1. Repeatedly pop from Stack and add to P each operator (on the top of
Stack) until a left parenthesis is encountered.
2. Remove the left Parenthesis.
[End of If]
[End of If]
7. END.
2. Write a program to convert infix expression to postfix expression.
//C++ Program to convert INFIX EXPRESSION TO POSTFIX
EXPRESSION
#include<iostream.h>
# define MAX 100
postfix [p]=’\0';
cout<<“\nThe postfix expression is: “<<postfix<<endl;
}
int prec(char symbol)
{
Switch (symbol)
{
case ‘/’:
Self-Instructional
Material 41
Linear Data Structure // Precedence of / is 4
return(4);
case ‘*’:
// Precedence of * is 3
NOTES
return(3);
case ‘+’:
// Precedence of + is 2
return(2);
case ‘-’:
// Precedence of - is 1
return(1);
case ‘(‘:
// Precedence of ( is 0
return(0);
default:
return(-1);
}
}
};
int main()
{
char ch=’y’;
Expression expr;
do
{
expr.input();
expr.ConvertToPostfix();
cout<<“\n\nDo you want to continue ? (y/n): “;
cin>>ch;
}while(ch==’y’ || ch==’Y’);
return 0;
}
Output:
Self-Instructional
42 Material
Algorithm: For evaluation of postfix expression using stack. Linear Data Structure
Description:
Here P is an arithmetic expression written in postfix expression. Stack is an array
where we will PUSH all the operands and final value. NOTES
TOP is the top most element of Stack where insertion and deletion is allowed
1. Add a Right Parenthesis “)” at the end of P postfix expression.
2. Scan P from left to right and repeat Step 3 to 4 for each element of P until
“)” is encountered.
3. If an operand is encountered, add it to STACK.
4. If an operator * is encountered, then
a) Remove two TOP elements of the stack where A is the TOP and B is
the TOP-1 element.
b) Evaluate B * A.
c) Place the result of step (b ) on to Stack
5. Set value equal to TOP element on stack.
6. Exit.
3. Write a program to evaluate postfix expressions using stack.
//C++ program to evaluate of Postfix Expressions Using
Stack
#include <iostream.h>
#include <stdlib.h>
#include <math.h>
#include <ctype.h>
const int MAX = 50 ;
//Postfix class declaration
class postfix
{
private:
int stack[MAX] ;
int top, nn ;
char *s ;
public:
//constructor
postfix ( )
{
top = -1 ;
}
Self-Instructional
Material 43
Linear Data Structure void setexpr ( char *str )
{
s = str;
}
NOTES
void push ( int item )
{
if ( top == MAX - 1 )
cout << endl << “Stack overflow “ ;
else
{
top++;
stack [top] = item ;
}
}
int pop( )
{
if ( top == -1 )
{
cout << endl << “Stack underflow “ ;
return NULL ;
}
int data = stack[top] ;
top—;
return data ;
}
void calculate( )
{
int n1, n2, n3 ;
while ( *s )
{
if ( *s == ‘ ‘ || *s == ‘\t’ )
{
s++;
continue;
}
if ( isdigit ( *s ) )
{
nn = *s - ‘0’ ;
push ( nn ) ;
}
Self-Instructional
44 Material
else Linear Data Structure
{
n1 = pop ( );
n2 = pop ( );
NOTES
switch ( *s )
{
case ‘+’ :
n3 = n2 + n1 ;
break ;
case ‘-’ :
n3 = n2 - n1 ;
break ;
case ‘/’ :
n3 = n2 / n1 ;
break ;
case ‘*’ :
n3 = n2 * n1 ;
break ;
case ‘%’ :
n3 = n2 % n1 ;
break ;
case ‘$’ :
n3 = pow ( n2 , n1 ) ;
break ;
default :
cout << “Invalid operator” ;
exit ( 1 ) ;
}
push ( n3 ) ;
}
s++ ;
}
}
void show( )
{
nn = pop ( ) ;
cout << “Final Result : “ << nn ;
}
Self-Instructional
Material 45
Linear Data Structure } ;
void main( )
{
char expr[MAX] ;
NOTES
cout << “\nEnter postfix expression to be evaluated :
“ ;
cin.getline (expr, MAX);
postfix q ;
q.setexpr (expr);
q.calculate ( );
q.show ( );
}
Algorithm to Push Value in Stack Using Linked List
Description:
Here TOP is a pointer variable which contains the address
of Top node.
NEW is the new node to be inserted in linked list.
INFO is data to be inserted in linked list
PUSH_STACK (TOP, INFO)
[OVERFLOW?]
1 IF NEW = NULL THEN
WRITE: OVERFLOW
EXIT
2 ELSE
IF TOP = NULL THEN
SET NEXT [TOP] = NULL
ELSE
SET NEXT [NEW] = TOP
[END OF IF]
SET DATA [TOP] = INFO
SET TOP = NEW
[END OF IF]
3 END
Algorithm To Pop Value From Stack Using Linked List
Description:
Here TOP is the Top node of Stack to be deleted
TEMP is name given to the node to be deleted from the list
Self-Instructional
46 Material
POP_STACK (TOP) Linear Data Structure
[UNDERFLOW?]
IF TOP = NULL THEN
WRITE: UNDER FLOW
NOTES
EXIT
ELSE
SET INFO=DATA [TOP]
SET TEMP = TOP
SET TOP =NEXT [TOP]
DELETE TEMP
[END OF IF]
END
4. Write a program to implement stack using linked list.
//C++ program for Stack implementation using linked list
#include <iostream.h>
class STACK
{
private:
NODE *top,*temp,*curr;
public:
STACK ()
{
top= NULL;
}
//PUSH Function to insert value to Stack
void push(int d)
{
temp = new NODE; //allocate memory to new node
temp->data = d;
if (temp==NULL)
{
cout<<“Overflow”;
Self-Instructional
Material 47
Linear Data Structure }
else if (top==NULL)
{
top=temp;
NOTES
top->next=NULL;
}
else
{
temp->next=top;
top=temp;
}
//POP Function to delete value from Stack
int pop()
{
int d;
if (top==NULL)
{
cout<<“Underflow”;
}
else
{
d= top->data ;
temp=top;
top=top->next;
delete temp;
}
return d;
}
curr= curr->next;
}
}
}
};
//MAIN FUNCTION
int main()
{
STACK s;
int d, ch;
char ans;
do
{
cout<<“\n 1.Push\n 2.Pop\n 3.Print “;
cout<<“\n Enter your choice \n”;
cin>>ch;
switch (ch)
{
case 1:
{
cout<<“\nEnter value to be inserted “;
cin>>d;
s.push (d);
break;
}
case 2:
Self-Instructional
Material 49
Linear Data Structure {
d=s.pop ();
cout<<“\n Deleted value “<<d;
break;
NOTES
}
case 3:
{
cout<<“\n Stack Value are \n”;
s.traversal ();
break;
}
default:
{
cout<<“\n Invalid choice \n”;
}
}
cout<<“\n\nCont...(y/n)”;
cin>>ans;
}
while (ans==’y’|| ans==’Y’);
}
Output:
Self-Instructional
50 Material
Linear Data Structure
Try yourself:
(1) Write a program to solving Towers of Hanoi problem that using a recursive
function.
(2) Write a program to convert infix expression to prefix expression. NOTES
Queues: Queue Implementation, Applications of Queue
class QUEUE
NOTES
{
private:
NODE *front,*rear,*temp,*curr;
public:
QUEUE()
{
front=rear= NULL;
}
//enQueue (Insertion) Function to insert value to Queue
void enQueue(int d)
{
temp = new NODE; //allocate memory to new node
temp->data = d;
if (temp==NULL)
{
cout<<“Overflow”;
}
else if (front==NULL)
{
front=rear=temp;
rear->next=NULL;
}
else
{
rear -> next = temp;
rear = temp;
}
//deQueue (delete) Function to delete value from Queue
int deQueue()
{
int d;
Self-Instructional
52 Material
if(front == NULL) Linear Data Structure
{
cout<<“Queue is Empty”;
}
NOTES
else
{
d= front->data;
temp=front;
front = front -> next;
delete temp;
}
return d;
}
curr=curr->next;
}
}
}
};
//MAIN FUNCTION
int main()
{
QUEUE q;
Self-Instructional
Material 53
Linear Data Structure int d, ch;
char ans;
cout<<“ Queue operations”;
NOTES
do
{
cout<<“\n 1.Insert \n 2.Delete \n 3.Print “;
cout<<“\n Enter your choice \n”;
cin>>ch;
switch(ch)
{
case 1:
{
cout<<“\nEnter value to be inserted “;
cin>>d;
q. enQueue( d);
break;
}
case 2:
{
d=q.deQueue();
cout<<“\n Deleted value “<<d;
break;
}
case 3:
{
cout<<“\n Queue Value are \n”;
q.traversal();
break;
}
default:
{
cout<<“\n Invalid choice \n”;
}
}
cout<<“\n\nCont...(y/n)”;
cin>>ans;
}while(ans==’y’|| ans==’Y’);
}
Self-Instructional
54 Material
Output: Linear Data Structure
NOTES
Try yourself:
(1) Write a program to implement queue using array.
(2) Write a program to implement priority queue.
6. Write a program to insert a node at the beginning of singly linked list.
//C++ program to insert node at the beginning of single
linked list
#include <iostream.h>
if(start == NULL)
{
start =end= temp;
end->next=NULL;
}
else
{
temp->next = start;
start=temp;
}
}
//Function to traversal/print single linked list
void traversal()
{
if(start == NULL)
{
cout << “Underflow” << endl;
}
else
{
curr=start;
while(curr!=NULL)
{cout << curr->data << endl;
curr=curr->next;
Self-Instructional
56 Material
} Linear Data Structure
}
}
NOTES
};
void main()
{
linked_list list;
int d;
char ans;
do
{
cout<<“\nEnter value to be inserted “;
cin>>d;
list.insert_beginning (d);
cout<<“\n\nCont...(y/n)”;
cin>>ans;
}while(ans==’y’|| ans==’Y’);
}
Output:
Self-Instructional
Material 57
Linear Data Structure 7. Write a program to insert a node at the end of singly linked list.
//C++ program to Insert Node at the end of single linked
list
#include <iostream.h>
NOTES
struct NODE
{
int data;
NODE *next;
};
class linked_list
{
private:
NODE *start,*end,*temp,*curr;
public:
linked_list()
{
start = end= NULL;
}
//Function to insert at the end
void insert_end(int d)
{
temp = new NODE; //allocate memory to new node
temp->data = d;
temp->next = NULL;
if(start == NULL)
{
start =end= temp;
end->next=NULL;
}
else
{
end->next=temp;
end=temp;
}
}
//Function to traversal/print single linked list
void traversal()
{
Self-Instructional
58 Material
if(start == NULL) Linear Data Structure
{
cout << “Underflow” << endl;
}
NOTES
else
{
curr=start;
while(curr!=NULL)
{cout << curr->data << endl;
curr=curr->next;
}
}
}
};
void main()
{
linked_list list;
int d;
char ans;
do
{
cout<<“\nEnter value to be inserted “;
cin>>d;
list.insert_end(d);
cout<<“\n\nCont...(y/n)”;
cin>>ans;
}while(ans==’y’|| ans==’Y’);
Self-Instructional
Material 59
Linear Data Structure Output:
NOTES
curr=curr->next;
}
}
}
curr=curr->prev;
}
}
}
};
//MAIN FUNCTION
int main()
{
linked_list list;
int d;
char ans;
do
{
cout<<“\nEnter value to be inserted “;
cin>>d;
list.insert_beginning (d);
cout<<“\n\nCont...(y/n)”;
cin>>ans;
}while(ans==’y’|| ans==’Y’);
Self-Instructional
62 Material
Output: Linear Data Structure
NOTES
Self-Instructional
Material 63
Linear Data Structure start =end= temp;
end->next=NULL;
end->prev=NULL;
}
NOTES else
{
end->next=temp;
temp->prev=end;
temp->next=NULL;
end=temp;
}
}
//Function to traversal/print double linked list (START
to END)
void traversal_S_to_E()
{
if(start == NULL)
{
cout << “Underflow” << endl;
}
else
{
curr=start;
while (curr!=NULL)
{cout << curr->data << endl;
curr=curr->next;
}
}
}
//Function to traversal/print double linked list (END to
START)
void traversal_E_to_S()
{
if (end == NULL)
{
cout << “Underflow” << endl;
}
else
{
curr=end;
while (curr!=NULL)
{cout << curr->data << endl;
curr=curr->prev;
}
Self-Instructional
64 Material
} Linear Data Structure
}
};
//MAIN FUNCTION
int main() NOTES
{
linked_list list;
int d;
char ans;
do
{
cout<<“\nEnter value to be inserted “;
cin>>d;
list.insert_end (d);
cout<<“\n\nCont...(y/n)”;
cin>>ans;
}while (ans==’y’|| ans==’Y’);
cout<<“\n Value of list from start to end \n”;
list.traversal_S_to_E ();
cout<<“\n Value of list from end to start \n”;
list.traversal_E_to_S ();
}
Output:
Try yourself:
(1) Write a program to implement circular linked list.
(2) Write a program to merge two linked lists.
(3) Write a program to sort a linked list.
Self-Instructional
Material 65
Non Linear Data Structure
5. [LEFT CHILD?]
IF LEFT [PTR] ‘“ NULL THEN
SET PTR = LEFT [PTR]
ELSE
SET PTR = STACK [TOP]
SET TOP = TOP -1
[END OF IF]
[END OF LOOP]
6. END
Algorithm: For post-order traversal
A binary tree t is in memory. This algorithm does postorder traversal of t. An array
stack is used to temporarily hold the address of nodes.
POSTORDER _TRAVERSAL (INFO, LEFT, RIGHT, ROOT)
1. [INITIALLY PUSH NULL TO STACK AND INITIALIZE PTR]
SET TOP =1
SET STACK [1] =NULL
SET PTR =ROOT
2. [PUSH LEFT-MOST PATH ONTO STACK ]
REPEAT STEPS 3 TO 5 WHILE PTR ‘“ NULL
3. SET TOP:=TOP+1
SET STACK [TOP] =PTR
class BST
{
public:
//constructor
BST ()
{
root = NULL;
}
// Function to insert value into tree
void insert(NODE *tree, NODE *newnode)
{
if (root == NULL)
{
root = new NODE;
root->data = newnode->data;
root->left = NULL;
root->right = NULL;
Self-Instructional
68 Material
cout<<“Root Node is Added”<<endl; Non Linear Data Structure
return;
}
if (tree->data == newnode->data)
NOTES
{
cout<<“Element already in the tree”<<endl;
return;
}
if (tree->data > newnode->data)
{
if (tree->left != NULL)
{
insert(tree->left, newnode);
}
else
{
tree->left = newnode;
(tree->left)->left = NULL;
(tree->left)->right = NULL;
cout<<“Node Added To Left”<<endl;
return;
}
}
else
{
if (tree->right != NULL)
{
insert (tree->right, newnode);
}
else
{
tree->right = newnode;
(tree->right)->left = NULL;
(tree->right)->right = NULL;
cout<<“Node Added To Right”<<endl;
return;
}
}
}
Self-Instructional
Material 69
Non Linear Data Structure // Function for inorder tree traversal
void inorder (NODE *ptr)
{
if (root == NULL)
NOTES
{
cout<<“\n Underflow\n”;
return;
}
if (ptr != NULL)
{
inorder(ptr->left);
cout<<ptr->data<<“ “;
inorder(ptr->right);
}
}
// main function
int main()
{
int ch, num;
Self-Instructional
70 Material
BST bst; Non Linear Data Structure
NODE *temp;
char ans;
do
NOTES
{
cout<<“\n1.Insert Element “<<endl;
cout<<“2.Inorder Traversal”<<endl;
cout<<“3.Display Tree Structure”<<endl;
cout<<“4. Exit”<<endl;
Self-Instructional
Material 71
Non Linear Data Structure Output:
NOTES
class BST
{
public:
//constructor
BST ()
{
root = NULL;
}
Self-Instructional
72 Material
// Function to inserting value into tree Non Linear Data Structure
void insert(NODE *tree, NODE *newnode)
{
if (root == NULL)
NOTES
{
root = new NODE;
root->data = newnode->data;
root->left = NULL;
root->right = NULL;
cout<<“Root Node is Added”<<endl;
return;
}
if (tree->data == newnode->data)
{
cout<<“Element already in the tree”<<endl;
return;
}
if (tree->data > newnode->data)
{
if (tree->left != NULL)
{
insert (tree->left, newnode);
}
else
{
tree->left = newnode;
(tree->left)->left = NULL;
(tree->left)->right = NULL;
cout<<“Node Added To Left”<<endl;
return;
}
}
else
{
if (tree->right != NULL)
{
insert (tree->right, newnode);
}
else
{
Self-Instructional
Material 73
Non Linear Data Structure tree->right = newnode;
(tree->right)->left = NULL;
(tree->right)->right = NULL;
cout<<“Node Added To Right”<<endl;
NOTES
return;
}
}
}
// main function
int main()
{
int ch, num;
BST bst;
NODE *temp;
char ans;
do
{
cout<<“\n1.Insert element “<<endl;
cout<<“2.preorder traversal”<<endl;
cout<<“3. Exit”<<endl;
}
Output:
Self-Instructional
Material 75
Non Linear Data Structure 3. Write a program for binary tree insertion and post-order traversal.
//C++ Program for postorder traversal of binary tree
# include <iostream.h>
NOTES
//structure for NODE
struct NODE
{
int data;
struct NODE *left;
struct NODE *right;
}*root;
class BST
{
public:
//constructor
BST ()
{
root = NULL;
}
// Function to insert value into tree
void insert(NODE *tree, NODE *newnode)
{
if (root == NULL)
{
root = new NODE;
root->data = newnode->data;
root->left = NULL;
root->right = NULL;
cout<<“Root Node is Added”<<endl;
return;
}
if (tree->data == newnode->data)
{
cout<<“Element already in the tree”<<endl;
return;
}
if (tree->data > newnode->data)
{
Self-Instructional
76 Material
if (tree->left != NULL) Non Linear Data Structure
{
insert(tree->left, newnode);
}
NOTES
else
{
tree->left = newnode;
(tree->left)->left = NULL;
(tree->left)->right = NULL;
cout<<“Node Added To Left”<<endl;
return;
}
}
else
{
if (tree->right != NULL)
{
insert (tree->right, newnode);
}
else
{
tree->right = newnode;
(tree->right)->left = NULL;
(tree->right)->right = NULL;
cout<<“Node Added To Right”<<endl;
return;
}
}
}
// main function
int main()
{
int ch, num;
BST bst;
NODE *temp;
char ans;
do
{
cout<<“\n1.Insert element “<<endl;
cout<<“2.post-order traversal”<<endl;
cout<<“3. Exit”<<endl;
Try yourself:
(1) Write a program to check whether a tree is a binary search tree.
(2) Write a program to search an element in a tree recursively.
(3) Write a program for depth first binary tree search using recursion.
(4) Write a program to find the largest value in a tree using inorder traversal.
Graphs
Self-Instructional
Material 79
Non Linear Data Structure
NOTES
Self-Instructional
Material 81
Non Linear Data Structure
Adjacency Matrix
In an adjacency matrix implementation, we store the edges in a V×V matrix A either
as binary values or real numbers for weighted edges.
(V2) storage is required (independent of E).
This representation is good for dense graphs where |E| |V|2. The advantage
is it only takes (1) time to determine if an edge (u, v) E since it is simply a
matrix element access. If the graph is undirected, then A = AT so only the upper
triangular half needs to be stored.
For the original directed graph, the adjacency matrix would be
Self-Instructional
82 Material
Shortest Path Algorithms Non Linear Data Structure
in the graph, and the edges that compose a minimum spanning tree of those nodes.
Algorithm:
MST-PRIM (G,w,r) NOTES
1. for each u G.V
2. u.key =
3. u.pi = NIL
4. r.key = 0
5. Q = G.V
6. while Q
7. u = EXTRACT-MIN(Q)
8. for each v G.Adj[u]
9. if v Q and w(u,v) < v.key
10. v.pi = u
11. v.key = w(u,v)
Basically the algorithm works as follows:
1. Initialize Q and set the source (root) key to 0
2. While Q is not empty, dequeue the vertex with minimum weight edge and
add it to the tree by adding edge (u.,u) to T
3. For each vertex v in Adj[u] that is still in Q, check if w(u,v) (the edge weights
from u for all vertices not in T) are less than the current v.key (the current
smallest edge weight) and if so update the predecessor and key fields
Graph traversing Methods
1. Breadth First Search(BFS)
2. Depth First Search(DFS)
Algorithm for BFS (Breadth First Search):
This Algorithm executes a breadth first search on a graph G beginning at a starting
node A
1. [Initialize all nodes to the ready state]
Set status:=1
2. Put the starting node A in Queue and change its status to the
Set status :=2
3. Repeat steps 4 and 5 until Queue is Empty:
Self-Instructional
Material 85
Non Linear Data Structure 4. Remove the front node N of Queue process N and change the status of N
to the processed
state
NOTES Set status: =3
5. Add to the rear of Queue all the neighbors of N that are in the ready state
(state=1), and
Change their status to the waiting state
Set status:=2
[End of step 3 loop]
End
Algorithm for DFS (Depth First Search)
This algorithm executes a Depth First Search on a graph G beginning A
1. [initialize all nodes to the ready state ]
Set status: =1
2. Push the starting node A onto stack and change its status to the waiting
state
Set status: =2
3. Repeat step 4 and 5 until stack is empty
4. Pop the top node N of stack . process N and change its status to the
processed state
Set status: =3
5. Push onto stack all the neighbors of N that are still in the ready state
(status=1),and change their status to the waiting state
Set status: =2
[End of step 3 loop]
6. End
DFS Applications:
DFS can be used directly, but is more often used as an intermediate technique
within another algorithm. This lecture examines three applications of DFS.
Parenthesis Theorem
Topological Sorting
Strongly Connected Component Decomposition (SCCD)
Self-Instructional
86 Material
Searching and Sorting
SORTING ALGORITHMS
NOTES
Searching refers to the operation of finding the location of a given item in a collection
of items.
Algorithm for Sequential Search
INPUT : LIST OF SIZE N, TARGET VALUE T
OUTPUT : POSITION OF T IN THE LIST
1. BEGIN
2. SET FOUND = FALSE
SET I = 0
3. WHILE IN AND FOUND IS FALSE
IF LIST [I] = T THEN
SET FOUND = TRUE
EXIT
ELSE
SET I =I+1
[END OF STEP 3 LOOP]
4. IF FOUND = FALSE THEN
WRITE: T IS NOT IN LIST
ELSE
WRITE: T IS FOUND AT I LOCATION
[END OF IF]
5 . END
1. Write a program to search a given value in an array using sequential search.
//C++ program for sequential search
#include <iostream.h>
//definition of sequential_Search function
void sequential_search (int a[ ] ,int size ,int key)
{
int flag , i ;
flag =0;
for ( i=0 ; i<size ; i++)
{
if ( a [i] == key )
{
flag = 1 ;
break ;
Self-Instructional
Material 87
Searching and Sorting }
Algorithms
}
if ( flag == 1)
cout<<"value found at "<<i+1<<"location";
NOTES
else
cout<<"value not found";
}
void main()
{
int arr[10],i,k;
cout<<"Enter 10 values";
for(i=0;i<10;i++)
cin>>arr[i];
#include <iostream.h>
// Binary Search Function
void binary_search (int a[ ] , int size , int key)
{
int low ,high ,mid ,flag ;
flag= 0;
low = 0;
high = size -1;
while (low <= high && flag ==0)
{
mid =(low +high)/2;
if ( key == a [mid])
{
flag=1;
break;
}
else if (key < a[mid ] )
{
high = mid -1;
}
else
{
low = mid +1;
}
Self-Instructional
Material 89
Searching and Sorting }
Algorithms
if ( flag ==1)
{
cout<<"value found at location"<<mid +1;
NOTES
}
else
cout<<"value not found";
}
void main()
{
int arr[10],i,k;
cout<<"Enter 10 values\n";
for(i=0;i<10;i++)
cin>>arr[i];
Sorting techniques: Bubble sort, Quick sort, Insertion sort, Merge sort
Sorting refers to the operation of arranging data in some given order such as
increasing or decreasing with numerical data and alphabetically with character
data.
Selection Sort
Selection sort algorithm starts by comparing first two elements of an array and
swapping if necessary.
Self-Instructional
90 Material
This algorithm is not suitable for large data sets as its average and worst Searching and Sorting
Algorithms
case complexities are of (n2), where n is the number of items.
3. Write a program to sort an array using selection sort.
//C++ program for selection sort NOTES
#include <iostream.h>
void selection_sort (int a[ ], int size )
{
int temp ,i,j, min;
}
}
//main function
void main()
{
int arr[10],i;
cout<<"Enter 10 values\n";
for(i=0;i<10;i++)
cin>>arr[i];
//call of selection sort function
selection_sort(arr,10);
cout<<" \n Sorted Values \n";
for(i=0;i<10;i++)
cout<<endl<<arr[i];
}
Self-Instructional
Material 91
Searching and Sorting Output:
Algorithms
NOTES
if(a[j]>a[j+1])
{
temp =a[j];
a[j]=a[j+1];
a[j+1]=temp;
} }
}
}
/main function
void main()
{
int arr[10],i;
cout<<"Enter 10 values\n";
for (i=0;i<10;i++)
Self-Instructional cin>>arr[i];
92 Material
//call of bubble sort function Searching and Sorting
Algorithms
bubble_sort(arr,10);
//main function
void main()
{
int arr[10],i,k;
cout<<"Enter 10 values\n";
for(i=0;i<5;i++)
cin>>arr[i];
//call of Insertion Sort function
insert_sort (arr, 5);
cout<<" \n Sorted Values \n";
for (i=0;i<5;i++)
cout<<endl<<arr[i];
}
Output:
Self-Instructional
94 Material
Algorithm for Quick Sort Searching and Sorting
Algorithms
QUICK_SORT ( ARRAY ,FIRST ,LAST )
1. SET LOW : = FIRST
SET HIGH : = LAST NOTES
SET PIVOT : =ARRAY[( LOW + HIGH) /2 ]
2. REPEAT THROUGH STEP 7 WHILE (LOW ?HIGH)
3. REPEAT STEP 4 WHILE (ARRAY [LOW]<PIVOT)
4. SET LOW := LOW+1
5. REPEAT STEP 6 WHILE (ARRAY [HIGH]>PIVOT)
6. SET HIGH := HIGH-1
7. IF (LOW <=HIGH)
ARRAY [LOW] <->ARRAY [HIGH]
SET LOW := LOW+1
SET HIGH:= HIGH-1
8. IF (FIORST<HIGH) THEN
QUICK_SORT (ARRAY,FIRST,HIGH)
9. IF (LOW < LAST)
QUICK_SORT (ARRAY,LOW,LAST)
10. END
6. Write a C++ program to sort an array using quick sort.
//C++ program for quick sort
#include <iostream.h>
void quick_sort (int a[ ], int first, int last)
{
int low ,high ,pivot, temp, i ;
low= first ;
high =last ;
pivot =a[(first +last)/2];
do
{
while (a[low]<pivot)
{
low++;
}
while (a [high]>pivot)
{
high--;
}
if(low <=high)
{ Self-Instructional
Material 95
Searching and Sorting temp= a [low];
Algorithms
a [low]= a[high];
a[high]= temp ;
low++;
NOTES
high--;
}
}while (low <=high);
if (first <high)
{
quick_sort (a, first, high);
}
if(low< last)
{
quick_sort (a, low, last);
}
}
void main()
{
int arr[10],i,k;
cout<<"Enter 10 values\n";
for(i=0;i<10;i++)
cin>>arr[i];
//call of Quick Sort function
quick_sort(arr,0,10);
Self-Instructional
96 Material
Algorithm for Shell Sort Searching and Sorting
Algorithms
ALGORITHM _ SHELL SHORT
INPUT _ LIST OF N ELEMENTS
OUTPUT _ LIST OF N ELEMENTS IN ASSENDING ORDER NOTES
SHELL_ SORT ( LIST ,SIZE)
1. [INITIALIZE]
SET GAP := N/2
2. REPEAT THROUGH STEP 6 WHILE GAP =0
SET SWAP := 0
4. REPEAT THROUGH STEP 6 WHILE SWAP=1
5. REPEAT THROUGH STEP 6 FOR I=1,3 ,.....I<(N-GAP)
6. IF ( LIST [I] > LIST [I+ GAP]) THEN
SET LIST [I] ,-. LIST [I+ GAP]
SET SWAP := 1
[END OF FOR LOOP ]
[END OF INNER WHILE LOOP]
[END OF OUTER WHILE LOOP]
7. END
7. Write a program to implement shell sort.
//C++ program for shell sort
#include <iostream.h>
{
int temp , gap ,i ,swap ;
gap = size /2 ;
do
{
do
{
swap =0;
for ( i=0 ; i < size-gap ; i ++)
{
if(a[i] > a[ i+ gap])
{
temp = a[i] ;
a[i] = a [i+ gap];
a[ i+ gap]= temp;
Self-Instructional
Material 97
Searching and Sorting
Algorithms
swap=1;
}}
}while ( swap ==1);
NOTES
gap= gap/2 ;
}while (gap >0) ;
}
void main()
{
int arr[10],i,k;
cout<<"Enter 10 values\n";
for(i=0;i<10;i++)
cin>>arr[i];
//call of shell sort function
shell_sort(arr,10);
cout<<" \n Sorted Values \n";
for(i=0;i<10;i++)
cout<<endl<<arr[i];
}
Output:
Try yourself:
(1) Write a program to sort n numbers in descending order using bubble sort.
(2) Write a program to implement selection sort method using functions.
(3) Write a program to sort the n names in an alphabetical order.
Self-Instructional
100 Material
.emaN e1.sruIncrease
oC eht fothe
ezifont
s tnosize
f ehof
t esthe
aerCourse
cnI .1 Name.
.egaP revoC e2.ht nuse
i rethe
daefollowing
h a sa gniwasolaloheader
f eht esin
u the
.2 Cover Page.
YTISREVINUALAGAPPA
APPAGALAUNIVERSITY
Master of Computer Applications
elcyC drihT eht ni )46.3:APGC( CA[Accredited
AN yb edarGwith
’+A’’A+’
htiwGrade
detidby
ercNAAC
cA[ (CGPA:3.64) in the Third Cycle
]CGU-DRHM yb ytisrevinU I–yrogeand
taC Graded
sa dedarasG Category–I
dna University by MHRD-UGC]
300 036 – IDUKIARA
KARAIKUDI
K – 630 003
315 14 NOITACUDE ECNATSIDDIRECTORATE
FO ETAROTCEOF
RIDDISTANCE EDUCATION
itnem sYou
a egaare
p reinstructed
voc eht etatodpupdate
u ot dethe
tcurcover
tsni erpage
a uoYas mentioned below:
.emaN e1.sruIncrease
oC eht fothe
ezifont
s tnosize
f ehof
t esthe
aerCourse
cnI .1 Name.
aP revoC e2.ht nuse
i rethe
daefollowing
h a sa gniwasolaloheader
f eht esin
u the
.2 Cover Page.
ISREVINUALAGAPPA
APPAGALAUNIVERSITY
Master of Computer Applications
rihT eht ni )46.3:APGC( CA[Accredited
AN yb edarGwith
’+A’’A+’
htiwGrade
detidby
ercNAAC
cA[ (CGPA:3.64) in the Third Cycle
]CGU-DRHM yb ytisrevinU I–yrogeand
taC Graded
sa dedarasG Category–I
dna University by MHRD-UGC]
300 036 – IDUKIARA
KARAIKUDI
TACUDE ECNATSIDDIRECTORATE
K
FO ETAROTCEOF
– 630 003
RIDDISTANCE EDUCATION
LAB: DATA STRUCTURE USING C++
I - Semester