Terdapat data dari 1 sampai 1000. Cari dan Temukan data ke- 212!
Diket :
l = 1 ; u = 1000
Jawab :
○m = (l + u) : 2
= (1 + 1000) : 2
= 1001 : 2
=
500,5
m = data ke-500
(1) x < m
u = m - 1
= 500 - 1
= 499
○m = (l + u) : 2
= (1 + 499) : 2
= 250
(2) x < m
u = m - 1
= 250 - 1
=249
m = (l + u) : 2
= (1 + 249) : 2
= 125
(3) x > m
l = m + 1
= 125 + 1
= 126
m = (l + u ) : 2
= (126 + 249) : 2
=187,5
m = data 187
(4) x > m
l = m + 1
= 187 + 1
= 188
m = (l + u) : 2
= (188 + 249) : 2
=
218,5
m = data ke- 218
(5) x < m
u = m -1
= 218 - 1
= 217
m = (l + u) : 2
= (188 + 217) : 2
=202,5
m = data ke-202
(6) x > m
l = m + 1
= 202 + 1
= 203
m = (l + u) : 2
= (203 + 217) : 2
= 210
(7) x > m
l = m + 1
= 210 + 1
= 211
m = (l + u) : 2
= (211 + 217) : 2
= 214
(8) x < m
u = m - 1
=214 - 1
=213
m = (l + u) : 2
= (211 + 213) : 2
= 212
(9) x = m
212 = 212
Tidak ada komentar:
Posting Komentar