0% found this document useful (0 votes)
59 views22 pages

Dsa Lab Manual Mca 22-23

Uploaded by

shahusarthak74
Copyright
© © All Rights Reserved
We take content rights seriously. If you suspect this is your content, claim it here.
Available Formats
Download as PDF, TXT or read online on Scribd
0% found this document useful (0 votes)
59 views22 pages

Dsa Lab Manual Mca 22-23

Uploaded by

shahusarthak74
Copyright
© © All Rights Reserved
We take content rights seriously. If you suspect this is your content, claim it here.
Available Formats
Download as PDF, TXT or read online on Scribd
You are on page 1/ 22

KJ’S Educational Institutes

TRINITY ACADEMY OF ENGINEEIRNG,


PUNE
(Accredited with ‘A’ grade by NAAC)

Department of MCA

LABORATORY MANUAL

DSA Laboratory
(Subject Code: 310906)

For the Academic Year 2022 - 2023


FYMCA- Semester I

DSA Lab Manual / SEM –I / 2022-23 Prof. Bisweswar Thakur


Teaching Scheme: Credit 02 Examination Scheme:
PR: 04Hours/Week TW:25Marks
PR: 50 Marks

PROGRAM OUTCOMES
PO No. Program Outcome Description
Apply knowledge of mathematics, computer science, computing specializations appropriate
PO 1 for real world applications.

Identify, formulate, analyze and solve complex computing problems using relevant domain
PO 2 disciplines.

Design and evaluate solutions for complex computing problems that meet specified needs with
appropriate considerations for real world problems.
PO 3
Find solutions of complex computing problems using design of experiments, analysis and
PO 4 interpretation of data.

Apply appropriate techniques and modern computing tools for development of complex
PO 5 computing activities.

Apply professional ethics, cyber regulations and norms of professional computing practices.
PO 6
Recognize the need to have ability to engage in independent and life-long learning in the
PO 7 broadest context of technological change.

Demonstrate knowledge and understanding of the computing and management principles and
PO 8 apply these to one’s own work, as a member and leader in a team, to manage projects and in
multidisciplinary environments.

Communicate effectively with the computing community and with society at large, such as,
PO 9 being able to comprehend and write effective reports and design documentation, make
effective presentations, and give and receive clear instructions.

Assess societal, environmental, health, safety, legal and cultural issues within local and global
contexts, and the consequent responsibilities relevant to the professional computing practices.
PO 10

Function effectively as an individual, and as a member or leader in diverse teams, and in


multidisciplinary environments.
PO 11

Identify a timely opportunity and use innovation, to pursue opportunity, as a successful


PO 12
Entrepreneur /professional.

DSA Lab Manual / SEM –I / 2022-23 Prof. Bisweswar Thakur


OBJECTIVE:

• To study the representation, implementation of basic data structures


• To study various linear & non liner data structures
• To implement applications of Data Structure in solving real life problems
• To study various searching & sorting algorithms
• To implement various searching & sorting techniques.

Course Outcomes
Implement elementary data structures such as Arrays, linked lists
CO 1
CO 2 Implement representation & application of Linked List

Demonstrate practical knowledge on the applications of stacks, queues


CO 3
CO 4 Implement nonlinear data structure trees to solve mathematical problems.

CO 5 Implement representations & the applications of graphs.

CO 6 Implement different searching and sorting algorithms.

Guidelines for Student Journal:


