SlideShare a Scribd company logo
1 of 21
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
Linear and Bianry search
Linear and Bianry search

More Related Content

What's hot

Dsa – data structure and algorithms searching
Dsa – data structure and algorithms   searchingDsa – data structure and algorithms   searching
Dsa – data structure and algorithms searchingsajinis3
 
Rahat &amp; juhith
Rahat &amp; juhithRahat &amp; juhith
Rahat &amp; juhithRj Juhith
 
Binary search algorithm
Binary search algorithmBinary search algorithm
Binary search algorithmmaamir farooq
 
Linear search algorithm
Linear search algorithmLinear search algorithm
Linear search algorithmNeoClassical
 
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 StructureBalwant Gorad
 
Dsa – data structure and algorithms sorting
Dsa – data structure and algorithms  sortingDsa – data structure and algorithms  sorting
Dsa – data structure and algorithms sortingsajinis3
 
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
 
Sorting and searching arrays binary search algorithm
Sorting and searching arrays binary search algorithmSorting and searching arrays binary search algorithm
Sorting and searching arrays binary search algorithmDavid Burks-Courses
 
Searching Techniques and Analysis
Searching Techniques and AnalysisSearching Techniques and Analysis
Searching Techniques and AnalysisAkashBorse2
 
Binary search
Binary search Binary search
Binary search Raghu nath
 
Algorithms Intro Lecture
Algorithms Intro LectureAlgorithms Intro Lecture
Algorithms Intro LectureIra D
 
Linear and Binary search
Linear and Binary searchLinear and Binary search
Linear and Binary searchNisha Soms
 

What's hot (20)

Dsa – data structure and algorithms searching
Dsa – data structure and algorithms   searchingDsa – data structure and algorithms   searching
Dsa – data structure and algorithms searching
 
Rahat &amp; juhith
Rahat &amp; juhithRahat &amp; juhith
Rahat &amp; juhith
 
Algorithm and Programming (Searching)
Algorithm and Programming (Searching)Algorithm and Programming (Searching)
Algorithm and Programming (Searching)
 
Binary search algorithm
Binary search algorithmBinary search algorithm
Binary search algorithm
 
Linear search algorithm
Linear search algorithmLinear search algorithm
Linear search algorithm
 
Linear search-and-binary-search
Linear search-and-binary-searchLinear search-and-binary-search
Linear search-and-binary-search
 
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
 
Dsa – data structure and algorithms sorting
Dsa – data structure and algorithms  sortingDsa – data structure and algorithms  sorting
Dsa – data structure and algorithms sorting
 
Binary Search
Binary SearchBinary Search
Binary Search
 
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...
 
Sorting and searching arrays binary search algorithm
Sorting and searching arrays binary search algorithmSorting and searching arrays binary search algorithm
Sorting and searching arrays binary search algorithm
 
Searching Techniques and Analysis
Searching Techniques and AnalysisSearching Techniques and Analysis
Searching Techniques and Analysis
 
L 14-ct1120
L 14-ct1120L 14-ct1120
L 14-ct1120
 
Binary search
Binary search Binary search
Binary search
 
Algorithms Intro Lecture
Algorithms Intro LectureAlgorithms Intro Lecture
Algorithms Intro Lecture
 
Hashing data
Hashing dataHashing data
Hashing data
 
Linear and Binary search
Linear and Binary searchLinear and Binary search
Linear and Binary search
 
Binary search2
Binary search2Binary search2
Binary search2
 
Binary search
Binary searchBinary search
Binary search
 
Hashing 1
Hashing 1Hashing 1
Hashing 1
 

Viewers also liked

Searching linear &amp; binary search
Searching linear &amp; binary searchSearching linear &amp; binary search
Searching linear &amp; binary searchnikunjandy
 
Linear Search & Binary Search
Linear Search & Binary SearchLinear Search & Binary Search
Linear Search & Binary SearchReem Alattas
 
