From the binary search algorithm, it follows that every iteration of the while loop cuts the size of the search list by half.
1 answer:
Answer:
True: In binary search algorithm, we follow the below steps sequentially:
Input: A sorted array B[1,2,...n] of n items and one item x to be searched.
Output: The index of x in B if exists in B, 0 otherwise.
- low=1
- high=n
- while( low < high )
- { mid=low + (high-low)/2
- if( B[mid]==x)
- {
- return(mid) //returns mid as the index of x
- }
- else
- {
- if( B[mid] < x) //takes only right half of the array
- {
- low=mid+1
- }
- else // takes only the left half of the array
- {
- high=mid-1
- }
- }
- }
- return( 0 )
Explanation:
For each iteration the line number 11 or line number 15 will be executed.
Both lines, cut the array size to half of it and takes as the input for next iteration.
You might be interested in
Answer:
TYSM!!!
Explanation:
✧・゚: *✧・゚:* *:・゚✧*:・゚✧
Hello!
✧・゚: *✧・゚:* *:・゚✧*:・゚✧
❖ The correct answer choice is B) sorting. When you sort, you can order your sheet however you'd like.
~ ʜᴏᴘᴇ ᴛʜɪꜱ ʜᴇʟᴘꜱ! :) ♡
~ ᴄʟᴏᴜᴛᴀɴꜱᴡᴇʀꜱ
Answer:
I first saw the Polaroid SX-70—the one-step instant camera introduced in 1972 by the company's co-founder, Dr.
Explanation:
Explanation:
noooooooooooooooooooooooooooooooooo
paypel is the most popular