• The laboratory assignments are to be submitted by student in the form of journal.
• Journal consists of prologue, Certificate, table of contents, and handwritten write-up of
each assignment (Title, Objectives, Problem Statement, Outcomes, software & Hardware
requirements, Date of Completion, Assessment grade/marks and assessor's sign, Theory-
Concept in brief conclusion/analysis.
• Program codes with sample output of all Performed assignments are to be submitted as
softcopy. As a conscious effort and little contribution towards Green IT and environment
awareness, attaching printed papers as part of write-ups and program listing to journal may
be avoided. Use of DVD containing students’ programs maintained by lab In-charge is
highly encouraged. For reference one or two journals may be maintained with program
prints at Laboratory.

DSA Lab Manual / SEM –I / 2022-23 Prof. Bisweswar Thakur


Sample Programs:

EXPERIMENT NO. 01

TITLE: Write a program to implement Pattern Matching algorithm.

OBJECTIVE: To implement an algorithm that matches two different data values.

CONCEPT:
Pattern matching is the problem of deciding whether or not a given string pattern P appears in a string text T.
We assume that the length P does not exceed the length of T.

ALGORITHM:
(Pattern Matching) P and T are the strings with lengths R and S respectively, and are stored as arrays with one
character per element. This algorithm finds the INDEX of P in T.
1. [Initialize.] Set K: =1 and MAX: = S-R+1.
2. Repeat Step 3 to 5 while K<= MAX:
3. Repeat for L=1 to R: [Tests each character of P.]
If P [L]! = T [K+L-1], then: Go to Step 5.
[End of inner loop.]
4. [Success.] Set INDEX = K, and Exit.
5. Set K: =K+1.
[End of Step 2 outer loop.]
6. [Failure.] Set INDEX =0.
7. Exit

CONCLUSION:
In this way, we can implement pattern matching algorithm.

CODE
#include<stdio.h>
#include<conio.h>

void main()
{
char P[80]={"bab"};
char T[80]={"aabbbabb"};
int R,S,K,L,MAX,INDEX;
clrscr();

R=strlen(P);
S=strlen(T);
K=1;
MAX=S-R+1;

while(K<=MAX)
{
for(L=0;L<R;L++)
if(P[L]!=T[K+L-1])

DSA Lab Manual / SEM –I / 2022-23 Prof. Bisweswar Thakur


break;

if(L==R)
{
INDEX=K;
break;
}

else
K=K+1;
}
if(K>MAX)
INDEX=-1;

printf("P=%s",P);
printf("\n\nT = %s",T);

if(INDEX!=-1)
printf("\n\nIndex of P in T is %d",INDEX);
else
printf("\n\n P does not exist in T");

getch();

OUTPUT:

EXPERIMENT NO. 02

TITLE: Write a program to search a given element in an array using Linear Search.

OBJECTIVE: To implement searching technique of an element on unsorted array.

CONCEPT:
Suppose a linear array DATA contains n elements & suppose a specific ITEM of information is given by
user to search. We want to find location LOC of the ITEM in the linear array. If ITEM is not present in the array
then we set LOC=0 to indicate that ITEM is not present. In the linear search algorithm we compare ITEM one by

DSA Lab Manual / SEM –I / 2022-23 Prof. Bisweswar Thakur


one with each element in the DATA, until we finds the location LOC such that ITEM = DATA [LOC] following
algorithm finds the location LOC of ITEM in the array DATA or set LOC =0 the required algorithm is as follows.

PRIOR CONCEPT:
One dimensional array, array index, loop structures.

NEW CONCEPTS:
Preposition 1: List
It is the listing of elements which are ordered or unordered.
Preposition 2: Searching
Searching is the process to find the given key element in the list with its position. The searching is also referred as
the locate operation.
Preposition 3: Result of searching
The result of searching is given as key element found or not found along with the position of the element in the list.
Preposition 4: Comparisons required
The number of Comparisons required indicates the number of element tested with key element to reach the result

ALGORITHM:
1) [Initialise] set K=1 & LOC=0
2) Repeart step 3 & 4 while LOC=0 & K<= N
3) If ITEM = DATA[K] then: set LOC = K
4) Set K= K+1 [Increment Counter]
[end of step 2 loop]
5) If LOC =0 , then:
Write : ITEM is not found in array DATA
else
Write : LOC is Location of ITEM
[end of if statement.]
6) Exit.

APPLICATION:

Linear search is usually very simple to implement, and is practical when the list has only a few elements, or
when performing a single search in an unordered list.

ADVANTAGES:

• The linear search is simple - It is very easy to understand and implement;


• It does not require the data in the array to be stored in any particular order.