Data Structures - Searching & sorting
Data Structures - Searching & sortingData Structures - Searching & sorting
Data Structures - Searching & sortingKaushal Shah
 
2. Linear Data Structure Using Arrays - Data Structures using C++ by Varsha P...
2. Linear Data Structure Using Arrays - Data Structures using C++ by Varsha P...2. Linear Data Structure Using Arrays - Data Structures using C++ by Varsha P...
2. Linear Data Structure Using Arrays - Data Structures using C++ by Varsha P...widespreadpromotion
 
Chapter 11 - Sorting and Searching
Chapter 11 - Sorting and SearchingChapter 11 - Sorting and Searching
Chapter 11 - Sorting and SearchingEduardo Bergavera
 
Data structure
Data structureData structure
Data structureM Ramya
 
Bubble sort
Bubble sort Bubble sort
Bubble sort rmsz786
 
Selection sort
Selection sortSelection sort
Selection sortstella D
 
Bec doms ppt on management information systems
Bec doms ppt on management information systemsBec doms ppt on management information systems
Bec doms ppt on management information systemsBabasab Patil
 
3.4 selection sort
3.4 selection sort3.4 selection sort
3.4 selection sortKrish_ver2
 
Selection sort
Selection sortSelection sort
Selection sortasra khan
 
Bubble sort a best presentation topic
Bubble sort a best presentation topicBubble sort a best presentation topic
Bubble sort a best presentation topicSaddam Hussain
 
Selection sort
Selection sortSelection sort
Selection sortJay Patel
 

Viewers also liked (20)

Searching linear &amp; binary search
Searching linear &amp; binary searchSearching linear &amp; binary search
Searching linear &amp; binary search
 
Linear Search & Binary Search
Linear Search & Binary SearchLinear Search & Binary Search
Linear Search & Binary Search
 
Linear and binary search
Linear and binary searchLinear and binary search
Linear and binary search
 
Data Structures - Searching & sorting
Data Structures - Searching & sortingData Structures - Searching & sorting
Data Structures - Searching & sorting
 
2. Linear Data Structure Using Arrays - Data Structures using C++ by Varsha P...
2. Linear Data Structure Using Arrays - Data Structures using C++ by Varsha P...2. Linear Data Structure Using Arrays - Data Structures using C++ by Varsha P...
2. Linear Data Structure Using Arrays - Data Structures using C++ by Varsha P...
 
Chapter 11 - Sorting and Searching
Chapter 11 - Sorting and SearchingChapter 11 - Sorting and Searching
Chapter 11 - Sorting and Searching
 
Data structure
Data structureData structure
Data structure
 
Sorting
SortingSorting
Sorting
 
Binary search
Binary searchBinary search
Binary search
 
sort search in C
 sort search in C  sort search in C
sort search in C
 
Bubble sort
Bubble sort Bubble sort
Bubble sort
 
Selection sort
Selection sortSelection sort
Selection sort
 
Bec doms ppt on management information systems
Bec doms ppt on management information systemsBec doms ppt on management information systems
Bec doms ppt on management information systems
 
The selection sort algorithm
The selection sort algorithmThe selection sort algorithm
The selection sort algorithm
 
Bubble sort algorithm
Bubble sort algorithmBubble sort algorithm
Bubble sort algorithm
 
3.4 selection sort
3.4 selection sort3.4 selection sort
3.4 selection sort
 
Selection sort
Selection sortSelection sort
Selection sort
 
Bubble sort a best presentation topic
Bubble sort a best presentation topicBubble sort a best presentation topic
Bubble sort a best presentation topic
 
Selection sort
Selection sortSelection sort
Selection sort
 
Selection sort
Selection sortSelection sort
Selection sort
 

Similar to Linear and Bianry 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 commandsVishvjeet Yadav
 
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
 
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 .pptxabhishekmaurya102515
 
Singly linked list.pptx
Singly linked list.pptxSingly linked list.pptx
Singly linked list.pptxSanthiya S
 
