0% found this document useful (0 votes)
26 views25 pages

Dsu MP

The document discusses different searching methods in data structures. It describes linear search and binary search, explaining their working, time and space complexity, algorithms, and providing examples. Linear search sequentially checks each element while binary search works on sorted data by eliminating half of elements at each step.

Uploaded by

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

Dsu MP

The document discusses different searching methods in data structures. It describes linear search and binary search, explaining their working, time and space complexity, algorithms, and providing examples. Linear search sequentially checks each element while binary search works on sorted data by eliminating half of elements at each step.

Uploaded by

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

JSPM’s

JAYAWANTRAO SAWANT POLYTECHNIC,


Handewadi Road, Hadapsar, Pune-28
Department of Computer Engineering
Academic Year 2023-24

MICRO PROJECT:
TITLE OF THE PROJECT- SEARCHING METHODS

Program: CO Program code: CO3I


Course: DSU Course code: 22317
Class: SYCO3 Group: I
Project Guide: Mrs. S.S.Wable.

1
MAHARASHTRA STATE BOARD OF
TECHNICAL EDUCATION
CERTIFICATE

This is to certify that Mr./Ms. Akhilesh Tushar Gawade, Aryan Dnyaneshwar


Panchal, Abhijeet Rajkumar Pawar, Anisha Sunil Mane of III Semester of
Diploma in Computer Engineering of Institute Jayawantrao Sawant Polytechnic
(Code: 0711) has completed the Micro Project satisfactorily in Subject – DSU (22317)
for the academic year 2023- 2024 as prescribed in the curriculum.

Place: Hadapsar, Pune Enrollment No: 2207110609


2207110610
2207110611
2207110612

Date: Exam Seat No:

Subject Teacher Head of the Department Principal

2
Group Details

Sr no. Name of group members Roll no. Enrollment Seat no.


no.

1 Akhilesh Tushar Gawade 173 2207110609

2 Aryan Dnyaneshwar Panchal 174 2207110610

3 Abhijeet Rajkumar Pawar 175 2207110611

4 Anisha Sunil Mane 176 2207110612

Name of guide: Mrs. S. S. Wable

3
INDEX

Sr No. Content Page No.

1 Certificate 2

2 Group Details 3

3 Index 4

4 Annexure IA (part A) 5

5 About Searching and its types 6

6 Linear search 7

7 Binary search 14

8 Annexure II A (Part B) 21

9 Annexure IV (Teachers Evaluation Sheet) 22

4
JSPM’s
JAYAWANTRAO SAWANT POLYTECHNIC,
Handewadi Road, Hadapsar, Pune-28
Department of Computer Engineering
Academic Year 2023-24

Title of Micro project: Searching Methods


1.0 Brief Introduction:
Made a Program using C language.

2.0 Aim of Micro Project:


We learnt to make programs using C language
3.0 Action Plan (Sequence and time required for major activities for 8 week)
Sr. Details of activity Planned start Planned Name of
No date Finish date Responsible
Team members

1 Collecting the information of view 20-Aug-2023 20-Sep-2023 Abhijeet Pawar,


Aryan Panchal,
2 Sorting the information of view 20-Sep-2023 20-Oct-2023
Akhilesh Gawade,
3 Compilation of the project 20-Oct-2023 28-Oct-2023
Anisha Mane
4 Submission of the project 28-Oct-2023 28-Oct-2023

4.0 Resources required (major resources such as raw material, some machining facility,
software etc.)
Sr. No. Name of resource Specification Quantity Remarks

1 Laptop/Computer Windows 11 1
Processor 8GB RAM

2 Software Google Chrome, 1


Microsoft Edge,
Turbo C, MS Word

3 Other - -

5
6
TITLE OF THE PROJECT: SEARCHING METHODS

❖ Searching: -

Searching in data structure refers to the process of finding the required information from a
collection of items stored as elements in the computer memory. These sets of items are in
different forms, such as an array, linked list, graph, or tree. Another way to define searching
in the data structures is by locating the desired element of specific characteristics in a
collection of items.

❖ Types of searching: -

1. Linear search/Sequential search


2. Binary search/Interval search

1. Linear search/Sequential search:-

The list or array of elements is traversed sequentially while checking every component of
the set.

2. Binary search/Interval search:-

The interval search includes algorithms that are explicitly designed for searching in sorted
data structures. In terms of efficiency, these algorithms are far better than linear search
algorithms.

7
▪ Linear search/sequential search: -

The linear search algorithm iteratively searches all elements of the array. It has the best
execution time of one and the worst execution time of n, where n is the total number of items
in the search array.It is the simplest search algorithm in data structure and checks each item
in the set of elements until it matches the searched element till the end of data collection.
When the given data is unsorted, a linear search algorithm is preferred over other search
algorithms.

