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

Notes On Searching and Sorting

Sequential and binary searching are two techniques for finding a value within a list. Sequential searching, also called linear searching, checks every element in order until the desired value is found or all elements are examined. It is applied to unsorted lists. Binary searching works by comparing the middle element of a sorted list, dividing the search area in half and repeating until the value is found or determined absent. While sequential searching has linear time complexity, binary searching has logarithmic time complexity, making it faster for large sorted lists.

Uploaded by

boggus acc
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)
44 views2 pages

Notes On Searching and Sorting

Sequential and binary searching are two techniques for finding a value within a list. Sequential searching, also called linear searching, checks every element in order until the desired value is found or all elements are examined. It is applied to unsorted lists. Binary searching works by comparing the middle element of a sorted list, dividing the search area in half and repeating until the value is found or determined absent. While sequential searching has linear time complexity, binary searching has logarithmic time complexity, making it faster for large sorted lists.

Uploaded by

boggus acc
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/ 2

Sorting and Searching: Definition and concept.

Searching techniques: Sequential


and binary searching.
_____________________________________________________________________

 Searching:
Searching is the process of finding a given value position in a list of values. It decides
whether an element is present in the list or not. It is the algorithmic process of finding
a particular item in a collection of items. It can be done on internal data structure or on
external data structure.
Two types of searching methods are available such as-
1. Sequential Search
2. Binary Search
1. Sequential Search:
Sequential search is also called as Linear Search. Sequential search starts at the
beginning of the list and checks every element of the list. It is a basic and simple
search algorithm. Sequential search compares the element with all the other elements
given in the list. If the element is matched, it returns the address of that value,
otherwise it returns -1.
The following figure shows how sequential search works.

It searches an element or value from an array till the desired element or value is not
found. If we search the element 25, it will go step by step in a sequence order. It
searches in a sequence order. Sequential search is applied on the unsorted or
unordered list when there are fewer elements in a list.

2. Binary Search:
Binary Search is used for searching an element in a sorted array. It is a fast search
algorithm with run-time complexity of O(log n). Binary search works on the principle
of divide and conquer.
This searching technique looks for a particular element by comparing the middle most
element of the collection. It is useful when there are large number of elements in an
array.
The above array is sorted in ascending order. Binary search is applied on sorted lists
only for fast searching.
For example, if searching an element 25 in the 7-element array, following figure
shows how binary search works:

Binary searching starts with middle element. If the element is equal to the element that
we are searching then return true. If the element is less than given element, then move
to the right of the list or if the element is greater than given element, then move to the
left of the list. Repeat this, till you find an element.

You might also like