‏‏chap6 list tuples.pptx
‏‏chap6 list tuples.pptx‏‏chap6 list tuples.pptx
‏‏chap6 list tuples.pptxRamiHarrathi1
 
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 algorithmsAbdullah Al-hazmy
 
DATA STRUCTURE CLASS 12 COMPUTER SCIENCE
DATA STRUCTURE CLASS 12 COMPUTER SCIENCEDATA STRUCTURE CLASS 12 COMPUTER SCIENCE
DATA STRUCTURE CLASS 12 COMPUTER SCIENCEDev Chauhan
 
03 Linear Arrays Memory Representations .pdf
03 Linear Arrays Memory Representations .pdf03 Linear Arrays Memory Representations .pdf
03 Linear Arrays Memory Representations .pdfKkSingh64
 
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 filesNitesh Dubey
 
Sorting programs
Sorting programsSorting programs
Sorting programsVarun Garg
 

Similar to Linear and Bianry 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
 
Ds
DsDs
Ds
 
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 (9)

big data
big databig data
big data
 
N type-sc
N type-scN type-sc
N type-sc
 
Complex number
Complex numberComplex number
Complex number
 
Ahsan Manzil presentation‬
Ahsan  Manzil presentation‬Ahsan  Manzil presentation‬
Ahsan Manzil presentation‬
 
Encoders
EncodersEncoders
Encoders
 
Structure
StructureStructure
Structure
 
physics presentation
physics presentationphysics presentation
physics presentation
 
nuclear fusion
nuclear fusionnuclear fusion
nuclear fusion
 
2g 3g 4g
2g 3g 4g2g 3g 4g
2g 3g 4g
 

Recently uploaded

Full Stack Web Development Course for Beginners
Full Stack Web Development Course  for BeginnersFull Stack Web Development Course  for Beginners
Full Stack Web Development Course for BeginnersSabitha Banu
 
Computed Fields and api Depends in the Odoo 17
Computed Fields and api Depends in the Odoo 17Computed Fields and api Depends in the Odoo 17
Computed Fields and api Depends in the Odoo 17Celine George
 
Organic Name Reactions for the students and aspirants of Chemistry12th.pptx
Organic Name Reactions  for the students and aspirants of Chemistry12th.pptxOrganic Name Reactions  for the students and aspirants of Chemistry12th.pptx
Organic Name Reactions for the students and aspirants of Chemistry12th.pptxVS Mahajan Coaching Centre
 
How to Make a Pirate ship Primary Education.pptx
How to Make a Pirate ship Primary Education.pptxHow to Make a Pirate ship Primary Education.pptx
How to Make a Pirate ship Primary Education.pptxmanuelaromero2013
 
