SlideShare a Scribd company logo
Mehedi Hassan
161-15-7667
Arafat Rahman
152-15-5983
Nazmul Islam 152-
15-5652
Taijul Islam 152-
15-5613
Name :
Ms. Rifat Ara Shams
Designation :
Senior Lecturer
Department :
Department of
Computer Science and
Engineering
E-mail :
rifat.cse@diu.edu.bd
Cell-Phone :
+880-1723256560
LINEAR BINARY
SEARCH
LINEAR SEARCH
10 46 8 996 2 34 19578
ENTER THE ARRAY ELEMENTS
ENTER THE NUMBER TO BE SEARCHED
2
M[0] M[1] M[2] M[3] M[4] M[5] M[6] M{7] M[8] M[9]
LINEAR SEARCH
10 46 8 996 2 34 19578
2 2 2 2 2 2
THE NUMBER IS FOUND IN THE 6TH
POSITION
#include <stdio.h>
int main()
{
int array[100], search, c, n;
printf("Enter the number of elements in
arrayn");
scanf("%d",&n);
printf("Enter %d integer(s)n", n);
for (c = 0; c < n; c++)
scanf("%d", &array[c]);
CODE
printf("Enter the number to searchn");
scanf("%d", &search);
for (c = 0; c < n; c++)
{
if (array[c] == search) /* if required
element found */
{
printf("%d is present at location
%d.n", search, c+1);
break;
}
}
if (c == n)
printf("%d is not present in array.n",
search);
return 0;
}
BINARY SEARCH
1 5 8 2412 36 48 876754
ENTER THE ARRAY ELEMENTS
ENTER THE NUMBER TO BE SEARCHED
36
M[0] M[1] M[2] M[3] M[4] M[5] M[6] M{7] M[8] M[9]
BINARY SEARCH
1 5 8 2412 36 48 876754
ENTER THE ARRAY ELEMENTS
ENTER THE NUMBER TO BE SEARCHED 36
M[0] M[1] M[2] M[3] M[4] M[5] M[6] M{7] M[8] M[9]
LB UB
P=LB+UB/2
24
STEP 1
FIND THE MIDDLE ELEMENT
P=0+9/2
24 36<
36 48 54 67 87
THE SEARCH ELEMENT LIES IN THE UB
0 1 2 3 4
COMPARING SEARCH WITH MIDDLE ELEMENT
STEP 2
P=LB+UB/2 54
54 > 36
36 48
STEP 3
DIVIDE THE ARRAY FURTHER
COMPARING SEARCH WITH MIDDLE ELEMENT
THE SEARCH ELEMENT LIES IN THE LB
3636
=
NUMBER FOUND
STEP 4
36 48
MIDDLE ELEMENT IS COMPARED WITH THE ELEMENTS IN THE ARRAY
#include<stdio.h>
int main(){
int a[10],i,n,m,c=0,l,u,mid;
printf("Enter the size of an
array: ");
scanf("%d",&n);
printf("Enter the elements in
ascending order: ");
for(i=0;i<n;i++){
scanf("%d",&a[i]);
}
printf("Enter the number to be
search: ");
scanf("%d",&m);
CODE
l=0,u=n-1;
while(l<=u){
mid=(l+u)/2;
if(m==a[mid]){
c=1;
break;
}
else if(m<a[mid]){
u=mid-1;
}
else
l=mid+1;
}
if(c==0)
printf("The number is not found.");
else
printf("The number is found.");
return 0;
}
Enter the elements of the array in ascending order
12
Enter the elements of the array in ascending order
23
Enter the elements of the array in ascending order
34
Enter the elements of the array in ascending order
45
Enter the elements of the array in ascending order
56
Enter the elements of the array in ascending order
67
Enter the elements of the array in ascending order
78
Enter the elements of the array in ascending order
89
Enter the elements of the array in ascending order
98
Enter the elements of the array in ascending order
100
Enter the number to be searched
67
found
Search
Search

More Related Content

What's hot

Implement a queue using two stacks.
Implement a queue using two stacks.Implement a queue using two stacks.
Implement a queue using two stacks.
Dr. Loganathan R
 
Bcsl 033 data and file structures lab s3-3
Bcsl 033 data and file structures lab s3-3Bcsl 033 data and file structures lab s3-3
Bcsl 033 data and file structures lab s3-3
Dr. Loganathan R
 
Bcsl 033 data and file structures lab s2-2
Bcsl 033 data and file structures lab s2-2Bcsl 033 data and file structures lab s2-2
Bcsl 033 data and file structures lab s2-2
Dr. Loganathan R
 
C programming codes for the class assignment
C programming codes for the class assignmentC programming codes for the class assignment
C programming codes for the class assignment
Zenith SVG
 
Matlab lab exe
Matlab lab exeMatlab lab exe
Matlab lab exe
Dr. Krishna Mohbey
 
Bcsl 033 data and file structures lab s5-3
Bcsl 033 data and file structures lab s5-3Bcsl 033 data and file structures lab s5-3
Bcsl 033 data and file structures lab s5-3
Dr. Loganathan R
 
Bcsl 033 data and file structures lab s1-3
Bcsl 033 data and file structures lab s1-3Bcsl 033 data and file structures lab s1-3
Bcsl 033 data and file structures lab s1-3
Dr. Loganathan R
 
Decorator Design Pattern in C#
Decorator Design Pattern in C#Decorator Design Pattern in C#
Decorator Design Pattern in C#
Kasun Ranga Wijeweera
 
201801 CSE240 Lecture 11
201801 CSE240 Lecture 11201801 CSE240 Lecture 11
201801 CSE240 Lecture 11
Javier Gonzalez-Sanchez
 
คำสั่ง Do while
คำสั่ง Do whileคำสั่ง Do while
คำสั่ง Do whilekramsri
 
Singleton Design Pattern in C#
Singleton Design Pattern in C#Singleton Design Pattern in C#
Singleton Design Pattern in C#
Kasun Ranga Wijeweera
 
Core 3 Functions 2
Core 3 Functions 2Core 3 Functions 2
Core 3 Functions 2
davidmiles100
 
10 2 배열 응용
10 2 배열 응용10 2 배열 응용
10 2 배열 응용
Changwon National University
 
Runge kutta C programme
Runge kutta C programmeRunge kutta C programme
Runge kutta C programmeShah Keval
 
Bcsl 033 data and file structures lab s5-2
Bcsl 033 data and file structures lab s5-2Bcsl 033 data and file structures lab s5-2
Bcsl 033 data and file structures lab s5-2
Dr. Loganathan R
 
Insertion sort
Insertion sortInsertion sort
Insertion sort
Hitesh Kumar
 

What's hot (19)

Implement a queue using two stacks.
Implement a queue using two stacks.Implement a queue using two stacks.
Implement a queue using two stacks.
 
Bcsl 033 data and file structures lab s3-3
Bcsl 033 data and file structures lab s3-3Bcsl 033 data and file structures lab s3-3
Bcsl 033 data and file structures lab s3-3
 
Bcsl 033 data and file structures lab s2-2
Bcsl 033 data and file structures lab s2-2Bcsl 033 data and file structures lab s2-2
Bcsl 033 data and file structures lab s2-2
 
C programming codes for the class assignment
C programming codes for the class assignmentC programming codes for the class assignment
C programming codes for the class assignment
 
Spiral array
Spiral arraySpiral array
Spiral array
 
Matlab lab exe
Matlab lab exeMatlab lab exe
Matlab lab exe
 
Bcsl 033 data and file structures lab s5-3
Bcsl 033 data and file structures lab s5-3Bcsl 033 data and file structures lab s5-3
Bcsl 033 data and file structures lab s5-3
 
Bcsl 033 data and file structures lab s1-3
Bcsl 033 data and file structures lab s1-3Bcsl 033 data and file structures lab s1-3
Bcsl 033 data and file structures lab s1-3
 
Decorator Design Pattern in C#
Decorator Design Pattern in C#Decorator Design Pattern in C#
Decorator Design Pattern in C#
 
201801 CSE240 Lecture 11
201801 CSE240 Lecture 11201801 CSE240 Lecture 11
201801 CSE240 Lecture 11
 
คำสั่ง Do while
คำสั่ง Do whileคำสั่ง Do while
คำสั่ง Do while
 
Singleton Design Pattern in C#
Singleton Design Pattern in C#Singleton Design Pattern in C#
Singleton Design Pattern in C#
 
Core 3 Functions 2
Core 3 Functions 2Core 3 Functions 2
Core 3 Functions 2
 
week-8x
week-8xweek-8x
week-8x
 
10 2 배열 응용
10 2 배열 응용10 2 배열 응용
10 2 배열 응용
 
programs
programsprograms
programs
 
Runge kutta C programme
Runge kutta C programmeRunge kutta C programme
Runge kutta C programme
 
Bcsl 033 data and file structures lab s5-2
Bcsl 033 data and file structures lab s5-2Bcsl 033 data and file structures lab s5-2
Bcsl 033 data and file structures lab s5-2
 
Insertion sort
Insertion sortInsertion sort
Insertion sort
 

Viewers also liked

Mixx2016_Ануреев_Дмитрий
Mixx2016_Ануреев_ДмитрийMixx2016_Ануреев_Дмитрий
Mixx2016_Ануреев_Дмитрий
iabrussiaprez
 
Cmsascode
CmsascodeCmsascode
Cmsascode
tricknik
 
Tecnicas de evaluacion de proyectos
Tecnicas de evaluacion de proyectosTecnicas de evaluacion de proyectos
Tecnicas de evaluacion de proyectos
Javier Garcia
 
Adapting our API for multiple platforms
Adapting our API for multiple platformsAdapting our API for multiple platforms
Adapting our API for multiple platforms
Rouven Weßling
 
Kendra Shot List
Kendra Shot ListKendra Shot List
Kendra Shot List
Kendra Maduray
 
Storyboard title sequence (1)
Storyboard title sequence (1)Storyboard title sequence (1)
Storyboard title sequence (1)
Annika Laws-Walsh
 
Idioms and fixed expressions (i)
Idioms and fixed expressions (i)Idioms and fixed expressions (i)
Idioms and fixed expressions (i)
Meeting Point Cerdanyola
 
Phrasal verbs and Idioms Quiz FCE
Phrasal verbs and Idioms Quiz FCEPhrasal verbs and Idioms Quiz FCE
Phrasal verbs and Idioms Quiz FCE
Meeting Point Cerdanyola
 
Indice libro "SEO e SEM Guida Avanzata al Web Marketing" 4° Edizione
Indice libro "SEO e SEM Guida Avanzata al Web Marketing" 4° EdizioneIndice libro "SEO e SEM Guida Avanzata al Web Marketing" 4° Edizione
Indice libro "SEO e SEM Guida Avanzata al Web Marketing" 4° Edizione
Libro SEO
 
CIM Formación - Fitoterapia para los trastornos del sistema nervioso
CIM Formación - Fitoterapia para los trastornos del sistema nerviosoCIM Formación - Fitoterapia para los trastornos del sistema nervioso
CIM Formación - Fitoterapia para los trastornos del sistema nervioso
CIM Grupo de Formación
 

Viewers also liked (11)

Mixx2016_Ануреев_Дмитрий
Mixx2016_Ануреев_ДмитрийMixx2016_Ануреев_Дмитрий
Mixx2016_Ануреев_Дмитрий
 
Suquet de peix
Suquet de peixSuquet de peix
Suquet de peix
 
Cmsascode
CmsascodeCmsascode
Cmsascode
 
Tecnicas de evaluacion de proyectos
Tecnicas de evaluacion de proyectosTecnicas de evaluacion de proyectos
Tecnicas de evaluacion de proyectos
 
Adapting our API for multiple platforms
Adapting our API for multiple platformsAdapting our API for multiple platforms
Adapting our API for multiple platforms
 
Kendra Shot List
Kendra Shot ListKendra Shot List
Kendra Shot List
 
Storyboard title sequence (1)
Storyboard title sequence (1)Storyboard title sequence (1)
Storyboard title sequence (1)
 
Idioms and fixed expressions (i)
Idioms and fixed expressions (i)Idioms and fixed expressions (i)
Idioms and fixed expressions (i)
 
Phrasal verbs and Idioms Quiz FCE
Phrasal verbs and Idioms Quiz FCEPhrasal verbs and Idioms Quiz FCE
Phrasal verbs and Idioms Quiz FCE
 
Indice libro "SEO e SEM Guida Avanzata al Web Marketing" 4° Edizione
Indice libro "SEO e SEM Guida Avanzata al Web Marketing" 4° EdizioneIndice libro "SEO e SEM Guida Avanzata al Web Marketing" 4° Edizione
Indice libro "SEO e SEM Guida Avanzata al Web Marketing" 4° Edizione
 
CIM Formación - Fitoterapia para los trastornos del sistema nervioso
CIM Formación - Fitoterapia para los trastornos del sistema nerviosoCIM Formación - Fitoterapia para los trastornos del sistema nervioso
CIM Formación - Fitoterapia para los trastornos del sistema nervioso
 

Similar to Search

Computer Science Practical Science C++ with SQL commands
Computer Science Practical Science C++ with SQL commandsComputer Science Practical Science C++ with SQL commands
Computer Science Practical Science C++ with SQL commands
Vishvjeet Yadav
 
Sequential & binary, linear search
Sequential & binary, linear searchSequential & binary, linear search
Sequential & binary, linear search
montazur420
 
DSC program.pdf
DSC program.pdfDSC program.pdf
DSC program.pdf
Prof. Dr. K. Adisesha
 
Data Structures Using C Practical File
Data Structures Using C Practical File Data Structures Using C Practical File
Data Structures Using C Practical File
Rahul Chugh
 
unit-2-dsa.pptx
unit-2-dsa.pptxunit-2-dsa.pptx
unit-2-dsa.pptx
sayalishivarkar1
 
2D array
2D array2D array
2D array
A. S. M. Shafi
 
Data structure new lab manual
Data structure  new lab manualData structure  new lab manual
Data structure new lab manualSANTOSH RATH
 
ARRAY in python and c with examples .pptx
ARRAY  in python and c with examples .pptxARRAY  in python and c with examples .pptx
ARRAY in python and c with examples .pptx
abhishekmaurya102515
 
C programs
C programsC programs
C programs
Koshy Geoji
 
Arrays in C
Arrays in CArrays in C
Arrays in C
Kamruddin Nur
 
Pnno
PnnoPnno
Singly linked list.pptx
Singly linked list.pptxSingly linked list.pptx
Singly linked list.pptx
Santhiya S
 
‏‏chap6 list tuples.pptx
‏‏chap6 list tuples.pptx‏‏chap6 list tuples.pptx
‏‏chap6 list tuples.pptx
RamiHarrathi1
 
Data Structures- Part3 arrays and searching algorithms
Data Structures- Part3 arrays and searching algorithmsData Structures- Part3 arrays and searching algorithms
Data Structures- Part3 arrays and searching algorithms
Abdullah Al-hazmy
 
DATA STRUCTURE CLASS 12 COMPUTER SCIENCE
DATA STRUCTURE CLASS 12 COMPUTER SCIENCEDATA STRUCTURE CLASS 12 COMPUTER SCIENCE
DATA STRUCTURE CLASS 12 COMPUTER SCIENCE
Dev Chauhan
 
03 Linear Arrays Memory Representations .pdf
03 Linear Arrays Memory Representations .pdf03 Linear Arrays Memory Representations .pdf
03 Linear Arrays Memory Representations .pdf
KkSingh64
 
design and analysis of algorithm Lab files
design and analysis of algorithm Lab filesdesign and analysis of algorithm Lab files
design and analysis of algorithm Lab files
Nitesh Dubey
 
Sorting programs
Sorting programsSorting programs
Sorting programsVarun Garg
 

Similar to Search (20)

Arrays
ArraysArrays
Arrays
 
Computer Science Practical Science C++ with SQL commands
Computer Science Practical Science C++ with SQL commandsComputer Science Practical Science C++ with SQL commands
Computer Science Practical Science C++ with SQL commands
 
Sequential & binary, linear search
Sequential & binary, linear searchSequential & binary, linear search
Sequential & binary, linear search
 
DSC program.pdf
DSC program.pdfDSC program.pdf
DSC program.pdf
 
Data Structures Using C Practical File
Data Structures Using C Practical File Data Structures Using C Practical File
Data Structures Using C Practical File
 
unit-2-dsa.pptx
unit-2-dsa.pptxunit-2-dsa.pptx
unit-2-dsa.pptx
 
2D array
2D array2D array
2D array
 
Data structure new lab manual
Data structure  new lab manualData structure  new lab manual
Data structure new lab manual
 
ARRAY in python and c with examples .pptx
ARRAY  in python and c with examples .pptxARRAY  in python and c with examples .pptx
ARRAY in python and c with examples .pptx
 
C programs
C programsC programs
C programs
 
Arrays in C
Arrays in CArrays in C
Arrays in C
 
Pnno
PnnoPnno
Pnno
 
Singly linked list.pptx
Singly linked list.pptxSingly linked list.pptx
Singly linked list.pptx
 
‏‏chap6 list tuples.pptx
‏‏chap6 list tuples.pptx‏‏chap6 list tuples.pptx
‏‏chap6 list tuples.pptx
 
Data Structures- Part3 arrays and searching algorithms
Data Structures- Part3 arrays and searching algorithmsData Structures- Part3 arrays and searching algorithms
Data Structures- Part3 arrays and searching algorithms
 
DATA STRUCTURE CLASS 12 COMPUTER SCIENCE
DATA STRUCTURE CLASS 12 COMPUTER SCIENCEDATA STRUCTURE CLASS 12 COMPUTER SCIENCE
DATA STRUCTURE CLASS 12 COMPUTER SCIENCE
 
03 Linear Arrays Memory Representations .pdf
03 Linear Arrays Memory Representations .pdf03 Linear Arrays Memory Representations .pdf
03 Linear Arrays Memory Representations .pdf
 
design and analysis of algorithm Lab files
design and analysis of algorithm Lab filesdesign and analysis of algorithm Lab files
design and analysis of algorithm Lab files
 
Report 02(Binary Search)
Report 02(Binary Search)Report 02(Binary Search)
Report 02(Binary Search)
 
Sorting programs
Sorting programsSorting programs
Sorting programs
 

More from Daffodil International University

Bresenham algorithm
Bresenham algorithmBresenham algorithm
The Waterfall Model & RAD MODEL
 The Waterfall Model &  RAD MODEL The Waterfall Model &  RAD MODEL
The Waterfall Model & RAD MODEL
Daffodil International University
 
Reinforcement learning
Reinforcement learningReinforcement learning
Reinforcement learning
Daffodil International University
 
online marketing
online marketingonline marketing
Bioinformatics lesson
Bioinformatics lessonBioinformatics lesson
Bioinformatics lesson
Daffodil International University
 
Bioinformatics lesson
Bioinformatics lessonBioinformatics lesson
Bioinformatics lesson
Daffodil International University
 
stack in assembally language
stack in assembally languagestack in assembally language
stack in assembally language
Daffodil International University
 
Complex number
Complex numberComplex number
Ahsan Manzil
Ahsan Manzil Ahsan Manzil
Applications of numerical methods
Applications of numerical methodsApplications of numerical methods
Applications of numerical methods
Daffodil International University
 
Finite difference &amp; interpolation
Finite difference &amp; interpolationFinite difference &amp; interpolation
Finite difference &amp; interpolation
Daffodil International University
 

More from Daffodil International University (20)

Bresenham algorithm
Bresenham algorithmBresenham algorithm
Bresenham algorithm
 
Tic Tac Toe
Tic Tac ToeTic Tac Toe
Tic Tac Toe
 
The Waterfall Model & RAD MODEL
 The Waterfall Model &  RAD MODEL The Waterfall Model &  RAD MODEL
The Waterfall Model & RAD MODEL
 
Reinforcement learning
Reinforcement learningReinforcement learning
Reinforcement learning
 
online marketing
online marketingonline marketing
online marketing
 
normalization
normalizationnormalization
normalization
 
Bioinformatics lesson
Bioinformatics lessonBioinformatics lesson
Bioinformatics lesson
 
Blasta
BlastaBlasta
Blasta
 
Bioinformatics lesson
Bioinformatics lessonBioinformatics lesson
Bioinformatics lesson
 
Liver
LiverLiver
Liver
 
Numerical methods
Numerical methodsNumerical methods
Numerical methods
 
stack in assembally language
stack in assembally languagestack in assembally language
stack in assembally language
 
OSI Model
OSI ModelOSI Model
OSI Model
 
Topology
TopologyTopology
Topology
 
Complex number
Complex numberComplex number
Complex number
 
Ahsan Manzil
Ahsan Manzil Ahsan Manzil
Ahsan Manzil
 
Big data
Big dataBig data
Big data
 
Encoders
EncodersEncoders
Encoders
 
Applications of numerical methods
Applications of numerical methodsApplications of numerical methods
Applications of numerical methods
 
Finite difference &amp; interpolation
Finite difference &amp; interpolationFinite difference &amp; interpolation
Finite difference &amp; interpolation
 

Recently uploaded

A Survey of Techniques for Maximizing LLM Performance.pptx
A Survey of Techniques for Maximizing LLM Performance.pptxA Survey of Techniques for Maximizing LLM Performance.pptx
A Survey of Techniques for Maximizing LLM Performance.pptx
thanhdowork
 
2024.06.01 Introducing a competency framework for languag learning materials ...
2024.06.01 Introducing a competency framework for languag learning materials ...2024.06.01 Introducing a competency framework for languag learning materials ...
2024.06.01 Introducing a competency framework for languag learning materials ...
Sandy Millin
 
Normal Labour/ Stages of Labour/ Mechanism of Labour
Normal Labour/ Stages of Labour/ Mechanism of LabourNormal Labour/ Stages of Labour/ Mechanism of Labour
Normal Labour/ Stages of Labour/ Mechanism of Labour
Wasim Ak
 
Model Attribute Check Company Auto Property
Model Attribute  Check Company Auto PropertyModel Attribute  Check Company Auto Property
Model Attribute Check Company Auto Property
Celine George
 
Acetabularia Information For Class 9 .docx
Acetabularia Information For Class 9  .docxAcetabularia Information For Class 9  .docx
Acetabularia Information For Class 9 .docx
vaibhavrinwa19
 
Natural birth techniques - Mrs.Akanksha Trivedi Rama University
Natural birth techniques - Mrs.Akanksha Trivedi Rama UniversityNatural birth techniques - Mrs.Akanksha Trivedi Rama University
Natural birth techniques - Mrs.Akanksha Trivedi Rama University
Akanksha trivedi rama nursing college kanpur.
 
Chapter -12, Antibiotics (One Page Notes).pdf
Chapter -12, Antibiotics (One Page Notes).pdfChapter -12, Antibiotics (One Page Notes).pdf
Chapter -12, Antibiotics (One Page Notes).pdf
Kartik Tiwari
 
Best Digital Marketing Institute In NOIDA
Best Digital Marketing Institute In NOIDABest Digital Marketing Institute In NOIDA
Best Digital Marketing Institute In NOIDA
deeptiverma2406
 
Mule 4.6 & Java 17 Upgrade | MuleSoft Mysore Meetup #46
Mule 4.6 & Java 17 Upgrade | MuleSoft Mysore Meetup #46Mule 4.6 & Java 17 Upgrade | MuleSoft Mysore Meetup #46
Mule 4.6 & Java 17 Upgrade | MuleSoft Mysore Meetup #46
MysoreMuleSoftMeetup
 
How to Make a Field invisible in Odoo 17
How to Make a Field invisible in Odoo 17How to Make a Field invisible in Odoo 17
How to Make a Field invisible in Odoo 17
Celine George
 
Exploiting Artificial Intelligence for Empowering Researchers and Faculty, In...
Exploiting Artificial Intelligence for Empowering Researchers and Faculty, In...Exploiting Artificial Intelligence for Empowering Researchers and Faculty, In...
Exploiting Artificial Intelligence for Empowering Researchers and Faculty, In...
Dr. Vinod Kumar Kanvaria
 
Marketing internship report file for MBA
Marketing internship report file for MBAMarketing internship report file for MBA
Marketing internship report file for MBA
gb193092
 
"Protectable subject matters, Protection in biotechnology, Protection of othe...
"Protectable subject matters, Protection in biotechnology, Protection of othe..."Protectable subject matters, Protection in biotechnology, Protection of othe...
"Protectable subject matters, Protection in biotechnology, Protection of othe...
SACHIN R KONDAGURI
 
June 3, 2024 Anti-Semitism Letter Sent to MIT President Kornbluth and MIT Cor...
June 3, 2024 Anti-Semitism Letter Sent to MIT President Kornbluth and MIT Cor...June 3, 2024 Anti-Semitism Letter Sent to MIT President Kornbluth and MIT Cor...
June 3, 2024 Anti-Semitism Letter Sent to MIT President Kornbluth and MIT Cor...
Levi Shapiro
 
Unit 2- Research Aptitude (UGC NET Paper I).pdf
Unit 2- Research Aptitude (UGC NET Paper I).pdfUnit 2- Research Aptitude (UGC NET Paper I).pdf
Unit 2- Research Aptitude (UGC NET Paper I).pdf
Thiyagu K
 
Unit 8 - Information and Communication Technology (Paper I).pdf
Unit 8 - Information and Communication Technology (Paper I).pdfUnit 8 - Information and Communication Technology (Paper I).pdf
Unit 8 - Information and Communication Technology (Paper I).pdf
Thiyagu K
 
The basics of sentences session 5pptx.pptx
The basics of sentences session 5pptx.pptxThe basics of sentences session 5pptx.pptx
The basics of sentences session 5pptx.pptx
heathfieldcps1
 
Multithreading_in_C++ - std::thread, race condition
Multithreading_in_C++ - std::thread, race conditionMultithreading_in_C++ - std::thread, race condition
Multithreading_in_C++ - std::thread, race condition
Mohammed Sikander
 
The Diamond Necklace by Guy De Maupassant.pptx
The Diamond Necklace by Guy De Maupassant.pptxThe Diamond Necklace by Guy De Maupassant.pptx
The Diamond Necklace by Guy De Maupassant.pptx
DhatriParmar
 
Embracing GenAI - A Strategic Imperative
Embracing GenAI - A Strategic ImperativeEmbracing GenAI - A Strategic Imperative
Embracing GenAI - A Strategic Imperative
Peter Windle
 

Recently uploaded (20)

A Survey of Techniques for Maximizing LLM Performance.pptx
A Survey of Techniques for Maximizing LLM Performance.pptxA Survey of Techniques for Maximizing LLM Performance.pptx
A Survey of Techniques for Maximizing LLM Performance.pptx
 
2024.06.01 Introducing a competency framework for languag learning materials ...
2024.06.01 Introducing a competency framework for languag learning materials ...2024.06.01 Introducing a competency framework for languag learning materials ...
2024.06.01 Introducing a competency framework for languag learning materials ...
 
Normal Labour/ Stages of Labour/ Mechanism of Labour
Normal Labour/ Stages of Labour/ Mechanism of LabourNormal Labour/ Stages of Labour/ Mechanism of Labour
Normal Labour/ Stages of Labour/ Mechanism of Labour
 
Model Attribute Check Company Auto Property
Model Attribute  Check Company Auto PropertyModel Attribute  Check Company Auto Property
Model Attribute Check Company Auto Property
 
Acetabularia Information For Class 9 .docx
Acetabularia Information For Class 9  .docxAcetabularia Information For Class 9  .docx
Acetabularia Information For Class 9 .docx
 
Natural birth techniques - Mrs.Akanksha Trivedi Rama University
Natural birth techniques - Mrs.Akanksha Trivedi Rama UniversityNatural birth techniques - Mrs.Akanksha Trivedi Rama University
Natural birth techniques - Mrs.Akanksha Trivedi Rama University
 
Chapter -12, Antibiotics (One Page Notes).pdf
Chapter -12, Antibiotics (One Page Notes).pdfChapter -12, Antibiotics (One Page Notes).pdf
Chapter -12, Antibiotics (One Page Notes).pdf
 
Best Digital Marketing Institute In NOIDA
Best Digital Marketing Institute In NOIDABest Digital Marketing Institute In NOIDA
Best Digital Marketing Institute In NOIDA
 
Mule 4.6 & Java 17 Upgrade | MuleSoft Mysore Meetup #46
Mule 4.6 & Java 17 Upgrade | MuleSoft Mysore Meetup #46Mule 4.6 & Java 17 Upgrade | MuleSoft Mysore Meetup #46
Mule 4.6 & Java 17 Upgrade | MuleSoft Mysore Meetup #46
 
How to Make a Field invisible in Odoo 17
How to Make a Field invisible in Odoo 17How to Make a Field invisible in Odoo 17
How to Make a Field invisible in Odoo 17
 
Exploiting Artificial Intelligence for Empowering Researchers and Faculty, In...
Exploiting Artificial Intelligence for Empowering Researchers and Faculty, In...Exploiting Artificial Intelligence for Empowering Researchers and Faculty, In...
Exploiting Artificial Intelligence for Empowering Researchers and Faculty, In...
 
Marketing internship report file for MBA
Marketing internship report file for MBAMarketing internship report file for MBA
Marketing internship report file for MBA
 
"Protectable subject matters, Protection in biotechnology, Protection of othe...
"Protectable subject matters, Protection in biotechnology, Protection of othe..."Protectable subject matters, Protection in biotechnology, Protection of othe...
"Protectable subject matters, Protection in biotechnology, Protection of othe...
 
June 3, 2024 Anti-Semitism Letter Sent to MIT President Kornbluth and MIT Cor...
June 3, 2024 Anti-Semitism Letter Sent to MIT President Kornbluth and MIT Cor...June 3, 2024 Anti-Semitism Letter Sent to MIT President Kornbluth and MIT Cor...
June 3, 2024 Anti-Semitism Letter Sent to MIT President Kornbluth and MIT Cor...
 
Unit 2- Research Aptitude (UGC NET Paper I).pdf
Unit 2- Research Aptitude (UGC NET Paper I).pdfUnit 2- Research Aptitude (UGC NET Paper I).pdf
Unit 2- Research Aptitude (UGC NET Paper I).pdf
 
Unit 8 - Information and Communication Technology (Paper I).pdf
Unit 8 - Information and Communication Technology (Paper I).pdfUnit 8 - Information and Communication Technology (Paper I).pdf
Unit 8 - Information and Communication Technology (Paper I).pdf
 
The basics of sentences session 5pptx.pptx
The basics of sentences session 5pptx.pptxThe basics of sentences session 5pptx.pptx
The basics of sentences session 5pptx.pptx
 
Multithreading_in_C++ - std::thread, race condition
Multithreading_in_C++ - std::thread, race conditionMultithreading_in_C++ - std::thread, race condition
Multithreading_in_C++ - std::thread, race condition
 
The Diamond Necklace by Guy De Maupassant.pptx
The Diamond Necklace by Guy De Maupassant.pptxThe Diamond Necklace by Guy De Maupassant.pptx
The Diamond Necklace by Guy De Maupassant.pptx
 
Embracing GenAI - A Strategic Imperative
Embracing GenAI - A Strategic ImperativeEmbracing GenAI - A Strategic Imperative
Embracing GenAI - A Strategic Imperative
 

Search

  • 1.
  • 2. Mehedi Hassan 161-15-7667 Arafat Rahman 152-15-5983 Nazmul Islam 152- 15-5652 Taijul Islam 152- 15-5613
  • 3. Name : Ms. Rifat Ara Shams Designation : Senior Lecturer Department : Department of Computer Science and Engineering E-mail : rifat.cse@diu.edu.bd Cell-Phone : +880-1723256560
  • 4.
  • 6. LINEAR SEARCH 10 46 8 996 2 34 19578 ENTER THE ARRAY ELEMENTS ENTER THE NUMBER TO BE SEARCHED 2 M[0] M[1] M[2] M[3] M[4] M[5] M[6] M{7] M[8] M[9]
  • 7. LINEAR SEARCH 10 46 8 996 2 34 19578 2 2 2 2 2 2 THE NUMBER IS FOUND IN THE 6TH POSITION
  • 8. #include <stdio.h> int main() { int array[100], search, c, n; printf("Enter the number of elements in arrayn"); scanf("%d",&n); printf("Enter %d integer(s)n", n); for (c = 0; c < n; c++) scanf("%d", &array[c]); CODE
  • 9. printf("Enter the number to searchn"); scanf("%d", &search); for (c = 0; c < n; c++) { if (array[c] == search) /* if required element found */ { printf("%d is present at location %d.n", search, c+1); break; } } if (c == n) printf("%d is not present in array.n", search); return 0; }
  • 10.
  • 11. BINARY SEARCH 1 5 8 2412 36 48 876754 ENTER THE ARRAY ELEMENTS ENTER THE NUMBER TO BE SEARCHED 36 M[0] M[1] M[2] M[3] M[4] M[5] M[6] M{7] M[8] M[9]
  • 12. BINARY SEARCH 1 5 8 2412 36 48 876754 ENTER THE ARRAY ELEMENTS ENTER THE NUMBER TO BE SEARCHED 36 M[0] M[1] M[2] M[3] M[4] M[5] M[6] M{7] M[8] M[9] LB UB
  • 13. P=LB+UB/2 24 STEP 1 FIND THE MIDDLE ELEMENT P=0+9/2
  • 14. 24 36< 36 48 54 67 87 THE SEARCH ELEMENT LIES IN THE UB 0 1 2 3 4 COMPARING SEARCH WITH MIDDLE ELEMENT STEP 2
  • 15. P=LB+UB/2 54 54 > 36 36 48 STEP 3 DIVIDE THE ARRAY FURTHER COMPARING SEARCH WITH MIDDLE ELEMENT THE SEARCH ELEMENT LIES IN THE LB
  • 16. 3636 = NUMBER FOUND STEP 4 36 48 MIDDLE ELEMENT IS COMPARED WITH THE ELEMENTS IN THE ARRAY
  • 17. #include<stdio.h> int main(){ int a[10],i,n,m,c=0,l,u,mid; printf("Enter the size of an array: "); scanf("%d",&n); printf("Enter the elements in ascending order: "); for(i=0;i<n;i++){ scanf("%d",&a[i]); } printf("Enter the number to be search: "); scanf("%d",&m); CODE
  • 19. Enter the elements of the array in ascending order 12 Enter the elements of the array in ascending order 23 Enter the elements of the array in ascending order 34 Enter the elements of the array in ascending order 45 Enter the elements of the array in ascending order 56 Enter the elements of the array in ascending order 67 Enter the elements of the array in ascending order 78 Enter the elements of the array in ascending order 89 Enter the elements of the array in ascending order 98 Enter the elements of the array in ascending order 100 Enter the number to be searched 67 found