The document describes how binary search works to find a value in a sorted array. It provides an example of searching for the value 5 in an array of numbers, which is found after 2 comparisons by repeatedly dividing the search range in half. A second example searches for the value 20, which is not found in the array after 3 comparisons as each mid-point value is less than 20, narrowing the range until it is empty.
Copyright:
Attribution Non-Commercial (BY-NC)
Available Formats
Download as DOC, PDF, TXT or read online from Scribd
The document describes how binary search works to find a value in a sorted array. It provides an example of searching for the value 5 in an array of numbers, which is found after 2 comparisons by repeatedly dividing the search range in half. A second example searches for the value 20, which is not found in the array after 3 comparisons as each mid-point value is less than 20, narrowing the range until it is empty.
The document describes how binary search works to find a value in a sorted array. It provides an example of searching for the value 5 in an array of numbers, which is found after 2 comparisons by repeatedly dividing the search range in half. A second example searches for the value 20, which is not found in the array after 3 comparisons as each mid-point value is less than 20, narrowing the range until it is empty.
Copyright:
Attribution Non-Commercial (BY-NC)
Available Formats
Download as DOC, PDF, TXT or read online from Scribd
The document describes how binary search works to find a value in a sorted array. It provides an example of searching for the value 5 in an array of numbers, which is found after 2 comparisons by repeatedly dividing the search range in half. A second example searches for the value 20, which is not found in the array after 3 comparisons as each mid-point value is less than 20, narrowing the range until it is empty.
Copyright:
Attribution Non-Commercial (BY-NC)
Available Formats
Download as DOC, PDF, TXT or read online from Scribd