Question
What names are interrogated by the binary search whensearching for the name Joe in the list Alice, Brenda,Carol, Duane,Evelyn, Fred, George, Henry, Irene, Joe, Karl, Larry, Mary, Nancy,and Oliver? give explanation of the steps to be taken What names are interrogated by the binary search whensearching for the name Joe in the list Alice, Brenda,Carol, Duane,Evelyn, Fred, George, Henry, Irene, Joe, Karl, Larry, Mary, Nancy,and Oliver? give explanation of the steps to be taken
Explanation / Answer
Alice, Brenda,Carol, Duane, Evelyn, Fred, George, Henry,Irene, Joe, Karl, Larry, Mary, Nancy, Oliver There are 15 names....so binary search will compare joe with 8thone (the middle one) 1) Henry will be compared withJoe As joe is greater than Henry... next binary search will be done on Henry, Irene, Joe, Karl,Larry, Mary, Nancy, Oliver 2) now there are 8 names ..and now the fourth one will be comparedwith joe therefore Karl will be compared with joe as Karl > Joe the next binary search will be done on Henry, Irene,Joe, Karl 3) now there are only 4 elements ..and the middle one (end one) isIrene so Irene will be compared with Joe as Irene