2. IF (ArU = DATA) THEN
Begin
Write “Successful search”
W rite DATA, “found at position”, I goto step 5
End
ELSE
Begin
I < - 1 + 1
End
3. W rite “Unsuccessfulsearch”
4. END.
A L G O R IT M : Ik k ilik q id iru v .
Berilgan N elementdan
tashkil topgan massiv A,
elementlari
o ‘sish tartibida tartiblangan. Ushbu algoritm
massiv elementlarim
ichidan
eng katta, eng kichkina va o ‘rta
qiymatini berilgan
intervalda izlash uchun xizm at qiladi. I massiv indeksi.
LOW <- 1 HIGH <- N
1. W hile (LOW < HIGH) DO upto step 4
2. M ID <- Integral part o f ((LOW + HIGH)/2)
3. IF (DATA = AfMID 1)THEN
Begin
W rite “Successfulsearch”
W rite DATA, “found at position”, М Ш goto step 6
End
ELSE
Begin
IF (DATA > AfM IDl) THEN LOW <- M ID + 1
ELSE
HIGH < - M I D - 1
End
4. W rite “Unsuccessfulsearch”
5. END.
280
ALGORITM: 0 ‘sish bo‘vicha tartiblash algoritmi tuzilsin.
Berilgan N elementdan tashkil topgan massiv A. Ushbu
algoritm massiv elementlarmi o'sish bo‘yicha
tartiblash uchun
xizm at qiladi. I massiv indeksi.
1. Repeatfor
1
=
1,
2,......,
N-l
Begin
Repeat for J = I + 1 ,1 + 2 ,, N
Begin
IF (A flK A fll) THEN Begin
TEM P <- A fllAflK - AfJIAfJK- TEMP
End
End
End
2. END.
Dostları ilə paylaş: