diff --git a/Binary Search.java b/Binary Search.java deleted file mode 100644 index 25814197f..000000000 --- a/Binary Search.java +++ /dev/null @@ -1,74 +0,0 @@ -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 (keyarray[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"); - } - } -} diff --git a/Binary to Decimal.java b/Binary to Decimal.java deleted file mode 100644 index b61c9f1c5..000000000 --- a/Binary to Decimal.java +++ /dev/null @@ -1,19 +0,0 @@ -#import java.util.*; -class Binary_Decimal -{ - 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); - } -} diff --git a/Bubble Sort.java b/Bubble Sort.java deleted file mode 100644 index a374d9ff7..000000000 --- a/Bubble Sort.java +++ /dev/null @@ -1,38 +0,0 @@ -import java.util.Scanner; - -class BubbleSort -{ - 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"); - } - - } -} diff --git a/Decimal to Binary.java b/Decimal to Binary.java deleted file mode 100644 index e89b65fad..000000000 --- a/Decimal to Binary.java +++ /dev/null @@ -1,19 +0,0 @@ -#import java.util.*; -class Decimal_Binary -{ - 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); - } -} diff --git a/Decimal to octal.java b/Decimal to octal.java deleted file mode 100644 index 11a8a563f..000000000 --- a/Decimal to octal.java +++ /dev/null @@ -1,19 +0,0 @@ -#import java.util.*; -class Decimal_Octal -{ - public static void main() - { - 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); - } -} diff --git a/Insertion Sort.java b/Insertion Sort.java deleted file mode 100644 index 179030919..000000000 --- a/Insertion Sort.java +++ /dev/null @@ -1,38 +0,0 @@ -import java.util.Scanner; - -class InsertionSort -{ - 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<6; i++) - { - int temp=array[i]; - int j=i-1; - while(j>=0 && temp 0; lastSortedIndex--){ - - //If our extracted element is smaller than element to the right, switch them. - if (sortedArray[lastSortedIndex-1] > extractedElement){ - //move the element to the left of extractedElement to the right in sortedArray - sortedArray[lastSortedIndex] = sortedArray[lastSortedIndex-1]; - //And move the current extractedElement to the left one (since it's smaller). - sortedArray[lastSortedIndex-1] = extractedElement; - } - else{ - //insert element where it is. - sortedArray[lastSortedIndex] = extractedElement; - //Terminating loop since element is in the right spot. - break; - } - - } - - } - - return sortedArray; - - } - -} diff --git a/Selection Sort.java b/Selection Sort.java deleted file mode 100644 index d4f7c0ccb..000000000 --- a/Selection Sort.java +++ /dev/null @@ -1,40 +0,0 @@ -import java.util.Scanner; - -class SelectionSort -{ - 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<6; i++) - { - int min=i; - for(int j=i+1; j<6; j++) - { - if(array[j]