DISADVANTAGES:

• The linear search is inefficient - If the array being searched contains 20,000 elements, the algorithm will
have to look at all 20,000 elements in order to find a value in the last element. In an average case, an item is
just as likely to be found near the beginning of the array as near the end. Typically, for an array of N items,
the linear search will locate an item in N/2 attempts. If an array has 50,000 elements, the linear search will
make a comparison with 25,000 of them in a typical case. This is assuming that the search item is
consistently found in the array. N/2 is the average number of comparisons. The maximum number of
comparisons is always N.

DSA Lab Manual / SEM –I / 2022-23 Prof. Bisweswar Thakur


CONCLUSION:
In this way, we can search an element in array using leaner search.

CODE
#include<stdio.h>
#include<conio.h>
void main()
{
int i , ser , s;
int a[20];
clrscr();
printf("enter total no. of element");
scanf("%d",&s) ;
for (i=0;i<s;i++)
{
printf("enter the element");
scanf("%d",&a[i]);
}
printf("enter the element to be searched");
scanf("%d",&ser);
for(i=0;i<s;i++)
{
if(ser==a[i])
{
printf("element exist in array:%d",i+1);
break;
}
}
if(ser!=a[i])
printf("element does not exist in array");
getch();
}

OUTPUT:

DSA Lab Manual / SEM –I / 2022-23 Prof. Bisweswar Thakur


EXPERIMENT NO. 03

TITLE: Write a program to search a given element in an array using Binary Search.

OBJECTIVE: To implement searching technique of an element on sorted array.

CONCEPT:
Suppose DATA is an array which is sorted in increasing numerical order or, equivalently, alphabetically.
Then there is an extremely efficient searching algorithm called Binary search, Which can be used to find the location
LOC of a given ITEM of information in DATA.

ALGORITHM:
(Binary Search) BINARY (DATA, UB, LB, ITEM, LOC)
Here DATA is sorted array with lower bound LB and upper bound UB, and IETM is a given item of
information. The variables BEG, END and MID denote respectively the beginning, end and the middle locations of a
segment of elements of DATA. This algorithm finds the location LOC of ITEM in DATA or sets LOC=NULL.

1) [Initialize segment variables.]


Set BEG: =LB, END: = UB and MID: = INT ((BEG+END)/2)

2) Repeat step 3 & 4 while BEG <= END and DATA [MID]! = ITEM

3) If ITEM < DATA [MID], then:


Set END = MID -1
Else:
Set BEG: = MID +1
[End of If structure]

4) Set MID: = INT ((BEG +END) /2)


[End of step 2 loop.]

5) If DATA [ MID ] =ITEM , then:


Set LOC: = MID
Else
Set LOC: = NULL
[End of If structure]
6) Exit.

CONCLUSION:
In this way, we can search an element in an array using binary search.

DSA Lab Manual / SEM –I / 2022-23 Prof. Bisweswar Thakur


CODE

#include<stdio.h>
#include<conio.h>
void main()
{
int n,i,search,f=0,low,high,mid,a[20];
clrscr();
printf("Enter the n value:");
scanf("%d",&n);
for(i=1;i<=n;i++)
{
printf("Enter the number in ascending order a[%d]=",i);
scanf("%d",&a[i]);
}
printf("Enter the search element:");
scanf("%d",&search);
low=1;
high=n;
while(low<=high)
{
mid=(low+high)/2;
if(search<a[mid])
{
high=mid-1;
}
else if(search>a[mid])
{
low=mid+1;
}
else
{
f=1;
printf("obtained in the position %d:",mid);
getch();
exit();
}
}
if(f==0)
{
printf("not present");
}
getch();
}

DSA Lab Manual / SEM –I / 2022-23 Prof. Bisweswar Thakur


OUTPUT:

EXPERIMENT NO. 04

TITLE: Write a program to sort the elements in an array using Bubble Sort.

OBJECTIVE: To implement sorting technique for array.

