尊敬的 微信汇率:1円 ≈ 0.046166 元 支付宝汇率:1円 ≈ 0.046257元 [退出登录]
SlideShare a Scribd company logo
Sequential Search
&
Binary Search
By:
Solanki Gaurav P. 15COD05
Nikam Rohit P.15COD08
Patel Hemanshu B.15COD14
Jena Akshay.15COD19
What is searching?
• In computer science, searching is the process of finding an item with
specified properties from a collection of items.The items may be stored as
records in a database, simple data elements in arrays, text in files, nodes in
trees, vertices and edges in graphs, or maybe be elements in other search
place.
Why do we need searching?
• Searching is one of the core computer science algorithms. We know that
today’s computers store a lot of information.To retrieve this information
proficiently we need very efficient searching algorithms.
Types of searching
• Unordered linear/ sequential search
• Sorted/ Ordered linear/ sequential search
• Binary search
• Symbol tables and Hashing
• String searching algorithms
Unordered linear/ Sequential search
• Let us assume that given an array whose elements order is not known.That
means that the element of array are not sorted. In this case, to search for an
element we have to scan the complete array and see if the element is there
in given list or not.
Unordered linear/ Sequential search
int unorderedlinearsearch (int A[], int n, int data)
{
for (int i=0; i<n; i++)
{
if(A[i] == data)
return i;
}
return -1;
}
Search No. 405 from the given array
15 75 65405 551 1535 77 80
First of all compare the element to be searched with the index
element of array.
51 !=405 So move to next element.
15 !=405 Move to next element.
75 != 405 Move to next element.
35 !=405 move to next element.
405 ==405 SEARCH COMPLETE.
Binary Search
• Let us consider a problem of searching a word in a dictionary.Typically, we
directly go to some approximate page[say, middle page] start searching
from that point. If the name that we are searching is same then the search is
complete. If the page is before the selected pages then apply the process for
the first half otherwise apply the same process for the second half. Binary
search also works in the same way.The algorithm applying such strategy is
referred as binary search algorithm.
Search Number 75 from Array using binary
search
15 25 65
75 > 45
45 555 9535 75 85
According to
algorithm, first find
middle element of
your array.
MID= LOW+HIGH/2
Check if search
element and middle
element are same?
If yes your search is
over.
75 ≠ 45
If not equal then
Check if search
element is greater or
smaller than middle
value.
75 == 75
If search element is
greater than mid
element then make
mid + 1 low value and
find middle value
Search Complete
LOW MID HIGHMIDLOW

More Related Content

What's hot

Analysis of Algorithm - Binary Search.pptx
Analysis of Algorithm - Binary Search.pptxAnalysis of Algorithm - Binary Search.pptx
Analysis of Algorithm - Binary Search.pptx
Maulana Abul Kalam Azad University of Technology
 
Binary Search
Binary SearchBinary Search
Binary Search
kunj desai
 
Searching algorithm
Searching algorithmSearching algorithm
Searching algorithm
MG Thushara Pradeesh
 
Searching Techniques and Analysis
Searching Techniques and AnalysisSearching Techniques and Analysis
Searching Techniques and Analysis
AkashBorse2
 
Searching linear &amp; binary search
Searching linear &amp; binary searchSearching linear &amp; binary search
Searching linear &amp; binary search
nikunjandy
 
Linear Search
Linear SearchLinear Search
Linear Search
SWATHIR72
 
Algorithms Lecture 6: Searching Algorithms
Algorithms Lecture 6: Searching AlgorithmsAlgorithms Lecture 6: Searching Algorithms
Algorithms Lecture 6: Searching Algorithms
Mohamed Loey
 
Linear Search Data Structure
Linear Search Data StructureLinear Search Data Structure
Linear Search Data Structure
Talha Shaikh
 
Binary Search - Design & Analysis of Algorithms
Binary Search - Design & Analysis of AlgorithmsBinary Search - Design & Analysis of Algorithms
Binary Search - Design & Analysis of Algorithms
Drishti Bhalla
 
