SlideShare a Scribd company logo
1 of 2
Show that the worst-case time complexity for Binary Search is given by
when n is not restricted to being a power of 2. Hint: First show that the recurrence equation for
W(n) is given by
T(1) = 1
To do this, consider even and odd values of n separately. Then use induction to solve the
recurrence equation.
I understand how to find this with base 2 but totally lost otherwise?
Solution
Hi there,
The time to search in an array of N elements is equal to the time to search in an array of N/2
elements plus 1 comparison.
T(N) = T(N/2) + 1
Now we re-write the function in recurrence.
T(N) = T(N/2) + 1
T(N/2) = T(N/4) + 1
T(N/4) = T(N/8) + 1
……
T(4) = T(2) + 1
T(2) = T(1) + 1
Next we sum up the left and the right sides of the equations above:
T(N) + T(N/2) + T(N/4) + T(N/8) + … +T(2) = T(N/2) + T(N/4) + T(N/8) + … +T(2) + T(1) +
(1 + 1 + … + 1)
The number of 1’s on the right side is LogN
Finally, we cross the equal terms on the opposite sides and simplify the remaining sum on the
right side, we get,
T(N) = T(1) + LogN
T(N) = 1 + LogN as T(1)=1
The worst case time complexityof binary search is:
T(N) = O(LogN)

More Related Content

Similar to Show that the worst-case time complexity for Binary Search is given by.docx

CS330-Lectures Statistics And Probability
CS330-Lectures Statistics And ProbabilityCS330-Lectures Statistics And Probability
CS330-Lectures Statistics And Probabilitybryan111472
 
Jurnal informatika
Jurnal informatika Jurnal informatika
Jurnal informatika MamaMa28
 
Solving recurrences
Solving recurrencesSolving recurrences
Solving recurrencesMegha V
 
Lecture 4 (1).pptx
Lecture 4 (1).pptxLecture 4 (1).pptx
Lecture 4 (1).pptxworkwithiec
 
Copy of y16 02-2119divide-and-conquer
Copy of y16 02-2119divide-and-conquerCopy of y16 02-2119divide-and-conquer
Copy of y16 02-2119divide-and-conquerJoepang2015
 
pradeepbishtLecture13 div conq
pradeepbishtLecture13 div conqpradeepbishtLecture13 div conq
pradeepbishtLecture13 div conqPradeep Bisht
 
Admission in india 2015
Admission in india 2015Admission in india 2015
Admission in india 2015Edhole.com
 
04_Recurrences_1.ppt
04_Recurrences_1.ppt04_Recurrences_1.ppt
04_Recurrences_1.pptMouDhara1
 
Skiena algorithm 2007 lecture09 linear sorting
Skiena algorithm 2007 lecture09 linear sortingSkiena algorithm 2007 lecture09 linear sorting
Skiena algorithm 2007 lecture09 linear sortingzukun
 
Skiena algorithm 2007 lecture08 quicksort
Skiena algorithm 2007 lecture08 quicksortSkiena algorithm 2007 lecture08 quicksort
Skiena algorithm 2007 lecture08 quicksortzukun
 
5.2 divede and conquer 03
5.2 divede and conquer 035.2 divede and conquer 03
5.2 divede and conquer 03Krish_ver2
 
5.2 divede and conquer 03
5.2 divede and conquer 035.2 divede and conquer 03
5.2 divede and conquer 03Krish_ver2
 
lecture 3
lecture 3lecture 3
lecture 3sajinsc
 

Similar to Show that the worst-case time complexity for Binary Search is given by.docx (20)

CS330-Lectures Statistics And Probability
CS330-Lectures Statistics And ProbabilityCS330-Lectures Statistics And Probability
CS330-Lectures Statistics And Probability
 
Lec9
Lec9Lec9
Lec9
 
Jurnal informatika
Jurnal informatika Jurnal informatika
Jurnal informatika
 
Solving recurrences
Solving recurrencesSolving recurrences
Solving recurrences
 
Merge Sort
Merge SortMerge Sort
Merge Sort
 
Lecture 4 (1).pptx
Lecture 4 (1).pptxLecture 4 (1).pptx
Lecture 4 (1).pptx
 
