Skip to content

Commit 5105464

Browse files
Merge pull request #24 from zacharyjones123/master
Added JavaDoc to BinarySearch.java
2 parents 86aae08 + 94871b7 commit 5105464

File tree

1 file changed

+24
-3
lines changed

1 file changed

+24
-3
lines changed

Binary Search.java

Lines changed: 24 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -1,10 +1,23 @@
11
import java.util.Scanner;
22

3+
/**
4+
* Implements a Binary Search in Java
5+
*
6+
* @author unknown
7+
*/
38
class BinarySearch
49
{
10+
/**
11+
* This method implements the Binary Search
12+
*
13+
* @param array The array to make the binary search
14+
* @param key The number you are looking for
15+
* @param lb The lower bound
16+
* @param up The upper bound
17+
* @return the location of the key
18+
**/
519
public static int BS(int array[], int key, int lb, int ub)
6-
{
7-
if (lb>ub)
20+
{ if (lb>ub)
821
{
922
return -1;
1023
}
@@ -25,6 +38,14 @@ else if (key>array[mid])
2538
}
2639
}
2740

41+
42+
/**
43+
* This is the main method of Binary Search
44+
*
45+
* @author Unknown
46+
* @param args Command line parameters
47+
*/
48+
2849
public static void main(String[] args)
2950
{
3051
Scanner input=new Scanner(System.in);
@@ -50,4 +71,4 @@ public static void main(String[] args)
5071
System.out.println("Not found");
5172
}
5273
}
53-
}
74+
}

0 commit comments

Comments
 (0)