diff --git a/Binary Search.java b/Binary Search.java index a108de7e87f8..25814197fd23 100644 --- a/Binary Search.java +++ b/Binary Search.java @@ -1,10 +1,23 @@ import java.util.Scanner; +/** + * Implements a Binary Search in Java + * + * @author unknown + */ class BinarySearch { + /** + * This method implements the Binary Search + * + * @param array The array to make the binary search + * @param key The number you are looking for + * @param lb The lower bound + * @param up The upper bound + * @return the location of the key + **/ public static int BS(int array[], int key, int lb, int ub) - { - if (lb>ub) + { if (lb>ub) { return -1; } @@ -25,6 +38,14 @@ else if (key>array[mid]) } } + + /** + * This is the main method of Binary Search + * + * @author Unknown + * @param args Command line parameters + */ + public static void main(String[] args) { Scanner input=new Scanner(System.in); @@ -50,4 +71,4 @@ public static void main(String[] args) System.out.println("Not found"); } } -} \ No newline at end of file +} pFad - Phonifier reborn

Pfad - The Proxy pFad of © 2024 Garber Painting. All rights reserved.

Note: This service is not intended for secure transactions such as banking, social media, email, or purchasing. Use at your own risk. We assume no liability whatsoever for broken pages.


Alternative Proxies:

Alternative Proxy

pFad Proxy

pFad v3 Proxy

pFad v4 Proxy