▪ Working of linear search

● Every element is considered as a potential match for the key and checked for the same.

● If any element is found equal to the key, the search is successful and the index of that
element is returned.

● If no element is found equal to the key, the search yields “No match found”.

● For example: Consider the array arr[] = {10, 50, 30, 70, 80, 20, 90, 40} and key = 3

Step 1: Start from the first element (index 0) and compare key with each element (arr[i]).

Comparing key with first element arr[0]. SInce not equal, the iterator moves to the next
element as a potential match.

Comparing key with next element arr[1]. SInce not equal, the iterator moves to the next
element as a potential match.

8
Step 2: Now when comparing arr[2] with key, the value matches. So the Linear Search
Algorithm will yield a successful message and return the index of the element when key is
found (here 2).

9
▪ Complexities in linear search are: -

▪ Space Complexity

Since linear search uses no extra space, its space complexity is O(n), where n is the
number of elements in an array

▪ Time Complexity

Best-case complexity = O(1) occurs when the searched item is present at the first element
in the search array.
Worst-case complexity = O(n) occurs when the required element is at the tail of the array
or not present at all.
Average- case complexity = average case occurs when the item to be searched is in
somewhere middle of the Array.

10
▪ Algorithm of linear search/sequential search

Step 1: Set i to 1
Step 2: if i > n then go to step 7
Step 3: if A[i] = x then go to step 6
Step 4: Set i to i + 1
Step 5: Go to Step 2
Step 6: Print Element x Found at index i and go to step 8
Step 7: Print element not found
Step 8: Exit

▪ Flowchart of linear search/Sequential search

11
▪ C PROGRAM OF LINEAR SEARCH

#include<stdio.h>
#include<conio.h>
void main()
{
int a[100],i,key,n;
clrscr();
printf("\n Enter size of array");
scanf("%d",&n);
printf("\n Enter array elements");
for(i=0;i<n;i++)
{
scanf("%d",&a[i]);
}
printf("Enter the key element to be searched");
scanf("%d",&key);
for(i=0;i<n;i++)
{
if(a[i]==key)
{
printf("Element found at index %d \n",i);
break;
}
}
if(i==n)
{
printf("\nElement not found in array");
}
getch();
}

12
▪ OUTPUT

13
▪ Advantages of Linear Search

1. Linear search can be used irrespective of whether the array is sorted or not. It can be used
on arrays of any data type.
2. Does not require any additional memory.
3. It is a well-suited algorithm for small datasets.

▪ Drawbacks of Linear Search

1. Linear search has a time complexity of O(N), which in turn makes it slow for large
datasets.
2. Not suitable for large arrays.

▪ When to use Linear Search

1. When we are dealing with a small dataset.


2. When you are searching for a dataset stored in contiguous memory.

14
15
▪ Binary search/interval search: -

This algorithm locates specific items by comparing the middlemost items in the data
collection. When a match is found, it returns the index of the item. When the middle item is
greater than the search item, it looks for a central item of the left sub-array. If, on the other
hand, the middle item is smaller than the search item, it explores for the middle item in the
right sub-array. It keeps looking for an item until it finds it or the size of the sub-arrays
reaches zero.

Binary search needs sorted order of items of the array. It works faster than a linear search
algorithm. The binary search uses the divide and conquers principle.

▪ Working of Binary search

To understand the working of binary search, consider the following illustration:

Consider an array arr[ ] = {2, 5, 8, 12, 16, 23, 38, 56, 72, 91}, and the target = 23.

First Step:
Calculate the mid and compare the mid element with the key. If the key is less than mid
element, move to left and if it is greater than the mid then move search space to the right.

Key (i.e., 23) is greater than current mid element (i.e., 16). The search space moves to the
right.

16
Key is less than the current mid 56. The search space moves to the left.

Second Step:

If the key matches the value of the mid element, the element is found and stop search.

Key element found at index i=5

Complexities in Binary search are: -


Space Complexity
The space complexity of binary search is O(1).

Time ComplexityThe worst-case complexity in binary search is O(n log n).

● The average case complexity in binary search is O(n log n)

● Best case complexity = O (1)

17
▪ Algorithm of Binary search/Interval search

Step 1: set beg = lower_bound, end = upper_bound, pos = - 1


Step 2: repeat steps 3 and 4 while beg <=end
Step 3: set mid = (beg + end)/2
Step 4: if a[mid] = val
set pos = mid
print pos
go to step 6
else if a[mid] > val
set end = mid - 1
else
set beg = mid + 1
[end of if]
[end of loop]
Step 5: if pos = -1
print "value is not present in the array"
[end of if]
Step 6: Stop