Copy of y16 02-2119divide-and-conquer
Copy of y16 02-2119divide-and-conquerCopy of y16 02-2119divide-and-conquer
Copy of y16 02-2119divide-and-conquer
 
pradeepbishtLecture13 div conq
pradeepbishtLecture13 div conqpradeepbishtLecture13 div conq
pradeepbishtLecture13 div conq
 
Admission in india 2015
Admission in india 2015Admission in india 2015
Admission in india 2015
 
Time complexity
Time complexityTime complexity
Time complexity
 
Merge sort and quick sort
Merge sort and quick sortMerge sort and quick sort
Merge sort and quick sort
 
04_Recurrences_1.ppt
04_Recurrences_1.ppt04_Recurrences_1.ppt
04_Recurrences_1.ppt
 
Skiena algorithm 2007 lecture09 linear sorting
Skiena algorithm 2007 lecture09 linear sortingSkiena algorithm 2007 lecture09 linear sorting
Skiena algorithm 2007 lecture09 linear sorting
 
Skiena algorithm 2007 lecture08 quicksort
Skiena algorithm 2007 lecture08 quicksortSkiena algorithm 2007 lecture08 quicksort
Skiena algorithm 2007 lecture08 quicksort
 
searching.pdf
searching.pdfsearching.pdf
searching.pdf
 
5.2 divede and conquer 03
5.2 divede and conquer 035.2 divede and conquer 03
5.2 divede and conquer 03
 
5.2 divede and conquer 03
5.2 divede and conquer 035.2 divede and conquer 03
5.2 divede and conquer 03
 
Recurrence relation
Recurrence relationRecurrence relation
Recurrence relation
 
lecture 3
lecture 3lecture 3
lecture 3
 
Sorting
SortingSorting
Sorting
 

More from mmary455

signment-takeCovalent Activity-doPlocator-assignment take&takeAssignme.docx
signment-takeCovalent Activity-doPlocator-assignment take&takeAssignme.docxsignment-takeCovalent Activity-doPlocator-assignment take&takeAssignme.docx
signment-takeCovalent Activity-doPlocator-assignment take&takeAssignme.docxmmary455
 
Simple interest is the interest cost for one or more periods when the.docx
Simple interest is the interest cost for one or more periods when the.docxSimple interest is the interest cost for one or more periods when the.docx
Simple interest is the interest cost for one or more periods when the.docxmmary455
 
show work 10- Divide 1436 by 203- The answer expressed to the correct.docx
show work 10- Divide 1436 by 203- The answer expressed to the correct.docxshow work 10- Divide 1436 by 203- The answer expressed to the correct.docx
show work 10- Divide 1436 by 203- The answer expressed to the correct.docxmmary455
 
Show the effect of dollar appeciation and depreciation with the yen on.docx
Show the effect of dollar appeciation and depreciation with the yen on.docxShow the effect of dollar appeciation and depreciation with the yen on.docx
Show the effect of dollar appeciation and depreciation with the yen on.docxmmary455
 
Solubility products Ks(Fe(OH)2) - 4-9 x 10 ^ -17 Ks(Fe(OH)3) - 2-8 x 1.docx
Solubility products Ks(Fe(OH)2) - 4-9 x 10 ^ -17 Ks(Fe(OH)3) - 2-8 x 1.docxSolubility products Ks(Fe(OH)2) - 4-9 x 10 ^ -17 Ks(Fe(OH)3) - 2-8 x 1.docx
Solubility products Ks(Fe(OH)2) - 4-9 x 10 ^ -17 Ks(Fe(OH)3) - 2-8 x 1.docxmmary455
 
Sodium fluoride is added to many municipal water supplies to reduce to.docx
Sodium fluoride is added to many municipal water supplies to reduce to.docxSodium fluoride is added to many municipal water supplies to reduce to.docx
Sodium fluoride is added to many municipal water supplies to reduce to.docxmmary455
 
Societal Dimension of IPESolutionInternational political economy was t.docx
Societal Dimension of IPESolutionInternational political economy was t.docxSocietal Dimension of IPESolutionInternational political economy was t.docx
Societal Dimension of IPESolutionInternational political economy was t.docxmmary455
 
