Im looking over the practice exam our professor put up, and Im having a hard time understanding one of the problems. It goes like this:
Given the following array of character strings,
In a binary search (where the list is sorted), how many comparisons would be required to determine that the string "Delta" is not in the list? List the strings that would be compared to "Delta" in a standard binary search in the order that the comparisons would be made.Code:char *list[7]={ "Alpha", "Bravo", "Charlie", "Echo", "Foxtrot", "Golf", "Hotel"};
The answer he gives is this:
1.) Echo (element 3)
2.) Bravo (element 1)
3.) Charlie (element 2)
Im having a hard time understanding how he came up with that, can anyone explain it to me?