CONCEPT:
Proposition 1: List
It is the ordered list in which the elements are arranged in particular order by some criteria. The general order are
ascending order and descending order.
Proposition 2: Passes
The number of passes indicate the number of times the list is scanned to sort the list
Proposition 3: Exchanges
The number of exchanges indicates the number of elements swapped or exchanged till.
Proposition 4: Comparisons
The number of comparisons indicates the number of comparisons occurred in pass.

PRIOR CONCEPTS:
One dimensional array, loop structure, lists, comparisons.

ALGORITHM:
BUBBLE (DATA, N)
Here DATA is an array with N elements this algorithm sorts the elements in DATA.
1) Repeat steps 2 & 3 for K=1 to N-1
2) Set PTR = 1 [initialize pass pointer PTR]
3) Repeat while PTR <= N-K [execute pass]
a) If DATA[PTR] > DATA [PTR+1], then :
Interchange DATA [PTR] & DATA [PTR+1]
[end of if structure]

b) Set PTR= PTR+1


[end of inner loop]

DSA Lab Manual / SEM –I / 2022-23 Prof. Bisweswar Thakur


[end of step 1 outer loop]

4) Exit.

• APPLICATION :
Among various other sorting algorithm, bubble sort algorithm is one of the popular and frequently used
algorithm to sort elements either in ascending or descending order.

• ADVANTAGES :-
Simple to write, easy to understand and it takes few lines of code. The data is sorted in place so there is
little memory overhead and once sorted, the data is in memory , ready for processing

• DISADVANTAGE :-
Bubble sort should be avoided in case of large collections. It will not be efficient in case of reverse
ordered collection.
Bubble sort is not a practical sorting algorithm when n is large.
The major advantage is the amount of time it takes to sort.
The average time increases almost exponentially as the no. of table elements increase. Ten times the no.
of items takes almost one hundred times as long to sort.

• COMPLEXTY OF THE BUBBLE SORT ALGORITHM :-


The time for a sorting algorithm is measured in terms of the number of comparisons. The number f(n) of
comparisons in the bubble sort is easily computed specifically there are n-1 comparisons during the
first pass which places the largest element in the last position , there are n-2 comparisons in the
second pass which places the second largest element in the next to last position and so on…
Thus,
F(n) = (n-1)+ (n-2) + ………+ 1
= n (n-1) / 2
= n2/2 + n/2

F(n) = O(n)

CONCLUSION:
In this way, we can sort the elements in an array using Bubble sort.

CODE
#include<stdio.h>
#include<conio.h>
int DATA[10]={54,64,95,21,13,24,72,66,42,32};
int n=10;
void BUBBLE();

DSA Lab Manual / SEM –I / 2022-23 Prof. Bisweswar Thakur


void main()
{
int i;
clrscr();
printf("The elements in array before sorting \n") ;
for(i=0; i<n; i++)
{
printf("\t %d",DATA[i]) ;
}
BUBBLE();
printf("The elements in array after sorting \n");
for(i=0 ; i<n ; i++)
{
printf("\t %d", DATA[i]);
}
}
void BUBBLE()

{
int k , ptr ,temp;
for(k=1; k<=(n-1);k++)
{
for(ptr=0 ; ptr<=(n-k-1); ptr++)
{
if (DATA[ptr]> DATA[ptr+1])
{
temp=DATA[ptr];
DATA[ptr]=DATA[ptr+1];
DATA[ptr+1]=temp;
}
}
}
}

OUTPUT:

DSA Lab Manual / SEM –I / 2022-23 Prof. Bisweswar Thakur


EXPERIMENT NO. 05

TITLE: Write a program to implement Linked list and perform operations like traversing a linked list.

OBJECTIVE: To implement the data structure singly linked list and perform operation of traversing and searching a
list.

CONCEPT:
The linked list is the ordered list in which each element is represented by node with explicit address of next element.
The use of link or pointer to refer to element of list implies that element, which are logically adjacent, need not to be
physically adjacent in the memory.
In this program we will traverse and search in the linked list.

