DSU Micro Project
DSU Micro Project
A STUDY ON
Page | 1
Trimurti Institute of Polytechnic, Paldhi
Certificate
This is to certify that Mr./Mts. 1) Jayesh Patil (Roll NO: 2107)
2) Vedant Bachhav (Roll NO: 2125)
3) Harshal Patil (Roll NO: 2158)
4) Rutvik Patil (Roll NO: 2121)
Roll No: ……. Of Third Semester of Computer Engineering Diploma in Engineering &
Technology at 1432 GOVERNMENT POLYTECHNIC, NANDURBAR, has completed the
Micro Project satisfactorily in Subject DSU in the academic year 2021-2022 as per the
MSBTE prescribed curriculum of I Scheme.
Date :
Page | 2
Trimurti Institute of Polytechnic, Paldhi
INDEX
9
8 Annexure
Page | 3
Trimurti Institute of Polytechnic, Paldhi
Abstract
Binary search is a more specialized algorithm than sequential search as it takes advantage of data that
has been sorted. The underlying idea of binary search is to divide the sorted data into two halves and
to examine the data at the point of the split. Since the data is sorted, we can easily ignore one half or
the other depending on where the data we're looking for lies in comparison to the data at the split.
This makes for a much more efficient search than linear search.
Binary search is used on sorted arrays, but we see it more often when used with binary search trees
(see the trees SparkNote for more information). Whereas linear search allows us to look for data
in O(n) time, where n is the number of elements being searched, binary search allows us to do the
same search in O(logn) time, a dramatic speed enhancement.
Introduction
In this article, we will discuss the Binary Search Algorithm. Searching is the process of finding some
particular element in the list. If the element is present in the list, then the process is called successful,
and the process returns the location of that element. Otherwise, the search is called unsuccessful.
Linear Search and Binary Search are the two popular searching techniques. Here we will discuss the
Binary Search Algorithm.
Binary search is the search technique that works efficiently on sorted lists. Hence, to search an
element into some list using the binary search technique, we must ensure that the list is sorted.
Binary search follows the divide and conquer approach in which the list is divided into two halves, and
the item is compared with the middle element of the list. If the match is found then, the location of
the middle element is returned. Otherwise, we search into either of the halves depending upon the
result produced through the match.
Page | 4
Trimurti Institute of Polytechnic, Paldhi
Binary Search Algorithm is used to find a certain value of x for which a certain defined function f(x) needs to be
maximized or minimized. It is frequently used to search an element in a sorted sequence by repeatedly dividing
the search interval into halves. Begin with an interval covering the whole sequence, if the value of the search
key is less than the item in the middle of the interval, then search in the left half of the interval otherwise search
in the right half. Repeatedly check until the value is found or the interval is empty.
The main condition to perform a Binary Search is that the sequence must be monotonous i.e., it must be either
increasing or decreasing.
Time Complexity
Best Case Complexity - In Binary search, best case occurs when the element to search is found in first
comparison, i.e., when the first middle element itself is the element to be searched. The best-case time
complexity of Binary search is O (1).
Average Case Complexity - The average case time complexity of Binary search is O(logn).
Worst Case Complexity - In Binary search, the worst case occurs, when we have to keep reducing the
search space till it has only one element. The worst-case time complexity of Binary search is O(logn).
Space Complexity
The space complexity of binary search is O (1).
Page | 5
Trimurti Institute of Polytechnic, Paldhi
Now, compare the search value K with the element located at the median of the lower and upper bounds. If the
value K is greater, increase the lower bound, else decrease the upper bound.
Referring to the image above, the lower bound is 0 and the upper bound is 9. The median of the lower and
upper bounds is (lower_bound + upper_bound) / 2 = 4. Here a [4] = 4. The value 4>2, which is the value that you
are searching for. Therefore, we do not need to conduct a search on any element beyond 4 as the elements
beyond it will obviously be greater than 2.
Therefore, we can always drop the upper bound of the array to the position of element 4. Now, we follow the
same procedure on the same array with the following values.
Low: 0
High: 3
Repeat this procedure recursively until Low > High. If at any iteration, we get a[mid]=key, we return value
of mid. This is the position of key in the array. If key is not present in the array, we return −1.
Page | 6
Trimurti Institute of Polytechnic, Paldhi
This algorithm is used to search element in a given sorted array with more efficiency.
It could also be used for few other additional operations like- to find the smallest element in the array
or to find the largest element in the array.
Conclusion: -
Search algorithms are all over in any engineer’s code. From authorization and authentication to a simple filter
on your page it is important to understand what is going on behind any abstractions. Deeper knowledge into
algorithms like binary search will help you write good, clean code and lend its hand in any optimizations that
need to be made.
Reference :-
https://www.geeksforgeeks.org
https://en.wikipedia.org/
https://www.javatpoint.com/
https://www.programiz.com/dsa
Page | 7
Trimurti Institute of Polytechnic, Paldhi
Timing
Week Work or activity Performed Sign of the
No. Date From To Duration Guide
in hours
Discussion and Finalization of the Project
1 16/10/21 2:00 3:00 1 Title
Page | 8
Trimurti Institute of Polytechnic, Paldhi
ANNEXURE – II
Evaluation Sheet for the micro project(Teachers copy)
Academic Year:- 2021-2022 Name of Faculty :- Mr. Sanjay Thakre
Sem :- Third Program Name and Code :- Computer Engineering.
Course :- DSU Course Code :- 22317
1) Jayesh Patil
Name of Students:- 2) Vedant Bachhav
3) Harshal Patil
4) Rutvik Patil
Title of the Project :- Binary Searching Algorithm
( )
Signature With Name and Designation of the Faculty Member
Page | 9