MARGINALIZATION (Different learners in Marginalized Group
MARGINALIZATION (Different learners in Marginalized GroupMARGINALIZATION (Different learners in Marginalized Group
MARGINALIZATION (Different learners in Marginalized GroupJonathanParaisoCruz
 
Types of Journalistic Writing Grade 8.pptx
Types of Journalistic Writing Grade 8.pptxTypes of Journalistic Writing Grade 8.pptx
Types of Journalistic Writing Grade 8.pptxEyham Joco
 
Solving Puzzles Benefits Everyone (English).pptx
Solving Puzzles Benefits Everyone (English).pptxSolving Puzzles Benefits Everyone (English).pptx
Solving Puzzles Benefits Everyone (English).pptxOH TEIK BIN
 
internship ppt on smartinternz platform as salesforce developer
internship ppt on smartinternz platform as salesforce developerinternship ppt on smartinternz platform as salesforce developer
internship ppt on smartinternz platform as salesforce developerunnathinaik
 
History Class XII Ch. 3 Kinship, Caste and Class (1).pptx
History Class XII Ch. 3 Kinship, Caste and Class (1).pptxHistory Class XII Ch. 3 Kinship, Caste and Class (1).pptx
History Class XII Ch. 3 Kinship, Caste and Class (1).pptxsocialsciencegdgrohi
 
Final demo Grade 9 for demo Plan dessert.pptx
Final demo Grade 9 for demo Plan dessert.pptxFinal demo Grade 9 for demo Plan dessert.pptx
Final demo Grade 9 for demo Plan dessert.pptxAvyJaneVismanos
 
Incoming and Outgoing Shipments in 1 STEP Using Odoo 17
Incoming and Outgoing Shipments in 1 STEP Using Odoo 17Incoming and Outgoing Shipments in 1 STEP Using Odoo 17
Incoming and Outgoing Shipments in 1 STEP Using Odoo 17Celine George
 
CARE OF CHILD IN INCUBATOR..........pptx
CARE OF CHILD IN INCUBATOR..........pptxCARE OF CHILD IN INCUBATOR..........pptx
CARE OF CHILD IN INCUBATOR..........pptxGaneshChakor2
 
Software Engineering Methodologies (overview)
Software Engineering Methodologies (overview)Software Engineering Methodologies (overview)
Software Engineering Methodologies (overview)eniolaolutunde
 
Capitol Tech U Doctoral Presentation - April 2024.pptx
Capitol Tech U Doctoral Presentation - April 2024.pptxCapitol Tech U Doctoral Presentation - April 2024.pptx
Capitol Tech U Doctoral Presentation - April 2024.pptxCapitolTechU
 
EPANDING THE CONTENT OF AN OUTLINE using notes.pptx
EPANDING THE CONTENT OF AN OUTLINE using notes.pptxEPANDING THE CONTENT OF AN OUTLINE using notes.pptx
EPANDING THE CONTENT OF AN OUTLINE using notes.pptxRaymartEstabillo3
 
ECONOMIC CONTEXT - PAPER 1 Q3: NEWSPAPERS.pptx
ECONOMIC CONTEXT - PAPER 1 Q3: NEWSPAPERS.pptxECONOMIC CONTEXT - PAPER 1 Q3: NEWSPAPERS.pptx
ECONOMIC CONTEXT - PAPER 1 Q3: NEWSPAPERS.pptxiammrhaywood
 
Proudly South Africa powerpoint Thorisha.pptx
Proudly South Africa powerpoint Thorisha.pptxProudly South Africa powerpoint Thorisha.pptx
Proudly South Africa powerpoint Thorisha.pptxthorishapillay1
 
Meghan Sutherland In Media Res Media Component
Meghan Sutherland In Media Res Media ComponentMeghan Sutherland In Media Res Media Component
Meghan Sutherland In Media Res Media ComponentInMediaRes1
 
Earth Day Presentation wow hello nice great
Earth Day Presentation wow hello nice greatEarth Day Presentation wow hello nice great
Earth Day Presentation wow hello nice greatYousafMalik24
 

Recently uploaded (20)

Full Stack Web Development Course for Beginners
Full Stack Web Development Course  for BeginnersFull Stack Web Development Course  for Beginners
Full Stack Web Development Course for Beginners
 
Computed Fields and api Depends in the Odoo 17
Computed Fields and api Depends in the Odoo 17Computed Fields and api Depends in the Odoo 17
Computed Fields and api Depends in the Odoo 17
 
Organic Name Reactions for the students and aspirants of Chemistry12th.pptx
Organic Name Reactions  for the students and aspirants of Chemistry12th.pptxOrganic Name Reactions  for the students and aspirants of Chemistry12th.pptx
Organic Name Reactions for the students and aspirants of Chemistry12th.pptx
 
How to Make a Pirate ship Primary Education.pptx
How to Make a Pirate ship Primary Education.pptxHow to Make a Pirate ship Primary Education.pptx
How to Make a Pirate ship Primary Education.pptx
 
MARGINALIZATION (Different learners in Marginalized Group
MARGINALIZATION (Different learners in Marginalized GroupMARGINALIZATION (Different learners in Marginalized Group
MARGINALIZATION (Different learners in Marginalized Group
 
Types of Journalistic Writing Grade 8.pptx
Types of Journalistic Writing Grade 8.pptxTypes of Journalistic Writing Grade 8.pptx
Types of Journalistic Writing Grade 8.pptx
 
Solving Puzzles Benefits Everyone (English).pptx
Solving Puzzles Benefits Everyone (English).pptxSolving Puzzles Benefits Everyone (English).pptx
Solving Puzzles Benefits Everyone (English).pptx
 
TataKelola dan KamSiber Kecerdasan Buatan v022.pdf
TataKelola dan KamSiber Kecerdasan Buatan v022.pdfTataKelola dan KamSiber Kecerdasan Buatan v022.pdf
TataKelola dan KamSiber Kecerdasan Buatan v022.pdf
 
internship ppt on smartinternz platform as salesforce developer
internship ppt on smartinternz platform as salesforce developerinternship ppt on smartinternz platform as salesforce developer
internship ppt on smartinternz platform as salesforce developer
 
History Class XII Ch. 3 Kinship, Caste and Class (1).pptx
History Class XII Ch. 3 Kinship, Caste and Class (1).pptxHistory Class XII Ch. 3 Kinship, Caste and Class (1).pptx
History Class XII Ch. 3 Kinship, Caste and Class (1).pptx
 
Final demo Grade 9 for demo Plan dessert.pptx
Final demo Grade 9 for demo Plan dessert.pptxFinal demo Grade 9 for demo Plan dessert.pptx
Final demo Grade 9 for demo Plan dessert.pptx
 
Incoming and Outgoing Shipments in 1 STEP Using Odoo 17
Incoming and Outgoing Shipments in 1 STEP Using Odoo 17Incoming and Outgoing Shipments in 1 STEP Using Odoo 17
Incoming and Outgoing Shipments in 1 STEP Using Odoo 17
 
CARE OF CHILD IN INCUBATOR..........pptx
CARE OF CHILD IN INCUBATOR..........pptxCARE OF CHILD IN INCUBATOR..........pptx
CARE OF CHILD IN INCUBATOR..........pptx
 
Software Engineering Methodologies (overview)
Software Engineering Methodologies (overview)Software Engineering Methodologies (overview)
Software Engineering Methodologies (overview)
 
Capitol Tech U Doctoral Presentation - April 2024.pptx
Capitol Tech U Doctoral Presentation - April 2024.pptxCapitol Tech U Doctoral Presentation - April 2024.pptx
Capitol Tech U Doctoral Presentation - April 2024.pptx
 
EPANDING THE CONTENT OF AN OUTLINE using notes.pptx
EPANDING THE CONTENT OF AN OUTLINE using notes.pptxEPANDING THE CONTENT OF AN OUTLINE using notes.pptx
EPANDING THE CONTENT OF AN OUTLINE using notes.pptx
 
ECONOMIC CONTEXT - PAPER 1 Q3: NEWSPAPERS.pptx
ECONOMIC CONTEXT - PAPER 1 Q3: NEWSPAPERS.pptxECONOMIC CONTEXT - PAPER 1 Q3: NEWSPAPERS.pptx
ECONOMIC CONTEXT - PAPER 1 Q3: NEWSPAPERS.pptx
 
Proudly South Africa powerpoint Thorisha.pptx
Proudly South Africa powerpoint Thorisha.pptxProudly South Africa powerpoint Thorisha.pptx
Proudly South Africa powerpoint Thorisha.pptx
 
Meghan Sutherland In Media Res Media Component
Meghan Sutherland In Media Res Media ComponentMeghan Sutherland In Media Res Media Component
Meghan Sutherland In Media Res Media Component
 
Earth Day Presentation wow hello nice great
Earth Day Presentation wow hello nice greatEarth Day Presentation wow hello nice great
Earth Day Presentation wow hello nice great
 

Linear and Bianry 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