Algorithms Lecture 5: Sorting Algorithms II
Algorithms Lecture 5: Sorting Algorithms IIAlgorithms Lecture 5: Sorting Algorithms II
Algorithms Lecture 5: Sorting Algorithms II
Mohamed Loey
 
Queue in Data Structure
Queue in Data Structure Queue in Data Structure
Queue in Data Structure
Janki Shah
 
Queue
QueueQueue
PPT On Sorting And Searching Concepts In Data Structure | In Programming Lang...
PPT On Sorting And Searching Concepts In Data Structure | In Programming Lang...PPT On Sorting And Searching Concepts In Data Structure | In Programming Lang...
PPT On Sorting And Searching Concepts In Data Structure | In Programming Lang...
Umesh Kumar
 
Selection sort 1
Selection sort 1Selection sort 1
Selection sort 1
asmhemu
 
Sorting in python
Sorting in python Sorting in python
Sorting in python
Simplilearn
 
Binary search tree(bst)
Binary search tree(bst)Binary search tree(bst)
Binary search tree(bst)
Hossain Md Shakhawat
 
Searching techniques in Data Structure And Algorithm
Searching techniques in Data Structure And AlgorithmSearching techniques in Data Structure And Algorithm
Searching techniques in Data Structure And Algorithm
03446940736
 
Sorting
SortingSorting
Binary Search Tree in Data Structure
Binary Search Tree in Data StructureBinary Search Tree in Data Structure
Binary Search Tree in Data Structure
Dharita Chokshi
 
Searching and Sorting Techniques in Data Structure
Searching and Sorting Techniques in Data StructureSearching and Sorting Techniques in Data Structure
Searching and Sorting Techniques in Data Structure
Balwant Gorad
 

What's hot (20)

Analysis of Algorithm - Binary Search.pptx
Analysis of Algorithm - Binary Search.pptxAnalysis of Algorithm - Binary Search.pptx
Analysis of Algorithm - Binary Search.pptx
 
Binary Search
Binary SearchBinary Search
Binary Search
 
Searching algorithm
Searching algorithmSearching algorithm
Searching algorithm
 
Searching Techniques and Analysis
Searching Techniques and AnalysisSearching Techniques and Analysis
Searching Techniques and Analysis
 
Searching linear &amp; binary search
Searching linear &amp; binary searchSearching linear &amp; binary search
Searching linear &amp; binary search
 
Linear Search
Linear SearchLinear Search
Linear Search
 
Algorithms Lecture 6: Searching Algorithms
Algorithms Lecture 6: Searching AlgorithmsAlgorithms Lecture 6: Searching Algorithms
Algorithms Lecture 6: Searching Algorithms
 
Linear Search Data Structure
Linear Search Data StructureLinear Search Data Structure
Linear Search Data Structure
 
Binary Search - Design & Analysis of Algorithms
Binary Search - Design & Analysis of AlgorithmsBinary Search - Design & Analysis of Algorithms
Binary Search - Design & Analysis of Algorithms
 
Algorithms Lecture 5: Sorting Algorithms II
Algorithms Lecture 5: Sorting Algorithms IIAlgorithms Lecture 5: Sorting Algorithms II
Algorithms Lecture 5: Sorting Algorithms II
 
Queue in Data Structure
Queue in Data Structure Queue in Data Structure
Queue in Data Structure
 
Queue
QueueQueue
Queue
 
PPT On Sorting And Searching Concepts In Data Structure | In Programming Lang...
PPT On Sorting And Searching Concepts In Data Structure | In Programming Lang...PPT On Sorting And Searching Concepts In Data Structure | In Programming Lang...
PPT On Sorting And Searching Concepts In Data Structure | In Programming Lang...
 
Selection sort 1
Selection sort 1Selection sort 1
Selection sort 1
 
Sorting in python
Sorting in python Sorting in python
Sorting in python
 