Soil & GW Remediation (Civil and Environmental Engineering) SolutionQn.docx
Soil & GW Remediation (Civil and Environmental Engineering) SolutionQn.docxSoil & GW Remediation (Civil and Environmental Engineering) SolutionQn.docx
Soil & GW Remediation (Civil and Environmental Engineering) SolutionQn.docxmmary455
 
Since Linux is an international operating system you can configure it.docx
Since Linux is an international operating system you can configure it.docxSince Linux is an international operating system you can configure it.docx
Since Linux is an international operating system you can configure it.docxmmary455
 
Sinking fund bands- Require the issuer to set aside assets in order r.docx
Sinking fund bands-  Require the issuer to set aside assets in order r.docxSinking fund bands-  Require the issuer to set aside assets in order r.docx
Sinking fund bands- Require the issuer to set aside assets in order r.docxmmary455
 
Simplify-Write answers in the form of a+bi where a and b are real numb.docx
Simplify-Write answers in the form of a+bi where a and b are real numb.docxSimplify-Write answers in the form of a+bi where a and b are real numb.docx
Simplify-Write answers in the form of a+bi where a and b are real numb.docxmmary455
 
Simplify- 1 + 3 x+4 1 + 9 x-2 Solutio.docx
Simplify-    1 +      3    x+4         1 +      9    x-2       Solutio.docxSimplify-    1 +      3    x+4         1 +      9    x-2       Solutio.docx
Simplify- 1 + 3 x+4 1 + 9 x-2 Solutio.docxmmary455
 
Case- The Long- Loud Silence Background As the director of health info.docx
Case- The Long- Loud Silence Background As the director of health info.docxCase- The Long- Loud Silence Background As the director of health info.docx
Case- The Long- Loud Silence Background As the director of health info.docxmmary455
 
Case 4-3 The Baptist Foundation of Arizona- The Whistleblower Hotline.docx
Case 4-3 The Baptist Foundation of Arizona- The Whistleblower Hotline.docxCase 4-3 The Baptist Foundation of Arizona- The Whistleblower Hotline.docx
Case 4-3 The Baptist Foundation of Arizona- The Whistleblower Hotline.docxmmary455
 
Case 5-1 David L- Miller- Portrait of a White-Collar Criminal There is.docx
Case 5-1 David L- Miller- Portrait of a White-Collar Criminal There is.docxCase 5-1 David L- Miller- Portrait of a White-Collar Criminal There is.docx
Case 5-1 David L- Miller- Portrait of a White-Collar Criminal There is.docxmmary455
 
Carbon steel is an active metal meaning it has low corrosion resistanc.docx
Carbon steel is an active metal meaning it has low corrosion resistanc.docxCarbon steel is an active metal meaning it has low corrosion resistanc.docx
Carbon steel is an active metal meaning it has low corrosion resistanc.docxmmary455
 
Carbon dioxide in the atmosphere traps heat from the sun and makes lif.docx
Carbon dioxide in the atmosphere traps heat from the sun and makes lif.docxCarbon dioxide in the atmosphere traps heat from the sun and makes lif.docx
Carbon dioxide in the atmosphere traps heat from the sun and makes lif.docxmmary455
 
Carnival Corporation has recently placed into service some of the larg.docx
Carnival Corporation has recently placed into service some of the larg.docxCarnival Corporation has recently placed into service some of the larg.docx
Carnival Corporation has recently placed into service some of the larg.docxmmary455
 
Canadian Income Tax Question Tiffany MacGraw- a Canadian citizen- left.docx
Canadian Income Tax Question Tiffany MacGraw- a Canadian citizen- left.docxCanadian Income Tax Question Tiffany MacGraw- a Canadian citizen- left.docx
Canadian Income Tax Question Tiffany MacGraw- a Canadian citizen- left.docxmmary455
 
Capital budgeting decisions are among the most important decisions tha.docx
Capital budgeting decisions are among the most important decisions tha.docxCapital budgeting decisions are among the most important decisions tha.docx
Capital budgeting decisions are among the most important decisions tha.docxmmary455
 

More from mmary455 (20)

