In my previous post we have implemented binary search using iterative approach. In this post. By Programming Tutorial. Unknown November 16, at PM. Anonymous February 2, at PM. Anonymous April 3, at PM. Unknown May 4, at PM. Unknown March 15, at PM. Programming Tutorial March 30, at AM. We basically ignore half of the elements just after one comparison.
WriteLine "Element not present" ; else Console. Idea: Every number can be represented as a sum of the powers of the number 2. Initialize an index as 0. Loop while the computed power is greater than 0 and each time divide it by 2. If so the target element is present in the array, else not.
Skip to content. Change Language. Related Articles. Table of Contents. Improve Article. Save Article. Like Article. Java Programming. Java Tutorial. The Set Interface in Java. Please enter your comment! Please enter your name here. You have entered an incorrect email address! Popular Categories.
0コメント