Skip to content
Open
Show file tree
Hide file tree
Changes from all commits
Commits
Show all changes
54 commits
Select commit Hold shift + click to select a range
42354ac
Update CONTRIBUTORS.md
bchikara Oct 17, 2018
2dfb75b
Added Ceasar Cipher Py file
vishwasmehra Oct 17, 2018
bb5ca99
add my details in contribution.md
makkoncept Oct 17, 2018
8f5e181
Added Binary Search in C
Oct 17, 2018
62e748c
I added Linkedlist program in java
bchikara Oct 17, 2018
ac1b7f4
I added BINARY SEARCH IN CPP
varungarg15 Oct 17, 2018
bf2ffe8
C transpose of a matrix
palaashatri Oct 17, 2018
062ba01
add my details in contribution.md
impawanjoshi Oct 17, 2018
5f0dd06
add mmy details in contributors.md
AayushBansal-767 Oct 17, 2018
8cd1104
Added Bubble sort in C
Oct 17, 2018
6072bf4
Added Eculidean Algo Py file
vishwasmehra Oct 17, 2018
069f1c4
Added bubble sort
bchikara Oct 17, 2018
4c1cba8
I have added BUBBLE SORT IN CPP
varungarg15 Oct 17, 2018
69306a8
Merge pull request #2 from vishwasmehra/master
Tanmay17 Oct 17, 2018
763e174
Merge branch 'master' into master
Tanmay17 Oct 17, 2018
8451699
Merge branch 'master' into master
Tanmay17 Oct 17, 2018
6bf30e6
Merge pull request #4 from PalaashA/master
Tanmay17 Oct 17, 2018
540cb71
Merge branch 'master' into master
Tanmay17 Oct 17, 2018
cb03362
Added Merge sort in C
Oct 17, 2018
e9082dd
Merge branch 'master' into master
Tanmay17 Oct 17, 2018
14c389e
Merge pull request #5 from VipulChikara/master
Tanmay17 Oct 17, 2018
402d4a4
Merge branch 'master' into master
Tanmay17 Oct 17, 2018
1f8a625
Merge branch 'master' into master
Tanmay17 Oct 17, 2018
76104d1
Merge pull request #1 from sameer-dudeja/master
Tanmay17 Oct 17, 2018
355ab1f
Merge pull request #7 from impawanjoshi/master
Tanmay17 Oct 17, 2018
31c7d9a
Merge branch 'master' into master
Tanmay17 Oct 17, 2018
d16d51f
Merge branch 'master' into master
Tanmay17 Oct 17, 2018
c32940b
Merge pull request #8 from makkoncept/master
Tanmay17 Oct 17, 2018
dfa94ff
Merge pull request #9 from banaayush77/master
Tanmay17 Oct 17, 2018
8084956
Merge pull request #10 from NaveenShivnani/master
Tanmay17 Oct 17, 2018
0f53e5e
Merge branch 'master' into master
Tanmay17 Oct 17, 2018
b8d1517
Merge pull request #6 from blockbuster15/master
Tanmay17 Oct 17, 2018
3d2c692
Merge pull request #11 from sameer-dudeja/master
Tanmay17 Oct 17, 2018
2728a64
Prime checker using recursion
palaashatri Oct 17, 2018
2393e2d
Merge pull request #12 from PalaashA/master
Tanmay17 Oct 17, 2018
a3c2732
Added Merge sort in C
Oct 17, 2018
ed2b0b0
Merge pull request #13 from NaveenShivnani/master
Tanmay17 Oct 17, 2018
470e86d
I added merge-sort_VARUN_GARG
varungarg15 Oct 17, 2018
588f41e
Merge pull request #14 from sameer-dudeja/master
Tanmay17 Oct 17, 2018
7831b12
add fibonacci program
sanyam99ag Oct 17, 2018
c6a6e76
Merge pull request #15 from blockbuster15/master
Tanmay17 Oct 17, 2018
42b2c4a
written a code of factorial
impawanjoshi Oct 17, 2018
2066e21
Update Basics/Factorial/factorial_Palaash.c
palaashatri Oct 17, 2018
ede3f09
Merge pull request #16 from PalaashA/master
Tanmay17 Oct 17, 2018
12f1ec0
Merge branch 'master' of https://github.com/Tanmay17/Hactoberfest2k18…
sanyam99ag Oct 17, 2018
dc4d594
Added Huffmann code in C
Oct 17, 2018
491480c
pull changes from upstream
impawanjoshi Oct 17, 2018
9d07c39
Merge pull request #17 from sanyam99ag/master
Tanmay17 Oct 17, 2018
153a75e
Merge pull request #18 from NaveenShivnani/master
Tanmay17 Oct 17, 2018
81c02c6
Merge pull request #19 from impawanjoshi/master
Tanmay17 Oct 17, 2018
6fe69c8
Update Algorithms/Bubble Sort/bubbleSort_Palaash.c
palaashatri Oct 17, 2018
e5cfc6f
Merge pull request #20 from PalaashA/master
Tanmay17 Oct 17, 2018
1fcefa3
Update CONTRIBUTORS.md
palaashatri Oct 17, 2018
9433cea
Merge branch 'master' into master
Tanmay17 Oct 17, 2018
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
39 changes: 39 additions & 0 deletions Algorithms/Binary Search/Binary search.cpp
Original file line number Diff line number Diff line change
@@ -0,0 +1,39 @@
#include <stdio.h>

#include<stdio.h>
int main()
{
int c, first, last, middle, n, search, array[100];

printf("Enter number of elements\n");
scanf("%d",&n);

printf("Enter %d integers\n", n);

for (c = 0; c < n; c++)
scanf("%d",&array[c]);

printf("Enter value to find\n");
scanf("%d", &search);

first = 0;
last = n - 1;
middle = (first+last)/2;

while (first <= last) {
if (array[middle] < search)
first = middle + 1;
else if (array[middle] == search) {
printf("%d found at location %d.\n", search, middle+1);
break;
}
else
last = middle - 1;

middle = (first + last)/2;
}
if (first > last)
printf("Not found! %d isn't present in the list.\n", search);

return 0;
}
3 changes: 2 additions & 1 deletion Algorithms/Binary Search/Task.md
Original file line number Diff line number Diff line change
@@ -1,3 +1,4 @@
# Task

Implement Binary Search through your favourable language.
Implement Binary Search through your favourable language.

44 changes: 44 additions & 0 deletions Algorithms/Binary Search/binary_search.cpp
Original file line number Diff line number Diff line change
@@ -0,0 +1,44 @@

// C program to implement recursive Binary Search
#include <stdio.h>

// A recursive binary search function. It returns
// location of x in given 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 the element is present at the middle
// itself
if (arr[mid] == x)
return mid;

// If element is smaller than mid, then
// it can only be present in left subarray
if (arr[mid] > x)
return binarySearch(arr, l, mid-1, x);

// Else the element can only be present
// in right subarray
return binarySearch(arr, mid+1, r, x);
}

// We reach here when element is not
// present in array
return -1;
}

int main(void)
{
int arr[] = {2, 3, 4, 10, 40};
int n = sizeof(arr)/ sizeof(arr[0]);
int x = 10;
int result = binarySearch(arr, 0, n-1, x);
(result == -1)? printf("Element is not present in array")
: printf("Element is present at index %d",
result);
return 0;
}
34 changes: 34 additions & 0 deletions Algorithms/Bubble Sort/bubble sort.cpp
Original file line number Diff line number Diff line change
@@ -0,0 +1,34 @@
#include <stdio.h>

int main()
{
int array[100], n, c, d, swap;

printf("Enter number of elements\n");
scanf("%d", &n);

printf("Enter %d integers\n", n);

for (c = 0; c < n; c++)
scanf("%d", &array[c]);

for (c = 0 ; c < n - 1; c++)
{
for (d = 0 ; d < n - c - 1; d++)
{
if (array[d] > array[d+1]) /* For decreasing order use < */
{
swap = array[d];
array[d] = array[d+1];
array[d+1] = swap;
}
}
}

printf("Sorted list in ascending order:\n");

for (c = 0; c < n; c++)
printf("%d\n", array[c]);

return 0;
}
42 changes: 42 additions & 0 deletions Algorithms/Bubble Sort/bubble.cpp
Original file line number Diff line number Diff line change
@@ -0,0 +1,42 @@

// C program for implementation of Bubble sort
#include <stdio.h>

void swap(int *xp, int *yp)
{
int temp = *xp;
*xp = *yp;
*yp = temp;
}

// A function to implement bubble sort
void bubbleSort(int arr[], int n)
{
int i, j;
for (i = 0; i < n-1; i++)

// Last i elements are already in place
for (j = 0; j < n-i-1; j++)
if (arr[j] > arr[j+1])
swap(&arr[j], &arr[j+1]);
}

/* Function to print an array */
void printArray(int arr[], int size)
{
int i;
for (i=0; i < size; i++)
printf("%d ", arr[i]);
printf("n");
}

// Driver program to test above functions
int main()
{
int arr[] = {64, 34, 25, 12, 22, 11, 90};
int n = sizeof(arr)/sizeof(arr[0]);
bubbleSort(arr, n);
printf("Sorted array: \n");
printArray(arr, n);
return 0;
}
34 changes: 34 additions & 0 deletions Algorithms/Bubble Sort/bubbleSort_Palaash.c
Original file line number Diff line number Diff line change
@@ -0,0 +1,34 @@
#include<stdio.h>
//Descending Bubble Sort using C
int main()
{
int a[20],i,j,size,temp,swap;
printf("\n Enter Array Size : ");
scanf("%d",&size);
printf("\n Enter Array Elements : ");
for(i=0;i<size;i++)
scanf("%d",&a[i]);

//BUBBLE SORT : Descending
for(i=0;i<size-1;i++){
swap=0;
//COMPARE ELEMENTS AND SWAP:
for(j=0;j<(size-1)-1;j++){
if(a[j]<a[j+1]){
temp=a[j];
a[j]=a[j+1];
a[j+1]=temp;
swap=1;
}
}
if(swap==0){
break;
}
}

printf("\nArray after sort: ");
for(i=0;i<size;i++)
printf("%d",a[i]);

return 0;
}
33 changes: 33 additions & 0 deletions Algorithms/Bubble Sort/bubblesort.java
Original file line number Diff line number Diff line change
@@ -0,0 +1,33 @@
public class array {
static Scanner scn = new Scanner(System.in);

public static void main(String[] args) {
int[] arr2 = takeinput();
bubblesort(arr2);
display(arr2);
}
public static int[] takeinput() {
int n = scn.nextInt();
int[] arr = new int[n];
for (int i = 0; i <= arr.length - 1; i++) {
arr[i] = scn.nextInt();
}
return arr;
}

public static void display(int[] arr) {
for (int i = 0; i <= arr.length - 1; i++) {
System.out.println(arr[i]);
}
}
public static void bubblesort(int[] arr) {
for (int c = 0; c < arr.length - 1; c++) {
for (int j = 0; j < arr.length - 1 - c; j++) {
if (arr[j] > arr[j + 1]) {
int temp = arr[j];
arr[j] = arr[j + 1];
arr[j + 1] = temp;
}
}
}
}
Loading