signment-takeCovalent Activity-doPlocator-assignment take&takeAssignme.docx
signment-takeCovalent Activity-doPlocator-assignment take&takeAssignme.docxsignment-takeCovalent Activity-doPlocator-assignment take&takeAssignme.docx
signment-takeCovalent Activity-doPlocator-assignment take&takeAssignme.docx
 
Simple interest is the interest cost for one or more periods when the.docx
Simple interest is the interest cost for one or more periods when the.docxSimple interest is the interest cost for one or more periods when the.docx
Simple interest is the interest cost for one or more periods when the.docx
 
show work 10- Divide 1436 by 203- The answer expressed to the correct.docx
show work 10- Divide 1436 by 203- The answer expressed to the correct.docxshow work 10- Divide 1436 by 203- The answer expressed to the correct.docx
show work 10- Divide 1436 by 203- The answer expressed to the correct.docx
 
Show the effect of dollar appeciation and depreciation with the yen on.docx
Show the effect of dollar appeciation and depreciation with the yen on.docxShow the effect of dollar appeciation and depreciation with the yen on.docx
Show the effect of dollar appeciation and depreciation with the yen on.docx
 
Solubility products Ks(Fe(OH)2) - 4-9 x 10 ^ -17 Ks(Fe(OH)3) - 2-8 x 1.docx
Solubility products Ks(Fe(OH)2) - 4-9 x 10 ^ -17 Ks(Fe(OH)3) - 2-8 x 1.docxSolubility products Ks(Fe(OH)2) - 4-9 x 10 ^ -17 Ks(Fe(OH)3) - 2-8 x 1.docx
Solubility products Ks(Fe(OH)2) - 4-9 x 10 ^ -17 Ks(Fe(OH)3) - 2-8 x 1.docx
 
Sodium fluoride is added to many municipal water supplies to reduce to.docx
Sodium fluoride is added to many municipal water supplies to reduce to.docxSodium fluoride is added to many municipal water supplies to reduce to.docx
Sodium fluoride is added to many municipal water supplies to reduce to.docx
 
Societal Dimension of IPESolutionInternational political economy was t.docx
Societal Dimension of IPESolutionInternational political economy was t.docxSocietal Dimension of IPESolutionInternational political economy was t.docx
Societal Dimension of IPESolutionInternational political economy was t.docx
 
Soil & GW Remediation (Civil and Environmental Engineering) SolutionQn.docx
Soil & GW Remediation (Civil and Environmental Engineering) SolutionQn.docxSoil & GW Remediation (Civil and Environmental Engineering) SolutionQn.docx
Soil & GW Remediation (Civil and Environmental Engineering) SolutionQn.docx
 
Since Linux is an international operating system you can configure it.docx
Since Linux is an international operating system you can configure it.docxSince Linux is an international operating system you can configure it.docx
Since Linux is an international operating system you can configure it.docx
 
Sinking fund bands- Require the issuer to set aside assets in order r.docx
Sinking fund bands-  Require the issuer to set aside assets in order r.docxSinking fund bands-  Require the issuer to set aside assets in order r.docx
Sinking fund bands- Require the issuer to set aside assets in order r.docx
 
Simplify-Write answers in the form of a+bi where a and b are real numb.docx
Simplify-Write answers in the form of a+bi where a and b are real numb.docxSimplify-Write answers in the form of a+bi where a and b are real numb.docx
Simplify-Write answers in the form of a+bi where a and b are real numb.docx
 
Simplify- 1 + 3 x+4 1 + 9 x-2 Solutio.docx
Simplify-    1 +      3    x+4         1 +      9    x-2       Solutio.docxSimplify-    1 +      3    x+4         1 +      9    x-2       Solutio.docx
Simplify- 1 + 3 x+4 1 + 9 x-2 Solutio.docx
 
Case- The Long- Loud Silence Background As the director of health info.docx
Case- The Long- Loud Silence Background As the director of health info.docxCase- The Long- Loud Silence Background As the director of health info.docx
Case- The Long- Loud Silence Background As the director of health info.docx
 