Binary search tree(bst)
Binary search tree(bst)Binary search tree(bst)
Binary search tree(bst)
 
Searching techniques in Data Structure And Algorithm
Searching techniques in Data Structure And AlgorithmSearching techniques in Data Structure And Algorithm
Searching techniques in Data Structure And Algorithm
 
Sorting
SortingSorting
Sorting
 
Binary Search Tree in Data Structure
Binary Search Tree in Data StructureBinary Search Tree in Data Structure
Binary Search Tree in Data Structure
 
Searching and Sorting Techniques in Data Structure
Searching and Sorting Techniques in Data StructureSearching and Sorting Techniques in Data Structure
Searching and Sorting Techniques in Data Structure
 

Similar to Binary search

Linear Search for design and analysis of algorithm
Linear Search for design and analysis of algorithmLinear Search for design and analysis of algorithm
Linear Search for design and analysis of algorithm
JavedKhan524377
 
Linear Search Presentation
Linear Search PresentationLinear Search Presentation
Linear Search Presentation
Markajul Hasnain Alif
 
Linear Search in Oops.pptx
Linear Search in Oops.pptxLinear Search in Oops.pptx
Linear Search in Oops.pptx
Ashish Sadavarti
 
Data Structure & Algorithms - Operations
Data Structure & Algorithms - OperationsData Structure & Algorithms - Operations
Data Structure & Algorithms - Operations
babuk110
 
programming in C
programming in Cprogramming in C
programming in C
ADITHYAM19
 
BCA DATA STRUCTURES SEARCHING AND SORTING MRS.SOWMYA JYOTHI
BCA DATA STRUCTURES SEARCHING AND SORTING MRS.SOWMYA JYOTHIBCA DATA STRUCTURES SEARCHING AND SORTING MRS.SOWMYA JYOTHI
BCA DATA STRUCTURES SEARCHING AND SORTING MRS.SOWMYA JYOTHI
Sowmya Jyothi
 
4.1 sequentioal search
4.1 sequentioal search4.1 sequentioal search
4.1 sequentioal search
Krish_ver2
 
Searching Algorithm, Linear search algorithm and their time complexity
Searching Algorithm, Linear search algorithm and their time complexitySearching Algorithm, Linear search algorithm and their time complexity
Searching Algorithm, Linear search algorithm and their time complexity
hamzamunawarkhan
 
arrays in c
arrays in carrays in c
arrays in c
vidhi mehta
 
Data Structures 8
Data Structures 8Data Structures 8
Data Structures 8
Dr.Umadevi V
 
Searching, Sorting and Hashing Techniques
Searching, Sorting and Hashing TechniquesSearching, Sorting and Hashing Techniques
Searching, Sorting and Hashing Techniques
Selvaraj Seerangan
 
Rahat &amp; juhith
Rahat &amp; juhithRahat &amp; juhith
Rahat &amp; juhith
Rj Juhith
 
unit II_2_i.pptx
unit II_2_i.pptxunit II_2_i.pptx
unit II_2_i.pptx
HODElex
 
Searching and sorting
Searching  and sortingSearching  and sorting
Searching and sorting
PoojithaBollikonda
 
Searching in c language
Searching in c languageSearching in c language
Searching in c language
CHANDAN KUMAR
 
seaching internal 2 ppt
seaching internal 2 pptseaching internal 2 ppt
seaching internal 2 ppt
SubhrasisBiswal1
 
Data structure and algorithms
Data structure and algorithmsData structure and algorithms
Data structure and algorithms
technologygyan
 
Sequential & binary, linear search
Sequential & binary, linear searchSequential & binary, linear search
Sequential & binary, linear search
montazur420
 
searching
searchingsearching
searching
A. S. M. Shafi
 
Binary search
Binary search Binary search
Binary search
Ramkrishna bhagat
 

Similar to Binary search (20)

Linear Search for design and analysis of algorithm
Linear Search for design and analysis of algorithmLinear Search for design and analysis of algorithm
Linear Search for design and analysis of algorithm
 
