Questions   
Sort: 
 #1
avatar-2 
0
Oct 26, 2016
 #1
avatar
0
Oct 26, 2016
 #6
avatar+118659 
+5
Oct 26, 2016
 #5
avatar+26388 
+10

You mean that there is a maximum of 8 steps if the element exists in the array,

but 9 steps if the element does not exist?

 

Hello Melody!

 

YES!

 

\(\begin{array}{|lrcll|} \hline & \text{We search number 1:} & & \text{set } \{1,\dots,193 \}\\\\ (1) & 1 > \lfloor \frac{1+193}{2} \rfloor = 97 & no & \text{new set } \{1,\dots,97 \}\\ (2) & 1 > \lfloor \frac{1+97}{2} \rfloor = 49 & no & \text{new set } \{1,\dots,49 \}\\ (3) & 1 > \lfloor \frac{1+49}{2} \rfloor = 25 & no & \text{new set } \{1,\dots,25 \}\\ (4) & 1 > \lfloor \frac{1+25}{2} \rfloor = 13 & no & \text{new set } \{1,\dots,13 \}\\ (5) & 1 > \lfloor \frac{1+13}{2} \rfloor = 7 & no & \text{new set } \{1,\dots,7 \}\\ (6) & 1 > \lfloor \frac{1+7}{2} \rfloor = 4 & no & \text{new set } \{1,\dots,4 \}\\ (7) & 1 > \lfloor \frac{1+4}{2} \rfloor = 2 & no & \text{new set } \{1,2 \}\\ (8) & 1 > \lfloor \frac{1+2}{2} \rfloor = 1 & no & \text{we have found number 1 in the last set}\\ \hline \end{array} \\ \begin{array}{|lrcll|} \hline & \text{We search number 1.5:} & & \text{set } \{1,\dots,193 \}\\\\ (1) & 1.5 > \lfloor \frac{1+193}{2} \rfloor = 97 & no & \text{new set } \{1,\dots,97 \}\\ (2) & 1.5 > \lfloor \frac{1+97}{2} \rfloor = 49 & no & \text{new set } \{1,\dots,49 \}\\ (3) & 1.5 > \lfloor \frac{1+49}{2} \rfloor = 25 & no & \text{new set } \{1,\dots,25 \}\\ (4) & 1.5 > \lfloor \frac{1+25}{2} \rfloor = 13 & no & \text{new set } \{1,\dots,13 \}\\ (5) & 1.5 > \lfloor \frac{1+13}{2} \rfloor = 7 & no & \text{new set } \{1,\dots,7 \}\\ (6) & 1.5 > \lfloor \frac{1+7}{2} \rfloor = 4 & no & \text{new set } \{1,\dots,4 \}\\ (7) & 1.5 > \lfloor \frac{1+4}{2} \rfloor = 2 & no & \text{new set } \{1,2 \}\\ (8) & 1.5 > \lfloor \frac{1+2}{2} \rfloor = 1 & yes & \text{new set } \{ 2 \}\\ (9) & 1.5 = 2 & no & \text{we have not found number 1.5 in the last set}\\ \hline \hline \end{array}\)

 

laugh

Oct 26, 2016
 #2
avatar
0
Oct 26, 2016
 #1
avatar
0
Oct 26, 2016

1 Online Users

avatar