Meta tags:
Headings (most frequently used words):
view, source, for, binary, search,
Text of the page (most frequently used words):
math (96), the (43), #search (19), and (16), this (14), binary (9), you (9), for (8), set (8), view (7), code (7), return (7), floor (7), wikipedia (6), procedure (6), ceiling (6), leq (5), algorithm (5), unsuccessful (5), frac (5), a_m (5), while (5), blocked (5), edit (5), source (4), that (4), element (4), done (4), function (4), then (4), else (4), iteration (4), pages (4), page (4), have (4), add (3), target (3), value (3), following (3), sfn (3), knuth (3), 1998 (3), loc (3), searching (3), ordered (3), table (3), subsection (3), middle (3), functions (3), than (3), equal (3), may (3), file (3), check (3), one (3), ref (3), journal (3), history (3), can (3), other (3), information (3), not (3), been (3), block (3), globally (3), address (3), read (3), hide (3), move (3), sidebar (3), tools (3), main (3), languages (2), contact (2), about (2), from (2), wiki (2), binary_search (2), array (2), with (2), a_0 (2), a_1 (2), a_2 (2), find (2), terminates (2), position (2), plus (2), which (2), integer (2), step (2), now (2), pseudocode (2), where (2), above (2), specific (2), more (2), some (2), leave (2), out (2), only (2), when (2), comparison (2), name (2), bottenbruch1962 (2), bottenbruch (2), hermann (2), 1962 (2), doi (2), ceil (2), blocks (2), editing (2), recent (2), abuse (2), affect (2), who (2), are (2), believe (2), wrong (2), links (2), help (2), will (2), your (2), current (2), 135 (2), range (2), has (2), reason (2), appearance (2), upload (2), changes (2), article (2), log (2), create (2), account (2), donate (2), menu (2), topic, mobile, cookie, statement, statistics, developers, conduct, legal, safety, contacts, disclaimers, privacy, policy, retrieved, https, org, given, elements, values, record, computer, science, records, ldots, sorted, such, cdots, subroutine, uses, index, greatest, less, iterative, keeps, track, boundaries, two, variables, expressed, follows, variable, names, types, remain, same, refers, conveys, failure, work, gif, thumb, right, alternatively, take, change, result, appears, once, alternative, checks, whether, every, implementations, during, each, would, perform, left, results, faster, loop, eliminated, per, requires, average, cite, last1, first1, s2cid, 13406983, title, structure, use, algol, acm, date, april, volume, issue, 161, 221, issn, 0004, 5411, 1145, 321119, 321120, access, free, described, 214, titled, program, published, first, implementation, bibliography, neq, least, greater, a_l, otherwise, version, binary_search_alternative, copy, kinds, restrict, service, providers, telecom, companies, response, vandalism, sometimes, users, unrelated, review, below, assistance, anything, useful, global, were, mistake, additional, instructions, stewards, wizard, even, still, able, meta, usually, expire, january, 2027, 194, visit, affected, faq, open, proxy, webhost, jon, kolbert, affects, all, wikimedia, wikis, most, people, see, message, nothing, does, ability, permission, wikidata, item, projects, switch, legacy, parser, get, shortened, url, related, what, here, general, actions, english, talk, personal, special, community, portal, learn, contribute, random, events, contents, navigation, jump, content,
Text of the page (random words):
view source for binary search wikipedia jump to content main menu main menu move to sidebar hide navigation main page contents current events random article about wikipedia contact us contribute help learn to edit community portal recent changes upload file special pages search search appearance donate create account log in personal tools donate create account log in view source for binary search add languages article talk english read edit view history tools tools move to sidebar hide actions read edit view history general what links here related changes upload file page information get shortened url switch to legacy parser in other projects wikidata item appearance move to sidebar hide binary search you do not have permission to edit this page for the following reason this ip address range has been globally blocked this does not affect your ability to read wikipedia pages most people who see this message have done nothing wrong some kinds of blocks restrict editing from specific service providers or telecom companies in response to recent abuse or vandalism and can sometimes affect other users who are unrelated to that abuse review the information below for assistance if you do not believe that you have done anything wrong this block affects editing on all wikimedia wikis the ip address or range 5 135 0 0 16 has been globally blocked by jon kolbert for the following reason s open proxy webhost visit the faq if you are affected this block will expire on 04 29 8 january 2027 your current ip address is 5 135 42 194 even while globally blocked you will usually still be able to edit pages on meta wiki if you believe you were blocked by mistake you can find additional information and instructions in the stewards block wizard other useful links global blocks help i have been blocked you can view and copy the source of this page procedure given an array math a math of math n math elements with values or record computer science records math a_0 a_1 a_2 ldots a_ n 1 math sorted such that math a_0 leq a_1 leq a_2 leq cdots leq a_ n 1 math and target value math t math the following subroutine uses binary search to find the index of math t math in math a math sfn knuth 1998 loc 6 2 1 searching an ordered table subsection algorithm b set math l math to math 0 math and math r math to math n 1 math if math l r math the search terminates as unsuccessful set math m math the position of the middle element to math l math plus the floor and ceiling functions floor of math frac r l 2 math which is the greatest integer less than or equal to math frac r l 2 math if math a_m t math set math l math to math m 1 math and go to step 2 if math a_m t math set math r math to math m 1 math and go to step 2 now math a_m t math the search is done return math m math this iterative procedure keeps track of the search boundaries with the two variables math l math and math r math the procedure may be expressed in pseudocode as follows where the variable names and types remain the same as above code floor code is the floor function and code unsuccessful code refers to a specific value that conveys the failure of the search sfn knuth 1998 loc 6 2 1 searching an ordered table subsection algorithm b file binary search work gif thumb right binary search function binary_search a n t is l 0 r n 1 while l r do m l floor r l 2 if a m t then l m 1 else if a m t then r m 1 else return m return unsuccessful alternatively the algorithm may take the floor and ceiling functions ceiling of math frac r l 2 math this may change the result if the target value appears more than once in the array alternative procedure in the above procedure the algorithm checks whether the middle element math m math is equal to the target math t math in every iteration some implementations leave out this check during each iteration the algorithm would perform this check only when one element is left when math l r math this results in a faster comparison loop as one comparison is eliminated per iteration while it requires only one more iteration on average ref name bottenbruch1962 cite journal last1 bottenbruch first1 hermann s2cid 13406983 title structure and use of algol 60 journal journal of the acm date 1 april 1962 volume 9 issue 2 pages 161 221 issn 0004 5411 doi 10 1145 321119 321120 doi access free procedure is described at p 214 43 titled program for binary search ref hermann bottenbruch published the first implementation to leave out this check in 1962 ref name bottenbruch1962 sfn knuth 1998 loc 6 2 1 searching an ordered table subsection history and bibliography set math l math to math 0 math and math r math to math n 1 math while math l neq r math set math m math the position of the middle element to math l math plus the floor and ceiling functions ceiling of math frac r l 2 math which is the least integer greater than or equal to math frac r l 2 math if math a_m t math set math r math to math m 1 math else math a_m leq t math set math l math to math m math now math l r math the search is done if math a_l t math return math l math otherwise the search terminates as unsuccessful where code ceil code is the ceiling function the pseudocode for this version is function binary_search_alternative a n t is l 0 r n 1 while l r do m l ceil r l 2 if a m t then r m 1 else l m if a l t then return l return unsuccessful return to binary search retrieved from https en wikipedia org wiki binary_search privacy policy about wikipedia disclaimers contact wikipedia legal safety contacts code of conduct developers statistics cookie statement mobile view search search view source for binary search add languages add topic
|