Linear Search Presentation
Linear Search PresentationLinear Search Presentation
Linear Search Presentation
 
Linear Search in Oops.pptx
Linear Search in Oops.pptxLinear Search in Oops.pptx
Linear Search in Oops.pptx
 
Data Structure & Algorithms - Operations
Data Structure & Algorithms - OperationsData Structure & Algorithms - Operations
Data Structure & Algorithms - Operations
 
programming in C
programming in Cprogramming in C
programming in C
 
BCA DATA STRUCTURES SEARCHING AND SORTING MRS.SOWMYA JYOTHI
BCA DATA STRUCTURES SEARCHING AND SORTING MRS.SOWMYA JYOTHIBCA DATA STRUCTURES SEARCHING AND SORTING MRS.SOWMYA JYOTHI
BCA DATA STRUCTURES SEARCHING AND SORTING MRS.SOWMYA JYOTHI
 
4.1 sequentioal search
4.1 sequentioal search4.1 sequentioal search
4.1 sequentioal search
 
Searching Algorithm, Linear search algorithm and their time complexity
Searching Algorithm, Linear search algorithm and their time complexitySearching Algorithm, Linear search algorithm and their time complexity
Searching Algorithm, Linear search algorithm and their time complexity
 
arrays in c
arrays in carrays in c
arrays in c
 
Data Structures 8
Data Structures 8Data Structures 8
Data Structures 8
 
Searching, Sorting and Hashing Techniques
Searching, Sorting and Hashing TechniquesSearching, Sorting and Hashing Techniques
Searching, Sorting and Hashing Techniques
 
Rahat &amp; juhith
Rahat &amp; juhithRahat &amp; juhith
Rahat &amp; juhith
 
unit II_2_i.pptx
unit II_2_i.pptxunit II_2_i.pptx
unit II_2_i.pptx
 
Searching and sorting
Searching  and sortingSearching  and sorting
Searching and sorting
 
Searching in c language
Searching in c languageSearching in c language
Searching in c language
 
seaching internal 2 ppt
seaching internal 2 pptseaching internal 2 ppt
seaching internal 2 ppt
 
Data structure and algorithms
Data structure and algorithmsData structure and algorithms
Data structure and algorithms
 
Sequential & binary, linear search
Sequential & binary, linear searchSequential & binary, linear search
Sequential & binary, linear search
 
searching
searchingsearching
searching
 
Binary search
Binary search Binary search
Binary search
 

Recently uploaded

ESCORT SERVICE FULL ENJOY - @9711199012, Mayur Vihar CALL GIRLS SERVICE Delhi
ESCORT SERVICE FULL ENJOY - @9711199012, Mayur Vihar CALL GIRLS SERVICE DelhiESCORT SERVICE FULL ENJOY - @9711199012, Mayur Vihar CALL GIRLS SERVICE Delhi
ESCORT SERVICE FULL ENJOY - @9711199012, Mayur Vihar CALL GIRLS SERVICE Delhi
AK47
 
🔥Independent Call Girls In Pune 💯Call Us 🔝 7014168258 🔝💃Independent Pune Esco...
🔥Independent Call Girls In Pune 💯Call Us 🔝 7014168258 🔝💃Independent Pune Esco...🔥Independent Call Girls In Pune 💯Call Us 🔝 7014168258 🔝💃Independent Pune Esco...
🔥Independent Call Girls In Pune 💯Call Us 🔝 7014168258 🔝💃Independent Pune Esco...
AK47
 
🔥Photo Call Girls Lucknow 💯Call Us 🔝 6350257716 🔝💃Independent Lucknow Escorts...
🔥Photo Call Girls Lucknow 💯Call Us 🔝 6350257716 🔝💃Independent Lucknow Escorts...🔥Photo Call Girls Lucknow 💯Call Us 🔝 6350257716 🔝💃Independent Lucknow Escorts...
🔥Photo Call Girls Lucknow 💯Call Us 🔝 6350257716 🔝💃Independent Lucknow Escorts...
AK47
 
