From fcc6c7a3f2f7ce5ffc8311103769acb8fc944e87 Mon Sep 17 00:00:00 2001 From: Ankit R Gadiya Date: Tue, 3 Oct 2017 16:14:38 +0530 Subject: [PATCH] Directories Updated * Merged 2 sorts folder * Merged 2 conversion folder * Merged 2 search folder * Renamed Computer Oriented Statistical Methods --- Conversions/Binary To Decimal.c | 17 ------ Searches/BinarySearch.c | 39 ------------- Sorts/BogoSort.c | 40 ------------- Sorts/BubbleSort.c | 40 ------------- Sorts/InsertionSort.c | 29 ---------- Sorts/OtherBubbleSort.c | 56 ------------------- .../Gauss_Elimination.c | 0 .../MEAN.C | 0 .../MEDIAN.C | 0 .../Seidal.C | 0 .../lagrange_theorem.C | 0 .../simpson's 1-3rd rule.c | 0 .../variance.c | 0 {Sorts => sorting}/QuickSort.c | 0 14 files changed, 221 deletions(-) delete mode 100644 Conversions/Binary To Decimal.c delete mode 100644 Searches/BinarySearch.c delete mode 100644 Sorts/BogoSort.c delete mode 100644 Sorts/BubbleSort.c delete mode 100644 Sorts/InsertionSort.c delete mode 100644 Sorts/OtherBubbleSort.c rename {Computer Oriented Statistical Methods => computer-oriented-statistical-methods}/Gauss_Elimination.c (100%) rename {Computer Oriented Statistical Methods => computer-oriented-statistical-methods}/MEAN.C (100%) rename {Computer Oriented Statistical Methods => computer-oriented-statistical-methods}/MEDIAN.C (100%) rename {Computer Oriented Statistical Methods => computer-oriented-statistical-methods}/Seidal.C (100%) rename {Computer Oriented Statistical Methods => computer-oriented-statistical-methods}/lagrange_theorem.C (100%) rename {Computer Oriented Statistical Methods => computer-oriented-statistical-methods}/simpson's 1-3rd rule.c (100%) rename {Computer Oriented Statistical Methods => computer-oriented-statistical-methods}/variance.c (100%) rename {Sorts => sorting}/QuickSort.c (100%) diff --git a/Conversions/Binary To Decimal.c b/Conversions/Binary To Decimal.c deleted file mode 100644 index 93cb7d3f..00000000 --- a/Conversions/Binary To Decimal.c +++ /dev/null @@ -1,17 +0,0 @@ -#include -#include -int main() { - int number, decimal_number, temp=1; - printf("Enter any binary number= "); - scanf("%d", &number); - int remainder; - while(number>0) { - - remainder = number%10; - number = number/10; - decimal_number += remainder*temp; - temp = temp*2;//used as power of 2 - - } - printf("%d",decimal_number); -} diff --git a/Searches/BinarySearch.c b/Searches/BinarySearch.c deleted file mode 100644 index 4a0d7cc3..00000000 --- a/Searches/BinarySearch.c +++ /dev/null @@ -1,39 +0,0 @@ -#include - -// Recursive Function- It returns location of x assumiung array arr[l..r] is present, otherwise -1 - -int binarysearch(int arr[], int l, int r, int x) -{ - if (r >= l) - { - int mid = l + (r - l)/2; - - // If element is present at middle - if (arr[mid] == x) return mid; - - // If element is smaller than middle - if (arr[mid] > x) return binarysearch(arr, l, mid-1, x); - - // Else element is in right subarray - return binarysearch(arr, mid+1, r, x); - } - - // When element is not present in array - return -1; -} - -int main(void) -{ - // give function an array to work with - int arr[] = {2, 3, 4, 10, 40}; - // get size of array - int n = sizeof(arr)/ sizeof(arr[0]); - //set value to look for - int x = 10; - // set result to what is returned from binarysearch - int result = binarysearch(arr, 0, n-1, x); - // print out result - (result == -1)? printf("Element is not in the array") - : printf("Element is present at index %d", result); - return 0; -} diff --git a/Sorts/BogoSort.c b/Sorts/BogoSort.c deleted file mode 100644 index 8ad36b40..00000000 --- a/Sorts/BogoSort.c +++ /dev/null @@ -1,40 +0,0 @@ -#include -#include -#include - -bool check_sorted(int *a, int n) -{ - while ( --n >= 1 ) { - if ( a[n] < a[n-1] ) return false; - } - return true; -} - -void shuffle(int *a, int n) -{ - int i, t, r; - for(i=0; i < n; i++) { - t = a[i]; - r = rand() % n; - a[i] = a[r]; - a[r] = t; - } -} - -void sort(int *a, int n) -{ - while ( !check_sorted(a, n) ) shuffle(a, n); -} - -int main() -{ - int numbers[6]; - int i; - printf("Enter 6 numbers unsorted \n\n"); - for(i=0;i<6;i++){ - scanf("%d",&numbers[i]); - } - sort(numbers, 6); - for (i=0; i < 6; i++) printf("%d ", numbers[i]); - printf("\n"); -} diff --git a/Sorts/BubbleSort.c b/Sorts/BubbleSort.c deleted file mode 100644 index 95e8453f..00000000 --- a/Sorts/BubbleSort.c +++ /dev/null @@ -1,40 +0,0 @@ -#include -#include - - -int main(){ - - int* ARRAY=NULL; - int ContinueFilling=1; //This is to know if we should continue filling our array - int ARRAY_LENGTH=0,isSorted=0,i,TEMPORARY_ELEMENT; - - //This code part is for filling our array - while(ContinueFilling){ - printf("Enter the value number %d \n",ARRAY_LENGTH+1); - ARRAY=(int *)realloc(ARRAY,sizeof(int)*(ARRAY_LENGTH)); - scanf("%d",&ARRAY[ARRAY_LENGTH]); - ARRAY_LENGTH+=1; - printf("would you enter an other value (1:Continue/0:Sort the actual array)?\n"); - scanf("%d",&ContinueFilling); - } - - //Then we sort it using Bubble Sort.. - - while(!isSorted){ //While our array's not sorted - isSorted=1; //we suppose that it's sorted - for(i=0;iARRAY[i+1]){ // if the two elements aren't sorted - isSorted=0; //it means that the array is not sorted - TEMPORARY_ELEMENT=ARRAY[i]; //and we switch these elements using TEMPORARY_ELEMENT - ARRAY[i]=ARRAY[i+1]; - ARRAY[i+1]=TEMPORARY_ELEMENT; - } - } - } - //And we display it - for(i=0;i -#incude -#define MAX 20 - - - -int main() -{ - int i, elmtToInsert , j , arraySort[MAX] = {0}; - - for(i = 1 ; i < MAX ; i++) - { - elmtToInsert = arraySort[i]; - j = i - 1 ; - - while( j >= 0 && elmtToInsert < arraySort[j]) - { - arraySort[j+1] = arraySort[j]; - j--; - } - - arraySort[j+1] = elmtToInsert ; - } - - - - - return EXIT_SUCCESS; -} diff --git a/Sorts/OtherBubbleSort.c b/Sorts/OtherBubbleSort.c deleted file mode 100644 index f11fd63e..00000000 --- a/Sorts/OtherBubbleSort.c +++ /dev/null @@ -1,56 +0,0 @@ -#include -#include -#define MAX 20 -#define TRUE 1 -#define FALSE 0 - - -int main() -{ - - int i , arraySort[MAX] ={0} , isSort = FALSE, changePlace; - - - /* For example - Insertion random values in array to test - */ - - - for(i = 0 ; i < MAX; i++) - { - arraySort[i] = rand()%101 ; - } - - -/* Algorithm of bubble methods */ - - while(isSort) - { - isSort = FALSE; - - for( i = 0 ; i < MAX - 1 ; i++) - { - if(arraySort[i] > arraySort[i+1]) - { - changePlace = arratSort[i]; - arraySort[i] = arraySort[i+1]; - arraySort[i+1] = changePlace ; - isSort = TRUE; - } - - } - } - - /* See if it works */ - - for(i = 0 ; i < MAX; i++) - { - printf("%d\n", arraySort[i]); - } - - - - - return EXIT_SUCCESS; - -} diff --git a/Computer Oriented Statistical Methods/Gauss_Elimination.c b/computer-oriented-statistical-methods/Gauss_Elimination.c similarity index 100% rename from Computer Oriented Statistical Methods/Gauss_Elimination.c rename to computer-oriented-statistical-methods/Gauss_Elimination.c diff --git a/Computer Oriented Statistical Methods/MEAN.C b/computer-oriented-statistical-methods/MEAN.C similarity index 100% rename from Computer Oriented Statistical Methods/MEAN.C rename to computer-oriented-statistical-methods/MEAN.C diff --git a/Computer Oriented Statistical Methods/MEDIAN.C b/computer-oriented-statistical-methods/MEDIAN.C similarity index 100% rename from Computer Oriented Statistical Methods/MEDIAN.C rename to computer-oriented-statistical-methods/MEDIAN.C diff --git a/Computer Oriented Statistical Methods/Seidal.C b/computer-oriented-statistical-methods/Seidal.C similarity index 100% rename from Computer Oriented Statistical Methods/Seidal.C rename to computer-oriented-statistical-methods/Seidal.C diff --git a/Computer Oriented Statistical Methods/lagrange_theorem.C b/computer-oriented-statistical-methods/lagrange_theorem.C similarity index 100% rename from Computer Oriented Statistical Methods/lagrange_theorem.C rename to computer-oriented-statistical-methods/lagrange_theorem.C diff --git a/Computer Oriented Statistical Methods/simpson's 1-3rd rule.c b/computer-oriented-statistical-methods/simpson's 1-3rd rule.c similarity index 100% rename from Computer Oriented Statistical Methods/simpson's 1-3rd rule.c rename to computer-oriented-statistical-methods/simpson's 1-3rd rule.c diff --git a/Computer Oriented Statistical Methods/variance.c b/computer-oriented-statistical-methods/variance.c similarity index 100% rename from Computer Oriented Statistical Methods/variance.c rename to computer-oriented-statistical-methods/variance.c diff --git a/Sorts/QuickSort.c b/sorting/QuickSort.c similarity index 100% rename from Sorts/QuickSort.c rename to sorting/QuickSort.c