ALGORITHM
(Traversing a Linked List) Let LIST be a linked list in memory. This algorithm traverses LIST, applying an
operation PROCESS to each element of LIST. The variable PTR points to the node currently being processed.

1. Set PTR: = START.


2. Repeat Step 3 and 4 while PTR! =NULL.
3. Apply PROCESS to INFO [PTR].
4. Set PTR: = LINK [PTR]. [PTR now points to the next node.]
[End of Step 2 loop.]
5. Exit.

CONCLUSION:
In this way, we can perform operations like traversing in linked list.

CODE
#include<stdio.h>
#include<conio.h>

int LIST[20];
int LINK[20];
int START;

void main()
{
int PTR;
clrscr();

LIST[0]=22;LIST[2]=5;LIST[3]=19;LIST[5]=87;LIST[7]=29;LIST[8]=79;
LIST[9]=33;LIST[11]=2;LIST[13]=50;LIST[14]=8;LIST[16]=55;LIST[18]=99;

LINK[0]=3;LINK[2]=13;LINK[3]=2;LINK[5]=8;LINK[7]=14;LINK[8]=9;
LINK[9]=18;LINK[11]=16;LINK[13]=5;LINK[14]=-1;LINK[16]=0;LINK[18]=7;

DSA Lab Manual / SEM –I / 2022-23 Prof. Bisweswar Thakur


START=11;

printf("Initial LIST:\n 2 \t 55 \t 22 \t 19 \t 5 \t 50 \t 87 \t 79 \t 33 \t 99 \t 29 \t 8\n");

PTR=START;
printf("\n\n LIST After Traversal: \n");
while(PTR!=-1)
{
printf("%d\t",LIST[PTR]);
PTR=LINK[PTR];
}

getch();
}

OUTPUT:

EXPERIMENT NO 6.

TITLE: Write a program to implement abstract data type Stack.

OBJECTIVE: To implement abstract data type Stack with two operations push and pop.

CONCEPT:
A stack is a last in first out (LIFO) abstract data type and data structure. A stack can have any abstract data
type as an element, but is characterized by only two fundamental operations, the push and the pop.
The push operation adds to the top of the list, hiding any items already on the stack, or initializing the stack
if it is empty. The pop operation removes an item from the top of the list, and returns this value to the caller. A pop
either reveals previously concealed items, or results in an empty list.

ALGORITHM:
PUSH (STACK, TOP, MAXSTK, ITEM)
This procedure pushes an ITEM onto a stack.
1. [Stack already filled?]

DSA Lab Manual / SEM –I / 2022-23 Prof. Bisweswar Thakur


2. If TOP = MAXSTK, then: Print: OVERFLOW, and Return.
3. Set TOP: = TOP+1. [Increase TOP by 1.]
4. Set STACK [TOP]:= ITEM. [Insert ITEM in new TOP position.]
5. Return.

POP (STACK, TOP, ITEM)


This procedure deletes the top element of STACK and assigns it to the variable ITEM.

1. [Stack has an item to be removed?]


2. If TOP = 0, then: Print: UNDERFLOW, and Return.
3. Set ITEM: = STACK [TOP]. [Assign TOP element to ITEM.]
4. Set TOP: = TOP – 1. [Decrease TOP by 1.]
5. Return.

CONCLUSION:
In this way, we can implement abstract data type stack.

CODE:

#include<stdio.h>
#include<conio.h>
#define MAX 10
struct stack
{
int arr[MAX];
int top;
};

void initstack(struct stack*);


void push(struct stack *,int item);
int pop(struct stack *);
void main()
{
struct stack s;
int i;
clrscr();
initstack(&s);
push(&s,11);
push(&s,23);
push(&s,-8);
push(&s,16);
push(&s,27);
push(&s,14);
push(&s,20);

DSA Lab Manual / SEM –I / 2022-23 Prof. Bisweswar Thakur


push(&s,39);
push(&s,2);
push(&s,15);
push(&s,7);
i=pop(&s);
printf("\n item popped: %d",i);
i=pop(&s);
printf("\n item popped: %d",i);
i=pop(&s);
printf("\n item popped: %d",i);
i=pop(&s);
printf("\n item popped: %d",i);
i=pop(&s);
printf("\n item popped: %d",i);
getch();
}
void initstack(struct stack *s)
{
s->top= -1;
}