❣Independent Call Girls Chennai 💯Call Us 🔝 7737669865 🔝💃Independent Chennai E...
❣Independent Call Girls Chennai 💯Call Us 🔝 7737669865 🔝💃Independent Chennai E...❣Independent Call Girls Chennai 💯Call Us 🔝 7737669865 🔝💃Independent Chennai E...
❣Independent Call Girls Chennai 💯Call Us 🔝 7737669865 🔝💃Independent Chennai E...
nainakaoornoida
 
Better Builder Magazine, Issue 49 / Spring 2024
Better Builder Magazine, Issue 49 / Spring 2024Better Builder Magazine, Issue 49 / Spring 2024
Better Builder Magazine, Issue 49 / Spring 2024
Better Builder Magazine
 
Data Communication and Computer Networks Management System Project Report.pdf
Data Communication and Computer Networks Management System Project Report.pdfData Communication and Computer Networks Management System Project Report.pdf
Data Communication and Computer Networks Management System Project Report.pdf
Kamal Acharya
 
Literature review for prompt engineering of ChatGPT.pptx
Literature review for prompt engineering of ChatGPT.pptxLiterature review for prompt engineering of ChatGPT.pptx
Literature review for prompt engineering of ChatGPT.pptx
LokerXu2
 
Call Girls In Rohini (Delhi) Call 9711199012 ∰ Escort Service In Delhi ∰
Call Girls In Rohini (Delhi) Call 9711199012 ∰ Escort Service In Delhi ∰Call Girls In Rohini (Delhi) Call 9711199012 ∰ Escort Service In Delhi ∰
Call Girls In Rohini (Delhi) Call 9711199012 ∰ Escort Service In Delhi ∰
AK47
 
Covid Management System Project Report.pdf
Covid Management System Project Report.pdfCovid Management System Project Report.pdf
Covid Management System Project Report.pdf
Kamal Acharya
 
Sri Guru Hargobind Ji - Bandi Chor Guru.pdf
Sri Guru Hargobind Ji - Bandi Chor Guru.pdfSri Guru Hargobind Ji - Bandi Chor Guru.pdf
Sri Guru Hargobind Ji - Bandi Chor Guru.pdf
Balvir Singh
 
🔥LiploCk Call Girls Pune 💯Call Us 🔝 7014168258 🔝💃Independent Pune Escorts Ser...
🔥LiploCk Call Girls Pune 💯Call Us 🔝 7014168258 🔝💃Independent Pune Escorts Ser...🔥LiploCk Call Girls Pune 💯Call Us 🔝 7014168258 🔝💃Independent Pune Escorts Ser...
🔥LiploCk Call Girls Pune 💯Call Us 🔝 7014168258 🔝💃Independent Pune Escorts Ser...
adhaniomprakash
 
College Call Girls Kolkata 🔥 7014168258 🔥 Real Fun With Sexual Girl Available...
College Call Girls Kolkata 🔥 7014168258 🔥 Real Fun With Sexual Girl Available...College Call Girls Kolkata 🔥 7014168258 🔥 Real Fun With Sexual Girl Available...
College Call Girls Kolkata 🔥 7014168258 🔥 Real Fun With Sexual Girl Available...
Ak47
 
AN INTRODUCTION OF AI & SEARCHING TECHIQUES
AN INTRODUCTION OF AI & SEARCHING TECHIQUESAN INTRODUCTION OF AI & SEARCHING TECHIQUES
AN INTRODUCTION OF AI & SEARCHING TECHIQUES
drshikhapandey2022
 
Call Girls Chennai +91-8824825030 Vip Call Girls Chennai
Call Girls Chennai +91-8824825030 Vip Call Girls ChennaiCall Girls Chennai +91-8824825030 Vip Call Girls Chennai
Call Girls Chennai +91-8824825030 Vip Call Girls Chennai
paraasingh12 #V08
 