18
▪ Flowchart of Binary search/Interval search

19
▪ C program for binary search: -

#include <stdio.h>
int main()
{
int i, low, high, mid, n, key, array[100];
printf("Enter number of elementsn");
scanf("%d",&n);
printf("Enter %d integersn", n);
for(i = 0; i < n; i++)
scanf("%d",&array[i]);
printf("Enter value to findn");
scanf("%d", &key);
low = 0;
high = n - 1;
mid = (low+high)/2;
while (low <= high) {
if(array[mid] < key)
low = mid + 1;
else if (array[mid] == key) {
printf("%d found at location %d.n", key, mid+1);
break;
}
else
high = mid - 1;
mid = (low + high)/2;
}
if(low > high)
printf("Not found! %d isn't present in the list.n", key);
return 0;
}

20
▪ Output: -

21
▪ Advantages of Binary Search

1. Binary search is faster than linear search, especially for large arrays.
2. More efficient than other searching algorithms with a similar time complexity, such as
interpolation search or exponential search.
3. Binary search is well-suited for searching large datasets that are stored in external memory,
such as on a hard drive or in the cloud

▪ Drawbacks of Binary Search

1. The array should be sorted.


2. Binary search requires that the data structure being searched be stored in contiguous memory
locations.
3. Binary search requires that the elements of the array be comparable, meaning that they must
be able to be ordered.

▪ Applications of Binary Search

1. Binary search can be used as a building block for more complex algorithms used in machine
learning, such as algorithms for training neural networks or finding the optimal hyper
parameters for a model.
2. It can be used for searching in computer graphics such as algorithms for ray tracing or texture
mapping.
3. It can be used for searching a database

22
JSPM’s
JAYAWANTRAO SAWANT POLYTECHNIC,
Handewadi Road, Hadapsar, Pune-28
Department of Computer Engineering
Academic Year 2023-24

Title of Micro project: Searching Methods

3.0 Brief Introduction:


We wrote codes/programs for searching

4.0 Aim of Micro Project:


We wrote codes/programs for searching
3.0 Course Outcome Integrated
We wrote codes/programs searching
4.0 Actual Procedure Followed.
1. Wrote codes for searching
2. Pasted outputs of it in MS Word
5.0 Actual Resources Used (mention the actual resources used.)

Sr. No. Name of resource Specification Quantity Remarks

1 Laptop/Computer Windows 11 1
Processor 8GB RAM

2 Software Google Chrome, 1


Microsoft Edge,
MS Word, Turbo C

3 Other - -

6.0 Outputs of the Micro Projects


We wrote codes/programs for searching

7.0 Skill Developed/ Learning out of this Micro project


We wrote codes/programs for searching

23
Teacher Evaluation Sheet

Name of students: Akhilesh Gawade, Aryan Panchal, Abhijeet Pawar, Anisha Mane
Enrollment No: 2207110609, 2207110610, 2207110611, 2207110612
Name of program: Computer Engineering
Semester: 3rd
Course Title: DSU
Code: 22317
Title of Micro Project: Searching Methods.
Course Outcomes Achieved:

● We learnt to make programs using C language

Evaluation as per suggested Rubric for Assessment of Micro Project

Sr. Characteristic to be assessed Poor Average Good Excellent


No (Marks1- (Marks 4 - (Marks 6 (Marks 9 -
3) 5) -8) 10)

1 Relevance to the course

2 Literature Survey / Information


collection

3 Project Proposal

4 Completion of the Target as per


Project Proposal

5 Analysis of data and


representation

6 Quality of Prototype/ Model

7 Report preparation

8 Presentation

9 Defense

24
Micro Project Evaluation Sheet

Process Assessment Product Assessment

Part A - Project Par B - Project Individual Total

Project Methodology Report/ working Presentation/ Viva Marks

Proposal Model 10
(2 Marks) (4 Marks)
(2 Marks) (2 Marks)

Note: Every course teacher is expected to assign marks for group evaluation in first 3
columns and individual evaluation 4th column

Comment/ suggestion about team work/leadership/ interpersonal communication (If


any)

…………………………………………………………………………………………………
…………………………………………………………………………………………………
…………………………………………………………………………………………………
…………………………………………………………………………………………………
……………………………………………………………

Any other comment:

…………………………………………………………………………………………………
…………………………………………………………………………………………………
…………………………………………………………………………………………………
…………………………………………………………………………………………………
……………………………………………………………

Name and Designation of the Faculty Member: Mr. S.S.Wable.

Signature: ………………………….

25

You might also like