0% found this document useful (0 votes)
9 views2 pages

Searching Note1

Binary search algorithms are faster than linear search for large arrays as binary search time increases logarithmically while linear search increases linearly. Binary search requires a sorted array but is simple to implement. It can be used for machine learning and computer graphics applications. Linear search is simple but slow for large datasets as it has a linear time complexity.

Uploaded by

Niloy Sarkar
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)
9 views2 pages

Searching Note1

Binary search algorithms are faster than linear search for large arrays as binary search time increases logarithmically while linear search increases linearly. Binary search requires a sorted array but is simple to implement. It can be used for machine learning and computer graphics applications. Linear search is simple but slow for large datasets as it has a linear time complexity.

Uploaded by

Niloy Sarkar
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/ 2

BINARY SEARCH ALGORITHMS:

Advantages of Binary Search:


 Binary search is faster than linear search, especially for large arrays. As the size of the array
increases, the time it takes to perform a linear search increases linearly, while the time it
takes to perform a binary search increases logarithmically.

 Binary search is more efficient than other searching algorithms that have a similar time
complexity, such as interpolation search or exponential search.

 Binary search is relatively simple to implement and easy to understand, making it a good
choice for many applications.

 Binary search can be used on both sorted arrays and sorted linked lists, making it a flexible
algorithm.

 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.

 Binary search can be used as a building block for more complex algorithms, such as those
used in computer graphics and machine learning.

Drawbacks of Binary Search:


 We require the array to be sorted. If the array is not sorted, we must first sort it before
performing the search. This adds an additional O(n log n) time complexity for the sorting step,
which can make binary search less efficient for very small arrays.

 Binary search requires that the array being searched be stored in contiguous memory
locations. This can be a problem if the array is too large to fit in memory, or if the array is
stored on external memory such as a hard drive or in the cloud.

 Binary search requires that the elements of the array be comparable, meaning that they must
be able to be ordered. This can be a problem if the elements of the array are not naturally
ordered, or if the ordering is not well-defined.

 Binary search can be less efficient than other algorithms, such as hash tables, for searching
very large datasets that do not fit in memory.

Applications of Binary search:


 Searching in machine learning: 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 hyperparameters for a model.

 Commonly used in Competitive Programming.

 Can be used for searching in computer graphics. Binary search can be used as a building
block for more complex algorithms used in computer graphics, such as algorithms for ray
tracing or texture mapping.

 Can be used for searching a database. Binary search can be used to efficiently search a
database of records, such as a customer database or a product catalog.
LINEAR SEARCH ALGORITHMS:

Advantages of Linear Search:


 Linear search is simple to implement and easy to understand.

 Linear search can be used irrespective of whether the array is sorted or not. It
can be used on arrays of any data type.

 Does not require any additional memory.

 It is a well suited algorithm for small datasets.


Drawbacks of Linear Search:
 Linear search has a time complexity of O(n), which in turn makes it slow for
large datasets.

 Not suitable for large array.

 Linear search can be less efficient than other algorithms, such as hash tables.

Application: Linear search can be applied to both single-dimensional


and multi-dimensional arrays. Linear search is easy to implement and
effective when the array contains only a few elements. Linear Search is
also efficient when the search is performed to fetch a single search in an
unordered-List.

You might also like