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
// Stack implementation in C using Array. | |
#include<stdio.h> | |
#include<stdlib.h> // header file for exit and return function | |
#define max 5 | |
int stack[max],top=-1; // global variable | |
void push(); | |
int pop(); |
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
//Queue Implementation In C Using Array ! | |
#include<stdio.h> | |
#include<stdlib.h> // hearder for for using exit and return function | |
#define max 5 // symbolic constant | |
int rear=-1,front=-1; // global variable | |
int queue[max]; |
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
//Circular Queue Implementation in C using Array ! | |
#include<stdio.h> | |
#include<stdlib.h> //header file for using return and exit function | |
#define max 5 //symbolic constant | |
int front=-1,rear=-1; // global variable | |
int CQueue[max]; |
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
/// 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