Online train ticket booking system project.pdf
Online train ticket booking system project.pdfOnline train ticket booking system project.pdf
Online train ticket booking system project.pdf
Kamal Acharya
 
Intuit CRAFT demonstration presentation for sde
Intuit CRAFT demonstration presentation for sdeIntuit CRAFT demonstration presentation for sde
Intuit CRAFT demonstration presentation for sde
ShivangMishra54
 
Call Girls Chandigarh 🔥 7014168258 🔥 Real Fun With Sexual Girl Available 24/7...
Call Girls Chandigarh 🔥 7014168258 🔥 Real Fun With Sexual Girl Available 24/7...Call Girls Chandigarh 🔥 7014168258 🔥 Real Fun With Sexual Girl Available 24/7...
Call Girls Chandigarh 🔥 7014168258 🔥 Real Fun With Sexual Girl Available 24/7...
shourabjaat424
 
Call Girls In Tiruppur 👯‍♀️ 7339748667 🔥 Free Home Delivery Within 30 Minutes
Call Girls In Tiruppur 👯‍♀️ 7339748667 🔥 Free Home Delivery Within 30 MinutesCall Girls In Tiruppur 👯‍♀️ 7339748667 🔥 Free Home Delivery Within 30 Minutes
Call Girls In Tiruppur 👯‍♀️ 7339748667 🔥 Free Home Delivery Within 30 Minutes
kamka4105
 
Mahipalpur Call Girls Delhi 🔥 9711199012 ❄- Pick Your Dream Call Girls with 1...
Mahipalpur Call Girls Delhi 🔥 9711199012 ❄- Pick Your Dream Call Girls with 1...Mahipalpur Call Girls Delhi 🔥 9711199012 ❄- Pick Your Dream Call Girls with 1...
Mahipalpur Call Girls Delhi 🔥 9711199012 ❄- Pick Your Dream Call Girls with 1...
simrangupta87541
 
Sachpazis_Consolidation Settlement Calculation Program-The Python Code and th...
Sachpazis_Consolidation Settlement Calculation Program-The Python Code and th...Sachpazis_Consolidation Settlement Calculation Program-The Python Code and th...
Sachpazis_Consolidation Settlement Calculation Program-The Python Code and th...
Dr.Costas Sachpazis
 

Recently uploaded (20)

ESCORT SERVICE FULL ENJOY - @9711199012, Mayur Vihar CALL GIRLS SERVICE Delhi
ESCORT SERVICE FULL ENJOY - @9711199012, Mayur Vihar CALL GIRLS SERVICE DelhiESCORT SERVICE FULL ENJOY - @9711199012, Mayur Vihar CALL GIRLS SERVICE Delhi
ESCORT SERVICE FULL ENJOY - @9711199012, Mayur Vihar CALL GIRLS SERVICE Delhi
 
🔥Independent Call Girls In Pune 💯Call Us 🔝 7014168258 🔝💃Independent Pune Esco...
🔥Independent Call Girls In Pune 💯Call Us 🔝 7014168258 🔝💃Independent Pune Esco...🔥Independent Call Girls In Pune 💯Call Us 🔝 7014168258 🔝💃Independent Pune Esco...
🔥Independent Call Girls In Pune 💯Call Us 🔝 7014168258 🔝💃Independent Pune Esco...
 
🔥Photo Call Girls Lucknow 💯Call Us 🔝 6350257716 🔝💃Independent Lucknow Escorts...
🔥Photo Call Girls Lucknow 💯Call Us 🔝 6350257716 🔝💃Independent Lucknow Escorts...🔥Photo Call Girls Lucknow 💯Call Us 🔝 6350257716 🔝💃Independent Lucknow Escorts...
🔥Photo Call Girls Lucknow 💯Call Us 🔝 6350257716 🔝💃Independent Lucknow Escorts...
 
