Professional Documents
Culture Documents
Binary Search Algorithm For BCA
Binary Search Algorithm For BCA
Binary Search Algorithm For BCA
End If
If (i >= no) Then
MsgBox("array full")
End If
TextBox2.Clear()
TextBox2.Focus()
End Sub
Private Sub Button2_Click(ByVal sender As System.Object, ByVal e As
System.EventArgs) Handles Button2.Click
Dim lb, ub, mid, no, x As Integer
x = 0
no = Val(TextBox1.Text)
n = Val(TextBox3.Text)
lb = 0
ub = no - 1
While (lb <= ub)
mid = (lb + ub) \ 2
If (a(mid) = n) Then
MsgBox(" Number is present in the list")
x = x + 1
Exit While
End If
lb = mid + 1
End If
ub = mid - 1
End If
End While
If (x = 0) Then
MsgBox(" Number is not present in the list")
End If
End Sub
End Sub
End Sub
End Class