void push(struct stack *s, int item)


{
if(s->top==MAX-1)
{
printf("\nStack is full");
return;
}
s->top++;
s->arr[s->top]=item;
}

int pop(struct stack * s)


{
int data;
if(s->top==-1)
{
printf("\n Stack is emplty");
return NULL;
}
data=s->arr[s->top];
s->top--;
return data;
}

DSA Lab Manual / SEM –I / 2022-23 Prof. Bisweswar Thakur


OUTPUT:

EXPERIMENT NO. 07

TITLE: Write a program to implement Tower of Hanoi problem for n number of disks.

OBJECTIVE: To study the implementation of recursive algorithms.

CONCEPT:
Tower of Hanoi is an example of recursion that can be used as tool in developing algorithm to solve a
particular problem.
Suppose three pegs labeled A, B and C are given and suppose on peg A there are placed a finite number n of
disks of decreasing size. The object of the game is to move the disks from peg A to peg C using peg B as an
auxiliary. The rules are as follows:
a. Only one disk may be moved at a time. Specifically only the top disks on any peg may be moved to any
other peg.
b. At no time can a larger disk be placed on a smaller disk.

ALGORITHM:
TOWER (N, BEG, AUX, END)
This procedure gives a recursive solution to the Tower of Hanoi problem for N disks.
1. If N=1 , then:
a. Write: BEG-> END.
b. Return.
[End of if structure.]
2. [Move N-1 disks from peg BEG to peg AUX.]
Call TOWER (N-1, BEG, END, AUX).
3. Write: BEG-> END.
4. [Move N-1 disks from peg AUX to peg END.]
Call TOWER (N-1, AUX, BEG, END).
5. Return.

DSA Lab Manual / SEM –I / 2022-23 Prof. Bisweswar Thakur


CONCLUSION:
In this way, we can implement Tower of Hanoi problem.

CODE:

#include<stdio.h>
#include<conio.h>
#include<math.h>
void hanoi(int x, char from,char to,char aux)
{

if(x==1)
{
printf("Move Disk From %c to %c\n",from,to);
}
else
{
hanoi(x-1,from,aux,to);
printf("Move Disk From %c to %c\n",from,to);
hanoi(x-1,aux,to,from);
}

}
void main()
{
int disk;
int moves;
clrscr();
printf("Enter the number of disks you want to play with:");
scanf("%d",&disk);
moves=pow(2,disk)-1;
printf("\nThe No of moves required is=%d \n",moves);
hanoi(disk,'A','C','B');
getch();
}

DSA Lab Manual / SEM –I / 2022-23 Prof. Bisweswar Thakur


OUTPUT:

EXPERIMENT NO. 08

TITLE: Write a program to sort the elements in an array using Selection Sort.

OBJECTIVE: To implement sorting technique for array.

CONCEPT:
Proposition 1: Sorted list
It is the ordered list in which the elements are arranged in particular order by some criteria. The general order are
ascending order and descending order.
Proposition 2: Passes
The number of passes indicate the number of times the list is scanned to sort the list
Proposition 3: Exchanges
The number of exchanges indicates the number of elements swapped or exchanged till.

ALGORITHM:

A) MIN (A, K, N, LOC)


An array A is in memory. This procedure finds the location LOC of the
Smallest element among A [K], A [K+1] . . . , A [N].
1. Set MIN: = A [K] and LOC: = K. [Initializes pointers.]
2. Repeat for J = K+1, K+2 . . . , N:
If MIN > A [J], then: Set MIN: = A [J] and LOC: = A [J] and LOC := J.
[End of loop.]
3. Return

B) (Selection Sort) SELECTION (A, N)

DSA Lab Manual / SEM –I / 2022-23 Prof. Bisweswar Thakur


