0% found this document useful (0 votes)
42 views

DS - Practical - 1

DATA STRUCTURES

Uploaded by

Soha KULKARNI
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)
42 views

DS - Practical - 1

DATA STRUCTURES

Uploaded by

Soha KULKARNI
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/ 16

TITLE DAT DATE REMARK

SR. OF OF PAGE
NO. PERFORME SUBMISsION NO.
RS
Program to implement 21/10/21 21/10/21

linearand binary search._ 26/ 10/21 28/ 10/21


Program to implement
bubblesort, selection sort
insertionsortalgorithm.
Program to implement 09/11/21 11/11/21
stack. 16/11/21
Program to implement 18/11/21
linear queue.
Program to implement 23/11/21 25/11/21
circular queue.
6. Program to implement 30/11/21 30/11/21
singly linearlinked list 2/12/21 2/12/21
Program to implement
circular linkedlist.
8. Program to implement 14/12/21 16/12/21

doubly linked list. 21/ 12/21


9. A] Program to implement 23/12/21
linked list as stack.
B] Program to implement
linked list as queue.
10. Program to implement 28/12/21 28/12/21
Binary Tree and
traversing methods.
11 Program to implement 30/12/21 30/12/21
Binary search tree.
12. Program to implement 4/1/22 4/1/22
BFS.
13. Program to implement 6/1/22 6/1/22
DFS.
CERTIFICATE

This is to certify that Shri/Miss


LIZNA NURUDDIN CHARANIYA
of Class SYDCP_Roll No.204041 Exam No.204041 has satisfactorily
completed the Term-work in subject DATA STRUCTURE as detailed
above within the four walls of the institute during period from 2021-
2022

Date: Staff Member Head of the Department


cIASSMAte
Dete
Page:
PRACTICAL No. 1 204OL

tle Brogam o implement lineun seanch und bincay seanch


hea
Zinea Seahch
Elements uhe nd Sequentuallu sohhnqac
nst element and the pnocessis tenmiaated hec
element isound O L list is exhausted

binguY SecULch
Sincony seaLdnis secndh alaonith Bnat ods
the posihon o a tnqet vaee uithun sonted unau
Binunu Secacn_companes the thqet value to the middle
elemenE o the anau

Algothm to Seclch a_pamaaulcn element n an


a u LuSLnc linean seandh methoc

4nhuige laq 0, n,aLiO,key


Recd eements in n y

3 Keperut ton (eO unb Ln

if CaLi keuy)
Thenpanint Elem.ent
tOund

Laq
3n t 5
cIASSMAte
Dete
Pugo
20 +oLEL

inme camplexuhs 3n 5

Alqamitbhm bo nd an element in tac auLc usiAG biaay


secch methad

Laitialae aca=0 loudO hian =n- keu


2. Repeat unil high low
mic=Cow +high)/2

a Lmid = keu4
then aq
pnint elenaent found.
5 ifCaCmicl> key)
then set high mid-

else
loL mid

flaq=o)
paint Element not ound

