Binary search - Wikipedia
In computer science, binary search, also known as half-interval search,[1] logarithmic search,[2] or binary chop,[3] is a search algorithm that finds the position of a target value within a sorted array.[4][5] Binary search compares the target value to the middle element of the array. If they are not equal, the half in which the target cannot lie is eliminated and the search continues on the remaining half, again taking the middle element to compare to the target value, and repeating this until the target value is found. If the search ends with the remaining half being empty, the target is not in the array. Binary search runs in logarithmic time in the worst case, making 𝑂 ( log 𝑛 ) comparisons, where 𝑛 is the number of elements in the array.[a][6] Binary search is faster than linear search except for small arrays. However, the array must be sorted first to be able to apply binary search. There are specialized data structures designed for fast searching, such as hash tables, t
Binary search - Wikipedia Jump to content From Wikipedia, the free encyclopedia Search algorithm finding the position of a target value within a sorted array This article is about searching a finite sorted array. For searching continuous function values, see bisection method . Binary search Visualization of the binary search algorithm where 7 is the target value Class Search algorithm Data structure Array Worst-case performance O (log n ) Best-case performance O (1) Average performance O (log n ) Worst-case space complexity O (1) Optimal Yes In computer science , binary search , also known as
Explore this link on the map →related reading
- Static search trees: 40x faster than binary search · CuriousCodingcuriouscoding.nl
- Beautiful Branchless Binary Search | Probably Danceprobablydance.com
- Static B-Trees - Algorithmicaen.algorithmica.org
- Ternary search tree - Wikipediaen.wikipedia.org
- Role Of Algorithmsmatklad.github.io
- Visualizing Algorithmsbost.ocks.org
- Competitive Programmer's Handbookcses.fi
- John Graham-Cumming's blog: Steve Ballmer's incorrect binary search interview questionblog.jgc.org
- Fenwick tree - Wikipediaen.wikipedia.org
- Introduction of B Tree - GeeksforGeeksgeeksforgeeks.org
- Breadth-first search - Wikipediaen.wikipedia.org
- 2020 年秋季 進階電腦系統理論與實作課程作業 —— dict - HackMDhackmd.io