This algorithm sorts the array A with N elements.
1. Repeat Steps 2 and 3 for K = 1, 2. . . N-1:
2. CALL MIN (A, K, N, LOC)
3. [Interchange A [K] and A [LOC].]
Set TEMP: = A [K], A [K] := A [LOC], and A[LOC] := TEMP
[End of Step 1 loop.].
4. Exit

ADVANTAGES:-
Extremely fast

DISADVANTAGE:-
Very complex, massively recursive

COMPLEXTY OF THE SELECTION SORT ALGORITHM:-


The number f (n) of comparisons in the selection sort algorithm. It is independent of the original order of the
elements. Observe that MIN (A, K, N, LOC) requires N-K comparisons . That is there are N-1 comparisons during
pass 2 to find the second smallest element and so on Accordingly :-
f ( n ) = (N-1) + ( N-2) +. . . . + 2 + 1 = ( n (n - 1 ))/ 2 = o ( n* n)
The above result is summarized in the following table:
Algorithm Worst Case Average case
SELECTION SORT N(N-1))/ 2 = O (N*N) (N(N-1)) / 2 = O ( N*N)

CONCLUSION:
In this way, we can sort the elements in an array using selection sort.

CODE

#include <stdio.h>
#include<conio.h>
Void main ()
{
int A[20], N, Temp, i, j;
printf("\n\n\t ENTER THE NUMBER OF TERMS...: ");
scanf("%d",&N);
printf("\n\t ENTER THE ELEMENTS OF THE ARRAY...:");
for(i=1; i<=N; i++)
{
scanf("\n\t\t%d", &A[i]);
}
for(i=1; i<=N-1; i++)
for(j=i+1; j<=N;j++)

DSA Lab Manual / SEM –I / 2022-23 Prof. Bisweswar Thakur


if(A[i]>A[j])
{
Temp = A[i];
A[i] = A[j];
A[j] = Temp;
}
printf("\n\tTHE ASCENDING ORDER LIST IS...:\n");
for(i=1; i<=N; i++)
printf("\n\t\t\t%d",A[i]);
getch();
}

OUTPUT:

DSA Lab Manual / SEM –I / 2022-23 Prof. Bisweswar Thakur


Content of Lab Experiments for Journal

S.No. Title of Program


1 Write C/C++ program to store marks scored for first test of subject 'Data Structures and Algorithms'
for N students. Compute
i. The average score of class.
ii. Highest score and lowest score of class.
2 Write a menu driven program to perform following operations on singly linked list: Create, Insert,
Delete, and Display.
3 Write a program to implement abstract data type Stack (Push & Pop operation).
4 In any language program mostly syntax error occurs due to unbalancing delimiter such as (),{},[].
Write C/C++ program using stack to check whether given expression is well parenthesized or not.

5 Write a C/C++ program to convert infix to Postfix expression.

6 Pizza parlour accepting maximum M orders. Orders are served in first come first served basis. Order
once placed cannot be cancelled. Write C/C++ program to simulate the system using circular queue
using array.

7 Represent graph using adjacency list/adjacency matrix and perform Depth First Search.

8 Create binary tree. Find height of the tree and print leaf nodes. Find mirror image, print original and
mirror image using level-wise printing.

9 Write C/C++ program to store first year percentage of students in array. Write function for sorting
array of floating-point numbers in ascending order using Insertion Sort.

10 Write a program to sort the elements in an array using Bubble Sort.

11 Write a program to search a given element in an array using Binary Search.

12 Write a C/C++ program to implement Kruskal minimum cost spanning tree algorithm.

DSA Lab Manual / SEM –I / 2022-23 Prof. Bisweswar Thakur

You might also like

pFad - Phonifier reborn

Pfad - The Proxy pFad of © 2024 Garber Painting. All rights reserved.

Note: This service is not intended for secure transactions such as banking, social media, email, or purchasing. Use at your own risk. We assume no liability whatsoever for broken pages.


Alternative Proxies:

Alternative Proxy

pFad Proxy

pFad v3 Proxy

pFad v4 Proxy