Case 4-3 The Baptist Foundation of Arizona- The Whistleblower Hotline.docx
Case 4-3 The Baptist Foundation of Arizona- The Whistleblower Hotline.docxCase 4-3 The Baptist Foundation of Arizona- The Whistleblower Hotline.docx
Case 4-3 The Baptist Foundation of Arizona- The Whistleblower Hotline.docx
 
Case 5-1 David L- Miller- Portrait of a White-Collar Criminal There is.docx
Case 5-1 David L- Miller- Portrait of a White-Collar Criminal There is.docxCase 5-1 David L- Miller- Portrait of a White-Collar Criminal There is.docx
Case 5-1 David L- Miller- Portrait of a White-Collar Criminal There is.docx
 
Carbon steel is an active metal meaning it has low corrosion resistanc.docx
Carbon steel is an active metal meaning it has low corrosion resistanc.docxCarbon steel is an active metal meaning it has low corrosion resistanc.docx
Carbon steel is an active metal meaning it has low corrosion resistanc.docx
 
Carbon dioxide in the atmosphere traps heat from the sun and makes lif.docx
Carbon dioxide in the atmosphere traps heat from the sun and makes lif.docxCarbon dioxide in the atmosphere traps heat from the sun and makes lif.docx
Carbon dioxide in the atmosphere traps heat from the sun and makes lif.docx
 
Carnival Corporation has recently placed into service some of the larg.docx
Carnival Corporation has recently placed into service some of the larg.docxCarnival Corporation has recently placed into service some of the larg.docx
Carnival Corporation has recently placed into service some of the larg.docx
 
Canadian Income Tax Question Tiffany MacGraw- a Canadian citizen- left.docx
Canadian Income Tax Question Tiffany MacGraw- a Canadian citizen- left.docxCanadian Income Tax Question Tiffany MacGraw- a Canadian citizen- left.docx
Canadian Income Tax Question Tiffany MacGraw- a Canadian citizen- left.docx
 
Capital budgeting decisions are among the most important decisions tha.docx
Capital budgeting decisions are among the most important decisions tha.docxCapital budgeting decisions are among the most important decisions tha.docx
Capital budgeting decisions are among the most important decisions tha.docx
 

Recently uploaded

SOCIAL AND HISTORICAL CONTEXT - LFTVD.pptx
SOCIAL AND HISTORICAL CONTEXT - LFTVD.pptxSOCIAL AND HISTORICAL CONTEXT - LFTVD.pptx
SOCIAL AND HISTORICAL CONTEXT - LFTVD.pptxiammrhaywood
 
Painted Grey Ware.pptx, PGW Culture of India
Painted Grey Ware.pptx, PGW Culture of IndiaPainted Grey Ware.pptx, PGW Culture of India
Painted Grey Ware.pptx, PGW Culture of IndiaVirag Sontakke
 
_Math 4-Q4 Week 5.pptx Steps in Collecting Data
_Math 4-Q4 Week 5.pptx Steps in Collecting Data_Math 4-Q4 Week 5.pptx Steps in Collecting Data
_Math 4-Q4 Week 5.pptx Steps in Collecting DataJhengPantaleon
 
Kisan Call Centre - To harness potential of ICT in Agriculture by answer farm...
Kisan Call Centre - To harness potential of ICT in Agriculture by answer farm...Kisan Call Centre - To harness potential of ICT in Agriculture by answer farm...
Kisan Call Centre - To harness potential of ICT in Agriculture by answer farm...Krashi Coaching
 
“Oh GOSH! Reflecting on Hackteria's Collaborative Practices in a Global Do-It...
“Oh GOSH! Reflecting on Hackteria's Collaborative Practices in a Global Do-It...“Oh GOSH! Reflecting on Hackteria's Collaborative Practices in a Global Do-It...
“Oh GOSH! Reflecting on Hackteria's Collaborative Practices in a Global Do-It...Marc Dusseiller Dusjagr
 
Introduction to ArtificiaI Intelligence in Higher Education
Introduction to ArtificiaI Intelligence in Higher EducationIntroduction to ArtificiaI Intelligence in Higher Education
Introduction to ArtificiaI Intelligence in Higher Educationpboyjonauth
 
Crayon Activity Handout For the Crayon A
Crayon Activity Handout For the Crayon ACrayon Activity Handout For the Crayon A
Crayon Activity Handout For the Crayon AUnboundStockton
 
