This file contains hidden or 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
| #include <stdio.h> | |
| #include <stdlib.h> | |
| // Function to partition the array and return the index of the pivot | |
| int partition(int arr[], int low, int high) | |
| { | |
| int pivot = arr[high]; | |
| int i = low - 1; | |
| for (int j = low; j < high; j++) |
This file contains hidden or 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
| #include <stdio.h> | |
| #include <stdlib.h> | |
| #include <string.h> | |
| // Define a structure to represent a node in the Huffman tree | |
| struct Node | |
| { | |
| char data; | |
| int freq; | |
| struct Node* left; | |
| struct Node* right; |
This file contains hidden or 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
| #include <stdio.h> | |
| #include <stdlib.h> | |
| // Structure to represent an edge in the graph | |
| struct Edge | |
| { | |
| int src, dest, weight; | |
| }; | |
| // Structure to represent a subset for union-find |
This file contains hidden or 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
| #include <stdio.h> | |
| int modexp(int a, int b, int N) | |
| { | |
| if (b == 0) | |
| { | |
| return 1; | |
| } | |
| int z = modexp(a, b / 2, N); |
This file contains hidden or 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
| #include <stdio.h> | |
| // Function to multiply two 2x2 matrices using Strassen's algorithm | |
| void strassen_multiply(int A[2][2], int B[2][2], int C[2][2]) { | |
| int M1, M2, M3, M4, M5, M6, M7; | |
| M1 = (A[0][0] + A[1][1]) * (B[0][0] + B[1][1]); | |
| M2 = (A[1][0] + A[1][1]) * B[0][0]; | |
| M3 = A[0][0] * (B[0][1] - B[1][1]); | |
| M4 = A[1][1] * (B[1][0] - B[0][0]); |
This file contains hidden or 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
| #include <stdio.h> | |
| #include <stdlib.h> | |
| #include <math.h> | |
| #include <float.h> | |
| struct Point | |
| { | |
| int x, y; | |
| }; |
This file contains hidden or 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
| #include <stdio.h> | |
| #include <math.h> | |
| // Function to multiply two numbers using divide and conquer | |
| int multiply(int x, int y) { | |
| // Base case: if either x or y is a single digit | |
| if (x < 10 || y < 10) { | |
| return x * y; | |
| } |
This file contains hidden or 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
| #include <stdio.h> | |
| int gcd(int x,int y) | |
| { | |
| if(y==0) | |
| { | |
| return x; | |
| } | |
| return gcd(y,x%y); |
This file contains hidden or 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
| #include <stdio.h> | |
| int modexp(int x,int y,int N) | |
| { | |
| if(y==0) | |
| { | |
| return 1; | |
| } | |
| int z=modexp(x,y/2,N); |
This file contains hidden or 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
| #include <stdio.h> | |
| int multiply(int x, int y) | |
| { | |
| if (y == 0) | |
| { | |
| return 0; | |
| } | |
| int z = multiply(x, y / 2); |
NewerOlder