include include struct Node;typedef struct Node * PtrToNode;typedef PtrToNode List;typedef PtrToNode Position; struct Node{int e;Position next;}; void Insert(int x, List l, Position p){Position TmpCell;TmpCell = (struct Node*) malloc(sizeof(struct Node));if(TmpCell == NULL)printf(“Memory out of space\n”);else{TmpCell->e = x;TmpCell->next = p->next;p->next = TmpCell;}} int isLast(Position p){return (p->next == NULL);} Position FindPrevious(int x, List l){Position p = l;while(p->next != …
Start reading C Program to Implement Single Linked List OperationsBlog
struct Node;typedef struct Node * PtrToNode;typedef PtrToNode List;typedef PtrToNode Position; struct Node{int e;Position previous;Position next;}; void Insert(int x, List l, Position p){Position TmpCell;TmpCell = (struct Node*) malloc(sizeof(struct Node));if(TmpCell == NULL)printf(“Memory out of space\n”);else{TmpCell->e = x;TmpCell->previous = p;TmpCell->next = p->next;p->next = TmpCell;}} int isLast(Position p){return (p->next == NULL);} Position Find(int x, List l){Position p = l->next;while(p …
Start reading C Program to Implement Doubly Linked List Operations/* Binary search program in C using both recursive and non recursive functions */ include define MAX_LEN 10 /* Non-Recursive function*/void b_search_nonrecursive(int l[],int num,int ele){int l1,i,j, flag = 0;l1 = 0;i = num-1;while(l1 <= i){j = (l1+i)/2;if( l[j] == ele){printf(“\nThe element %d is present at position %d in list\n”,ele,j);flag =1;break;}elseif(l[j] < ele)l1 = j+1;elsei = …
Start reading Binary Search Program in C using Recursive and Non-Recursive Methodsvoid binary(int val);int main(){int a,b;printf(“Enter the number in decimal:”);scanf(“%d”,&a);printf(“Number in Binary form: “);binary(a);return 0;}void binary(int val){int r;r=val%2;val=val/2;if(val==0){printf(“%d”,r);}else{binary(val);printf(“%d”,r);}} OUTPUT: Enter the number in decimal:10Number in Binary form: 1010
Start reading Decimal to Binary Conversion Using Cint main(){int a[200],n,counter,temp,i;a[0]=1;counter=0;printf(“Enter the number to Find Factorial: “);scanf(“%d”,&n);for(; n>=2; n–){temp=0;for(i=0; i<=counter; i++) { temp=(a[i]*n)+temp; a[i]=temp%10; temp=temp/10; } while(temp>0){a[++counter]=temp%10;temp=temp/10;}}for(i=counter; i>=0; i–)printf(“%d”,a[i]);return 0;}OUTPUT: Enter the number to Find Factorial: 10093326215443944152681699238856266700490715968264381621468592963895217599993229915608941463976156518286253697920827223758251185210916864000000000000000000000000
Start reading Compute Factorial of Large Numbers using C// Function to find largest elementint largest(int a[], int n){int large = a[0], i;for(i = 1; i < n; i++){if(large < a[i])large = a[i];}return large;} // Function to perform sortingvoid RadixSort(int a[], int n){int bucket[10][10], bucket_count[10];int i, j, k, remainder, NOP=0, divisor=1, large, pass; } //program starts hereint main(){int i, n, a[10];printf(“Enter the number of …
Start reading C Program to Implement RADIX SORTvoid Merge(int a[], int tmp[], int lpos, int rpos, int rend){int i, lend, n, tmppos;lend = rpos – 1;tmppos = lpos;n = rend – lpos + 1; } void MSort(int a[], int tmp[], int left, int right){int center;if(left < right){center = (left + right) / 2;MSort(a, tmp, left, center);MSort(a, tmp, center + 1, right);Merge(a, tmp, …
Start reading Merge Sort Program in CPUSH function in the code is used to insert an element to the top of stack, POP function used to remove the element from the top of stack. Finally, the display function in the code is used to print the values. All stack functions are implemented in C Code. include int stack[100],choice,n,top,x,i;void push(void);void pop(void);void display(void);int …
Start reading Implementation of Stack Using Array in Cint n,nf;int in[100];int p[50];int hit=0;int i,j,k;int pgfaultcnt=0; void getData(){printf(“\nEnter length of page reference sequence:”);scanf(“%d”,&n);printf(“\nEnter the page reference sequence:”);for(i=0; i<n; i++)scanf(“%d”,&in[i]);printf(“\nEnter no of frames:”);scanf(“%d”,&nf);} void initialize(){pgfaultcnt=0;for(i=0; i<nf; i++)p[i]=9999;} int isHit(int data){hit=0;for(j=0; j<nf; j++){if(p[j]==data){hit=1;break;} } int getHitIndex(int data){int hitind;for(k=0; k<nf; k++){if(p[k]==data){hitind=k;break;}}return hitind;} void dispPages(){for (k=0; k<nf; k++){if(p[k]!=9999)printf(” %d”,p[k]);} } void dispPgFaultCnt(){printf(“\nTotal no of page faults:%d”,pgfaultcnt);} void fifo(){initialize();for(i=0; …
Start reading Page Replacement Programs in CQuick sort is a faster sorting method with less time complexity. Quick sort uses divide and conquer approcah to sort elements. Time complexity of Quick sort: Best Case Time Complexity of Quick Sort: O(n*log n) Average case Time Complexity of Quick Sort: O(n*log n) Worst Case Time Complexity of Quick Sort: O(n2) C Program to …
Start reading C Program for Quick Sort