Concusion
n this paachca we enned hoo)secnching
aethods linean seanch and bincy seanch and theia
thein
imple.mentationcnc cuqoatha
File Edit View Git Project Build Debug Test Analyze Tools Extensions Window Help Full Screen Search (Ctrl-Q LC

linear_search_assignment.c X
Miscellaneous Files (Global Scope) 9 main0

#include <stdio.h> //Header Files


#include<conio. h>
3 void main ()
int list[20], n, i, s; //declaration
printf("Enter the size of the list: "); I/Taking in the number of elements from the user

scanf("%d", an);

printf("Enter the %d elements of the 1ist: ", n); 1/Taking in the elements of the array from the user
18 for (i = e; i < n; i++)
11
scanf("%d", 8list[i])
13
14 printf("Enter the element you are searching for:"); //Taking in the value to be searched from the user
15 scanf("%d", &s);
16
17 for (i 0 ; i < n; i++) //Linear search
18
19 if (s == list [i]) //Checking if the value of s matches any of the values from the array
26

21 printf("Element found at index %d", i);


22 break;

25 if (i ==
n)
26 printf("Given element not found in the list") ;
27 getch();
28

1006 No issues found Ln: 25 Ch: 13 Col: 16 TABS CRLF

tem() Saved tAdd toSource Control


Developer Command Prompt for VS 2019 - linear_search_assignment.exe

C:\Users \AkRoz\source\repos\DS>cl.exe/c /EHsc 1inear_search_assignment.c


Microsoft (R) C/C++ Optimizing Compiler Version 19.29.30136 for x86
Copyright (C) Microsoft Corporation All rights reserved.
.

linear_search_assignment.c
:\Users \AkRoz \ source\repos \DS> l ink.exe linear_search_assignment .obj
Microsoft (R) Incremental Linker Version 14.29.30136.0
Copyright (C) Microsoft Corporation . All rights reserved.

C: \Users\AkRoz \ source \repos \DS> 1inear_search_assignment. exe


Enter the size of the list:5
Enter the 5 elements of the list:1 2 3 4 5
Enter the element you are searching for:4
Element found at index 3
C: \Users \AkRoz \ source\repos \DS>linear_search _assignment . exe
Enter the size of the list:5
Enter the 5 elements of the 1list: 1 2 3 4 5
Enter the element you are searching for:6
Given element not found in the list.

Type here to search o t D Desktop 30°C


245 PM
10/28/2021
1 #include <stdio.h>
2
3 int main()
4
5 int i, mid, high, low, n, search, array[100];
printf( "Enter number of elements\n");
scanf("%d", &n);
9
10 printf("Enter %d integers\n", n);
11
12 for (i = 0; i < ns; i++)
13 scanf("%d", &array[i])
14
15 printf("Enter value to find\n");
16 scanf( "%d", &search) ;
17
18 low 0
19 high n 1 ;
20 mid (low+ high)/ 2;
21
22 while (low «= high) {
23 if (array[mid] < search)
24
25 low mid + 1;
26
27 else if (array [mid] - search)
28
29 printf("%d found at location %d.\n", search, mid+1);
30 break
31
32 else
33
34 high mid 1;
35
36 mid (low high) / 2;
37
38 if (low high)
39 printf("Sorry, Not found! %d is not present in the list.\n", search);
40 return ;
41 }
Developer Command Prompt for VS 2019

C: \Users\AkRoz\source\repos\DS>binarysearch.exe
Enter number of elements
11
Enter 11 integers
5 10 12 21 27 30 52 77 78 89 91
Enter value to find
89
89 found at location 1.

C:
\Users\AkRoz\source\repos \DS>binarysearch.exe
Enter number of elements
11
Enter 11 integers
5 10 12 21 27 30 52 77 78 89 91
Enter value to find
10
10 found at location 2.

C: \Users\AkRoz \ source\repos \DS >binarysearch.


Enter number of elements
exe

11
Enter 11 integers
5 10 12 21 27 30 52 77 78 89 91
Enter value to find
125
Sorry, Not found! 125 is not present in the list.

C: \Users \AkRoz \source \repos \DS

4:40 PM
Type here to search Desktop 30°C 10/30o/2021
Page No
YouvA
Dato

20uOLL
Linea SeaxchDay Kuun

Disadvantuge Hiqh time Compleait

sEgSCAKCECLC,NITeM)

Set Flag CNot found)


wCTC OCn)

Einclude <stdio:h>

VOLd

Secrca
a t a a l 20S13e Sige S
Eatez tne s3e
Eater 5-elewents 3
o O,<5,1t)

ScenCZ &cATCiD,

the element te be ound '.seench = 4


Entez
S c a n f Y d " & seazchl

oYiO ik S F

b<5,2
seahch ag+C))
2 -F
2 2<9
painEECElementou HÉ3
a t .dTncdesi)
2 3 3<5 V

Cies s13e
pmintCGiven Element nat
faund"
Lizra Chaanit
2040Lt

1139 52 10 12 2178 L30 27 5


Tndex- 0 2 3 L S G 7 8

SORT
5 o12 21 27 90 S2 -7 73 89
Isuadexo 23 SG 78 9 1o

hiqh ld n Seachcla. Ckey ).


LO

hian mid n Secech Cheu


10
2

low hiah mt'd n Seahch Ckeq


L 125

LO
L
When Secmch E 2
loaatim 12
8 fotund a t

LhenScanch=10,
OJowndat at loccdi.on2

LOhea Seanch=1 2 S

Soau nst ound not pnasent


#include <stdio.h
int main C)
int
nt 1 l o , hiah mtd,nSecncaanhau COo
paint@Cnte numbe n_ot elements")
Scant Cd,&n)3
pont C Eate.n the arha elements
foaCi0,i4n iat)

scanf CY.d"aseha Ci
93int C Entethe vaulue to seanch \n
aunt C d", seanch)
low a O
hiqn n-
micl= low +hiqh)/2
Seanch- S9
cohile CCElo )-Tue
iCcounau Cs] 8 )
ie, if C30<89)
lo S+|

mica CGALo)/2
=8

ohile C6<=l6) Tue

Cancuy Ce3<8q)
i,e C148)

DLd= 19/2

tohile CG<=lo -

iC89<3) -False
else fCaiauC9= se.cmch)-TLce
else f CEq 8 ) Taue
39 ound at lacahion Cnid +) L
Reseanch)= 0

uhile CoE10) T
ifCancu CSJSro)
C30 <Ie) F

else f C30-=ICo)-F
else
hiq h =S- =
u

mid =4/2=2

tohile Co4= H ) - T

rf 2 lo) F

elsei G2 = lo) -F
else
high 2-1

while CoL=) T
ifC5< 10)
low= O t =

mid (aD/2=
uhile CIZE) T

if CIO1o).
else i ( o : o ) T

lecobon (aaid L) -2
0aheh 125
ohilo Co4a to)
IC.3o<125)
latw
Cod- 8

ohle CG<=lo) T
1C78<125)
(MLcd a )

tulaile C<1o)
rCaS125)
Jow 9+ 1O
CAL [o)
Lahile Cfo<- LoD
C 125)
Jow
(at'd 10)

cohile CU<EI6)
loopfeaminated

Soy12S not panese

You might also like