Pharmacognosy Flower 3. Compositae 2023.pdf
Pharmacognosy Flower 3. Compositae 2023.pdfPharmacognosy Flower 3. Compositae 2023.pdf
Pharmacognosy Flower 3. Compositae 2023.pdfMahmoud M. Sallam
 
Introduction to AI in Higher Education_draft.pptx
Introduction to AI in Higher Education_draft.pptxIntroduction to AI in Higher Education_draft.pptx
Introduction to AI in Higher Education_draft.pptxpboyjonauth
 
Software Engineering Methodologies (overview)
Software Engineering Methodologies (overview)Software Engineering Methodologies (overview)
Software Engineering Methodologies (overview)eniolaolutunde
 
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
 
Science 7 - LAND and SEA BREEZE and its Characteristics
Science 7 - LAND and SEA BREEZE and its CharacteristicsScience 7 - LAND and SEA BREEZE and its Characteristics
Science 7 - LAND and SEA BREEZE and its CharacteristicsKarinaGenton
 
Biting mechanism of poisonous snakes.pdf
Biting mechanism of poisonous snakes.pdfBiting mechanism of poisonous snakes.pdf
Biting mechanism of poisonous snakes.pdfadityarao40181
 
भारत-रोम व्यापार.pptx, Indo-Roman Trade,
भारत-रोम व्यापार.pptx, Indo-Roman Trade,भारत-रोम व्यापार.pptx, Indo-Roman Trade,
भारत-रोम व्यापार.pptx, Indo-Roman Trade,Virag Sontakke
 
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
 
Mastering the Unannounced Regulatory Inspection
Mastering the Unannounced Regulatory InspectionMastering the Unannounced Regulatory Inspection
Mastering the Unannounced Regulatory InspectionSafetyChain Software
 
18-04-UA_REPORT_MEDIALITERAСY_INDEX-DM_23-1-final-eng.pdf
18-04-UA_REPORT_MEDIALITERAСY_INDEX-DM_23-1-final-eng.pdf18-04-UA_REPORT_MEDIALITERAСY_INDEX-DM_23-1-final-eng.pdf
18-04-UA_REPORT_MEDIALITERAСY_INDEX-DM_23-1-final-eng.pdfssuser54595a
 
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
 

Recently uploaded (20)

SOCIAL AND HISTORICAL CONTEXT - LFTVD.pptx
SOCIAL AND HISTORICAL CONTEXT - LFTVD.pptxSOCIAL AND HISTORICAL CONTEXT - LFTVD.pptx
SOCIAL AND HISTORICAL CONTEXT - LFTVD.pptx
 
Painted Grey Ware.pptx, PGW Culture of India
Painted Grey Ware.pptx, PGW Culture of IndiaPainted Grey Ware.pptx, PGW Culture of India
Painted Grey Ware.pptx, PGW Culture of India
 
_Math 4-Q4 Week 5.pptx Steps in Collecting Data
_Math 4-Q4 Week 5.pptx Steps in Collecting Data_Math 4-Q4 Week 5.pptx Steps in Collecting Data
_Math 4-Q4 Week 5.pptx Steps in Collecting Data
 
Kisan Call Centre - To harness potential of ICT in Agriculture by answer farm...
Kisan Call Centre - To harness potential of ICT in Agriculture by answer farm...Kisan Call Centre - To harness potential of ICT in Agriculture by answer farm...
Kisan Call Centre - To harness potential of ICT in Agriculture by answer farm...
 
Model Call Girl in Tilak Nagar Delhi reach out to us at 🔝9953056974🔝
Model Call Girl in Tilak Nagar Delhi reach out to us at 🔝9953056974🔝Model Call Girl in Tilak Nagar Delhi reach out to us at 🔝9953056974🔝
Model Call Girl in Tilak Nagar Delhi reach out to us at 🔝9953056974🔝
 
“Oh GOSH! Reflecting on Hackteria's Collaborative Practices in a Global Do-It...
“Oh GOSH! Reflecting on Hackteria's Collaborative Practices in a Global Do-It...“Oh GOSH! Reflecting on Hackteria's Collaborative Practices in a Global Do-It...
“Oh GOSH! Reflecting on Hackteria's Collaborative Practices in a Global Do-It...
 