❣Independent Call Girls Chennai 💯Call Us 🔝 7737669865 🔝💃Independent Chennai E...
❣Independent Call Girls Chennai 💯Call Us 🔝 7737669865 🔝💃Independent Chennai E...❣Independent Call Girls Chennai 💯Call Us 🔝 7737669865 🔝💃Independent Chennai E...
❣Independent Call Girls Chennai 💯Call Us 🔝 7737669865 🔝💃Independent Chennai E...
 
Better Builder Magazine, Issue 49 / Spring 2024
Better Builder Magazine, Issue 49 / Spring 2024Better Builder Magazine, Issue 49 / Spring 2024
Better Builder Magazine, Issue 49 / Spring 2024
 
Data Communication and Computer Networks Management System Project Report.pdf
Data Communication and Computer Networks Management System Project Report.pdfData Communication and Computer Networks Management System Project Report.pdf
Data Communication and Computer Networks Management System Project Report.pdf
 
Literature review for prompt engineering of ChatGPT.pptx
Literature review for prompt engineering of ChatGPT.pptxLiterature review for prompt engineering of ChatGPT.pptx
Literature review for prompt engineering of ChatGPT.pptx
 
Call Girls In Rohini (Delhi) Call 9711199012 ∰ Escort Service In Delhi ∰
Call Girls In Rohini (Delhi) Call 9711199012 ∰ Escort Service In Delhi ∰Call Girls In Rohini (Delhi) Call 9711199012 ∰ Escort Service In Delhi ∰
Call Girls In Rohini (Delhi) Call 9711199012 ∰ Escort Service In Delhi ∰
 
Covid Management System Project Report.pdf
Covid Management System Project Report.pdfCovid Management System Project Report.pdf
Covid Management System Project Report.pdf
 
Sri Guru Hargobind Ji - Bandi Chor Guru.pdf
Sri Guru Hargobind Ji - Bandi Chor Guru.pdfSri Guru Hargobind Ji - Bandi Chor Guru.pdf
Sri Guru Hargobind Ji - Bandi Chor Guru.pdf
 
🔥LiploCk Call Girls Pune 💯Call Us 🔝 7014168258 🔝💃Independent Pune Escorts Ser...
🔥LiploCk Call Girls Pune 💯Call Us 🔝 7014168258 🔝💃Independent Pune Escorts Ser...🔥LiploCk Call Girls Pune 💯Call Us 🔝 7014168258 🔝💃Independent Pune Escorts Ser...
🔥LiploCk Call Girls Pune 💯Call Us 🔝 7014168258 🔝💃Independent Pune Escorts Ser...
 
College Call Girls Kolkata 🔥 7014168258 🔥 Real Fun With Sexual Girl Available...
College Call Girls Kolkata 🔥 7014168258 🔥 Real Fun With Sexual Girl Available...College Call Girls Kolkata 🔥 7014168258 🔥 Real Fun With Sexual Girl Available...
College Call Girls Kolkata 🔥 7014168258 🔥 Real Fun With Sexual Girl Available...
 
AN INTRODUCTION OF AI & SEARCHING TECHIQUES
AN INTRODUCTION OF AI & SEARCHING TECHIQUESAN INTRODUCTION OF AI & SEARCHING TECHIQUES
AN INTRODUCTION OF AI & SEARCHING TECHIQUES
 
Call Girls Chennai +91-8824825030 Vip Call Girls Chennai
Call Girls Chennai +91-8824825030 Vip Call Girls ChennaiCall Girls Chennai +91-8824825030 Vip Call Girls Chennai
Call Girls Chennai +91-8824825030 Vip Call Girls Chennai
 
Online train ticket booking system project.pdf
Online train ticket booking system project.pdfOnline train ticket booking system project.pdf
Online train ticket booking system project.pdf
 
Intuit CRAFT demonstration presentation for sde
Intuit CRAFT demonstration presentation for sdeIntuit CRAFT demonstration presentation for sde
Intuit CRAFT demonstration presentation for sde
 
