An array similar to a phone book has 1000 names arranged as names [0], names[1]....names[999]. Nancy wants to search a name X in
this array. Which of the following preconditions must she ensure to perform a binary search? a. The list has a large number of names.
b. The name X is present in the list.
In addition to the two statements above, which of the following is correct?
a. There should be no duplicates in the list.
b. The names in the list should be alphabetical order.
c. The name X should occur near the middle of the list.
b. The names in the list should be in alphabetical order.
Explanation:
A binary search is an algorithm used for searching for an item in a list or array. The algorithm first sorts the data structure into order and then divides it into halves. If the searched item is less than the middle item in the list, then the algorithm searches for the target in the first half, else, in the second half. This reduces the time complexity of the search.
The answer is d. full-duplex transmission. This communication setup allows for simultaneous transmit and receive for both parties. As signals are able to be transmitted at the same time two way for both parties, for both directions along the same data carrier medium.
Here scanf is represented by stdin and we are using that scanner object to read the string value from user.The value which we read are printed in a new line using printf .The format specifier %s in printf is replaced by name variable