Introduction to ArtificiaI Intelligence in Higher Education
Introduction to ArtificiaI Intelligence in Higher EducationIntroduction to ArtificiaI Intelligence in Higher Education
Introduction to ArtificiaI Intelligence in Higher Education
 
Crayon Activity Handout For the Crayon A
Crayon Activity Handout For the Crayon ACrayon Activity Handout For the Crayon A
Crayon Activity Handout For the Crayon A
 
Staff of Color (SOC) Retention Efforts DDSD
Staff of Color (SOC) Retention Efforts DDSDStaff of Color (SOC) Retention Efforts DDSD
Staff of Color (SOC) Retention Efforts DDSD
 
Pharmacognosy Flower 3. Compositae 2023.pdf
Pharmacognosy Flower 3. Compositae 2023.pdfPharmacognosy Flower 3. Compositae 2023.pdf
Pharmacognosy Flower 3. Compositae 2023.pdf
 
Introduction to AI in Higher Education_draft.pptx
Introduction to AI in Higher Education_draft.pptxIntroduction to AI in Higher Education_draft.pptx
Introduction to AI in Higher Education_draft.pptx
 
Software Engineering Methodologies (overview)
Software Engineering Methodologies (overview)Software Engineering Methodologies (overview)
Software Engineering Methodologies (overview)
 
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
 
Science 7 - LAND and SEA BREEZE and its Characteristics
Science 7 - LAND and SEA BREEZE and its CharacteristicsScience 7 - LAND and SEA BREEZE and its Characteristics
Science 7 - LAND and SEA BREEZE and its Characteristics
 
Biting mechanism of poisonous snakes.pdf
Biting mechanism of poisonous snakes.pdfBiting mechanism of poisonous snakes.pdf
Biting mechanism of poisonous snakes.pdf
 
भारत-रोम व्यापार.pptx, Indo-Roman Trade,
भारत-रोम व्यापार.pptx, Indo-Roman Trade,भारत-रोम व्यापार.pptx, Indo-Roman Trade,
भारत-रोम व्यापार.pptx, Indo-Roman Trade,
 
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
 
Mastering the Unannounced Regulatory Inspection
Mastering the Unannounced Regulatory InspectionMastering the Unannounced Regulatory Inspection
Mastering the Unannounced Regulatory Inspection
 
18-04-UA_REPORT_MEDIALITERAСY_INDEX-DM_23-1-final-eng.pdf
18-04-UA_REPORT_MEDIALITERAСY_INDEX-DM_23-1-final-eng.pdf18-04-UA_REPORT_MEDIALITERAСY_INDEX-DM_23-1-final-eng.pdf
18-04-UA_REPORT_MEDIALITERAСY_INDEX-DM_23-1-final-eng.pdf
 
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
 

Show that the worst-case time complexity for Binary Search is given by.docx

  • 1. Show that the worst-case time complexity for Binary Search is given by when n is not restricted to being a power of 2. Hint: First show that the recurrence equation for W(n) is given by T(1) = 1 To do this, consider even and odd values of n separately. Then use induction to solve the recurrence equation. I understand how to find this with base 2 but totally lost otherwise? Solution Hi there, The time to search in an array of N elements is equal to the time to search in an array of N/2 elements plus 1 comparison. T(N) = T(N/2) + 1 Now we re-write the function in recurrence. T(N) = T(N/2) + 1 T(N/2) = T(N/4) + 1 T(N/4) = T(N/8) + 1 …… T(4) = T(2) + 1 T(2) = T(1) + 1 Next we sum up the left and the right sides of the equations above:
  • 2. T(N) + T(N/2) + T(N/4) + T(N/8) + … +T(2) = T(N/2) + T(N/4) + T(N/8) + … +T(2) + T(1) + (1 + 1 + … + 1) The number of 1’s on the right side is LogN Finally, we cross the equal terms on the opposite sides and simplify the remaining sum on the right side, we get, T(N) = T(1) + LogN T(N) = 1 + LogN as T(1)=1 The worst case time complexityof binary search is: T(N) = O(LogN)