Skip to content

Commit

Permalink
In this commit I have:
Browse files Browse the repository at this point in the history
Added JavaDoc to every package except for "heaps"
  • Loading branch information
zacharyjones123 committed Apr 18, 2017
1 parent 94871b7 commit 9411d5b
Show file tree
Hide file tree
Showing 29 changed files with 1,408 additions and 427 deletions.
7 changes: 7 additions & 0 deletions .classpath
Original file line number Diff line number Diff line change
@@ -0,0 +1,7 @@
<?xml version="1.0" encoding="UTF-8"?>
<classpath>
<classpathentry excluding="data_structures/" kind="src" path=""/>
<classpathentry kind="src" path="data_structures"/>
<classpathentry kind="con" path="org.eclipse.jdt.launching.JRE_CONTAINER"/>
<classpathentry kind="output" path="bin"/>
</classpath>
1 change: 1 addition & 0 deletions .gitignore
Original file line number Diff line number Diff line change
@@ -0,0 +1 @@
/bin/
17 changes: 17 additions & 0 deletions .project
Original file line number Diff line number Diff line change
@@ -0,0 +1,17 @@
<?xml version="1.0" encoding="UTF-8"?>
<projectDescription>
<name>Java</name>
<comment></comment>
<projects>
</projects>
<buildSpec>
<buildCommand>
<name>org.eclipse.jdt.core.javabuilder</name>
<arguments>
</arguments>
</buildCommand>
</buildSpec>
<natures>
<nature>org.eclipse.jdt.core.javanature</nature>
</natures>
</projectDescription>
74 changes: 74 additions & 0 deletions BinarySearch.java
Original file line number Diff line number Diff line change
@@ -0,0 +1,74 @@
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)
{
return -1;
}

int mid=(lb+ub)/2;

if (key<array[mid])
{
return (BS(array, key, lb, mid-1));
}
else if (key>array[mid])
{
return (BS(array, key, mid+1, ub));
}
else
{
return 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);
int array[]=new int[10] ;
int key;

//Input
System.out.println("Enter an array of 10 numbers : ");
for (int i=0; i<10 ;i++ )
{
array[i]=input.nextInt();
}
System.out.println("Enter the number to be searched : ");
key=input.nextInt();

int index=BS(array, key, 0, 9);
if (index!=-1)
{
System.out.println("Number found at index number : " + index);
}
else
{
System.out.println("Not found");
}
}
}
32 changes: 32 additions & 0 deletions BinaryToDecimal.java
Original file line number Diff line number Diff line change
@@ -0,0 +1,32 @@
import java.util.Scanner;

/**
* This class converts a Binary number to a Decimal number
*
* @author Unknown
*
*/
class BinaryToDecimal
{

/**
* Main Method
*
* @param args Command line arguments
*/
public static void main(String args[])
{
Scanner sc=new Scanner(System.in);
int n,k,d,s=0,c=0;
n=sc.nextInt();
k=n;
while(k!=0)
{
d=k%10;
s+=d*(int)Math.pow(2,c++);
k/=10;
}
System.out.println("Binary number:"+n);
System.out.println("Decimal equivalent:"+s);
}
}
50 changes: 50 additions & 0 deletions BubbleSort.java
Original file line number Diff line number Diff line change
@@ -0,0 +1,50 @@
import java.util.Scanner;

/**
* This class implements BubbleSort
*
* @author Unknown
*
*/

class BubbleSort
{
/**
* Main Method
*
* @param args Command line arguments
*/
public static void main(String[] args)
{
int array[]=new int[6];
Scanner input=new Scanner(System.in);

//Input
System.out.println("Enter any 6 Numbers for Unsorted Array : ");
for(int i=0; i<6; i++)
{
array[i]=input.nextInt();
}

//Sorting
for(int i=0; i<5; i++)
{
for(int j=i+1; j<6; j++)
{
if(array[j]>array[i])
{
int temp=array[j];
array[j]=array[i];
array[i]=temp;
}
}
}

//Output
for(int i=0; i<6; i++)
{
System.out.print(array[i]+"\t");
}

}
}
31 changes: 31 additions & 0 deletions DecimalToBinary.java
Original file line number Diff line number Diff line change
@@ -0,0 +1,31 @@
import java.util.Scanner;

/**
* This class converts a Decimal number to a Binary number
*
* @author Unknown
*
*/
class DecimalToBinary
{
/**
* Main Method
*
* @param args Command Line Arguments
*/
public static void main(String args[])
{
Scanner sc=new Scanner(System.in);
int n,k,s=0,c=0,d;
n=sc.nextInt();
k=n;
while(k!=0)
{
d=k%2;
s=s+d*(int)Math.pow(10,c++);
k/=2;
}//converting decimal to binary
System.out.println("Decimal number:"+n);
System.out.println("Binary equivalent:"+s);
}
}
31 changes: 31 additions & 0 deletions DecimalToOctal.java
Original file line number Diff line number Diff line change
@@ -0,0 +1,31 @@
import java.util.Scanner;

/**
* This class converts Decimal numbers to Octal Numbers
*
* @author Unknown
*
*/
class Decimal_Octal
{
/**
* Main Method
*
* @param args Command line Arguments
*/
public static void main(String[] args)
{
Scanner sc=new Scanner(System.in);
int n,k,d,s=0,c=0;
n=sc.nextInt();
k=n;
while(k!=0)
{
d=k%8;
s+=d*(int)Math.pow(10,c++);
k/=8;
}
System.out.println("Decimal number:"+n);
System.out.println("Octal equivalent:"+s);
}
}
19 changes: 18 additions & 1 deletion Factorial.java
Original file line number Diff line number Diff line change
@@ -1,7 +1,19 @@
import java.util.Scanner;

/**
* This program will print out the factorial of any non-negative
* number that you input into it.
*
* @author Unknown
*
*/
public class Factorial{

/**
* The main method
*
* @param args Command line arguments
*/
public static void main(String[] args){
Scanner input = new Scanner(System.in);
//Prompt user to enter integer
Expand All @@ -20,7 +32,12 @@ public static void main(String[] args){
}
}

//Factorial method
/**
* Recursive Factorial Method
*
* @param n The number to factorial
* @return The factorial of the number
*/
public static long factorial(int n){

if (n==0){
Expand Down
21 changes: 18 additions & 3 deletions FindingPrimes.java
Original file line number Diff line number Diff line change
@@ -1,12 +1,27 @@
/*
* The Sieve of Eratosthenes is an algorithm used to find prime numbers, up to a given value.
/**
* The Sieve of Eratosthenes is an algorithm use to find prime numbers,
* up to a given value.
* Illustration: https://upload.wikimedia.org/wikipedia/commons/b/b9/Sieve_of_Eratosthenes_animation.gif
*/
* (This illustration is also in the github repository)
*
* @author Unknown
*
*/
public class FindingPrimes{
/**
* The Main method
*
* @param args Command line arguments
*/
public static void main(String args[]){
SOE(20); //Example: Finds all the primes up to 20
}

/**
* The method implementing the Sieve of Eratosthenes
*
* @param n Number to perform SOE on
*/
public static void SOE(int n){
boolean sieve[] = new boolean[n];

Expand Down
Loading

0 comments on commit 9411d5b

Please sign in to comment.