SEARCH
You are in browse mode. You must login to use MEMORY

   Log in to start


From course:

Computer Science AQA A level

» Start this Course
(Practice similar questions for free)
Question:

Pseudo code of how to prgram binary search

Author: Will Parker



Answer:

Found ← FALSE BottomPointer ← 0 TopPointer ← ArrayofNames.Count - 1 Do Until Found = TRUE or TopPointer < BottomPointer Midpoint = int mid TopPointer, BottomPointer If ArrayofNames(Midpoint) = Target Found = TRUE ElseIf ArrayofNames(Midpoint) > Target TopPointer = Midpoint - 1 ElseIf ArrayofNames(Midpoint) < Target BottomPointer = Midpoint + 1 Loop If Found = TRUE Output "Target found at " + Midpoint Else Output Target not found


0 / 5  (0 ratings)

1 answer(s) in total