Q: Write the Algorithm of Binary Search using binary search tree. Explain with example .
It is using the divide and conquer searching technique in which we have to arrange the data in the particular format before the searching operation. After that we find the middle element of the array and then compare with the target element.
If item not found, then we again check the target element. If it is greater than or less than the middle element then we followed the following operations. If it is greater than the middle element then we searching in the right side of the middle element and if it is less than the middle element then we will search into the left side of the middle element.
Algorithm:
"\\{ Set \\ l_r\\leftarrow mid+1"
"else"
"Set \\ u_p\\leftarrow mid-1"
9 ."If \\ f=1 \\ then"
"print(searching \\ item \\ found, \\ location =mid)"
"else"
"pinrt(element\\ not \\ found)"
Comments
Leave a comment