Call Girls Chandigarh 🔥 7014168258 🔥 Real Fun With Sexual Girl Available 24/7...
Call Girls Chandigarh 🔥 7014168258 🔥 Real Fun With Sexual Girl Available 24/7...Call Girls Chandigarh 🔥 7014168258 🔥 Real Fun With Sexual Girl Available 24/7...
Call Girls Chandigarh 🔥 7014168258 🔥 Real Fun With Sexual Girl Available 24/7...
 
Call Girls In Tiruppur 👯‍♀️ 7339748667 🔥 Free Home Delivery Within 30 Minutes
Call Girls In Tiruppur 👯‍♀️ 7339748667 🔥 Free Home Delivery Within 30 MinutesCall Girls In Tiruppur 👯‍♀️ 7339748667 🔥 Free Home Delivery Within 30 Minutes
Call Girls In Tiruppur 👯‍♀️ 7339748667 🔥 Free Home Delivery Within 30 Minutes
 
Mahipalpur Call Girls Delhi 🔥 9711199012 ❄- Pick Your Dream Call Girls with 1...
Mahipalpur Call Girls Delhi 🔥 9711199012 ❄- Pick Your Dream Call Girls with 1...Mahipalpur Call Girls Delhi 🔥 9711199012 ❄- Pick Your Dream Call Girls with 1...
Mahipalpur Call Girls Delhi 🔥 9711199012 ❄- Pick Your Dream Call Girls with 1...
 
Sachpazis_Consolidation Settlement Calculation Program-The Python Code and th...
Sachpazis_Consolidation Settlement Calculation Program-The Python Code and th...Sachpazis_Consolidation Settlement Calculation Program-The Python Code and th...
Sachpazis_Consolidation Settlement Calculation Program-The Python Code and th...
 

Binary search

  • 1.
  • 2. Sequential Search & Binary Search By: Solanki Gaurav P. 15COD05 Nikam Rohit P.15COD08 Patel Hemanshu B.15COD14 Jena Akshay.15COD19
  • 3. What is searching? • In computer science, searching is the process of finding an item with specified properties from a collection of items.The items may be stored as records in a database, simple data elements in arrays, text in files, nodes in trees, vertices and edges in graphs, or maybe be elements in other search place.
  • 4. Why do we need searching? • Searching is one of the core computer science algorithms. We know that today’s computers store a lot of information.To retrieve this information proficiently we need very efficient searching algorithms.
  • 5. Types of searching • Unordered linear/ sequential search • Sorted/ Ordered linear/ sequential search • Binary search • Symbol tables and Hashing • String searching algorithms
  • 6. Unordered linear/ Sequential search • Let us assume that given an array whose elements order is not known.That means that the element of array are not sorted. In this case, to search for an element we have to scan the complete array and see if the element is there in given list or not.
  • 7. Unordered linear/ Sequential search int unorderedlinearsearch (int A[], int n, int data) { for (int i=0; i<n; i++) { if(A[i] == data) return i; } return -1; }
  • 8. Search No. 405 from the given array 15 75 65405 551 1535 77 80 First of all compare the element to be searched with the index element of array. 51 !=405 So move to next element. 15 !=405 Move to next element. 75 != 405 Move to next element. 35 !=405 move to next element. 405 ==405 SEARCH COMPLETE.
  • 9. Binary Search • Let us consider a problem of searching a word in a dictionary.Typically, we directly go to some approximate page[say, middle page] start searching from that point. If the name that we are searching is same then the search is complete. If the page is before the selected pages then apply the process for the first half otherwise apply the same process for the second half. Binary search also works in the same way.The algorithm applying such strategy is referred as binary search algorithm.
  • 10. Search Number 75 from Array using binary search 15 25 65 75 > 45 45 555 9535 75 85 According to algorithm, first find middle element of your array. MID= LOW+HIGH/2 Check if search element and middle element are same? If yes your search is over. 75 ≠ 45 If not equal then Check if search element is greater or smaller than middle value. 75 == 75 If search element is greater than mid element then make mid + 1 low value and find middle value Search Complete LOW MID HIGHMIDLOW
  翻译: