This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
/// Bubble sort /// | |
#include<stdio.h> | |
main() | |
{ | |
int a[100],i,p,n,temp; | |
printf("Enter how many elements for your Array:"); | |
scanf("%d",&n); | |
printf("\nEnter %d values :",n); | |
for(i=0;i<n;i++) |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
/// Selection Sort /// | |
#include<stdio.h> | |
main() | |
{ | |
int a[100],i,j,minIndex,temp,n; | |
printf("Enter How many elements on your Array :"); | |
scanf("%d",&n); | |
printf("\nEnter %d values :",n); | |
for(i=0;i<n;i++) |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
/// Insertion Sort /// | |
#include<stdio.h> | |
main() | |
{ | |
int a[100],i,value,hole,n; | |
printf("Enter how many elements on your Array :"); | |
scanf("%d",&n); | |
printf("\nEnter %d values :",n); | |
for(i=0;i<n;i++) |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
/// linear search /// | |
#include <stdio.h> | |
main() | |
{ | |
int a[100],i,n,pos=0,item; | |
printf("Enter How many elements on your Array: "); | |
scanf("%d",&n); | |
printf("\nEnter %d elements values : ",n); | |
for(i=0;i<n;i++) |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
/// Binary Search /// | |
#include<stdio.h> | |
main() | |
{ | |
int a[]={1,2,3,4,5,6,7,8,9,10},i,start,end,mid,item; | |
printf("Enter a item to Search:"); | |
scanf("%d",&item); | |
start=0; | |
end=9; |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
// The 3n+1 problem // | |
#include<stdio.h> | |
long long count(long long n){ | |
long long c; | |
c=1; | |
while(n>1){ | |
if(n%2!=0){ | |
n=(3*n)+1; |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
/// longest Increasing Subsequence /// | |
#include<stdio.h> | |
#define max 100 | |
main() | |
{ | |
int arr[max],len[max],i,j,n,LIS; | |
printf("Enter the no of Elements :"); | |
scanf("%d",&n); |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
/// Breadth First Search for weighted undirected graph ! | |
#include <stdio.h> | |
#include <stdlib.h> | |
#define max 20 | |
int queue[max]; | |
int front,rear; |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
/// Depth First Search Implementation in C++ /// | |
#include<iostream> | |
#include<stdio.h> | |
#define max 20 | |
int stack[max]; | |
int top; | |
void DFS(int arr[][max],int,int); |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
/// Breadth First Search Implementation in C /// | |
#include<stdlib.h> // this header file is needed for exit function | |
#include<stdio.h> | |
#define max 20 | |
int queue[max]; | |
int front,rear; | |
int BFS(int arr[][max],int ,int); |
OlderNewer