Professional Documents
Culture Documents
h>
int main() {
int n = 5;
printf("Factorial of %d is %llu\n", n, factorial(n));
return 0;
}
[28/02, 10:30 am] Ganesh Clg: #include <stdio.h>
int main() {
int n = 5;
printf("Factorial of %d is %llu\n", n, factorial(n));
return 0;
}
[28/02, 10:30 am] Ganesh Clg: #include<stdio.h>
return K[n][W];
}
int main() {
int val[] = {60, 100, 120};
int wt[] = {10, 20, 30};
int W = 50;
int n = sizeof(val)/sizeof(val[0]);
printf("Maximum value that can be obtained: %d", knapSack(W, wt, val, n));
return 0;
}
[28/02, 10:30 am] Ganesh Clg: #include <stdio.h>
#include <stdbool.h>
return true;
}
board[i][col] = 0; // Backtrack
}
}
return false;
}
int main() {
int board[N][N] = {0};
if (solveNQueens(board, 0) == false) {
printf("Solution does not exist");
} else {
printf("Solution:\n");
printSolution(board);
}
return 0;
}
[28/02, 10:30 am] Ganesh Clg: #include <stdio.h>
#include <stdlib.h>
struct MinHeapNode {
char data;
unsigned freq;
struct MinHeapNode *left, *right;
};
struct MinHeap {
unsigned size;
unsigned capacity;
struct MinHeapNode** array;
};
return temp;
}
minHeap->size = 0;
minHeap->capacity = capacity;
minHeap->array
= (struct MinHeapNode**)malloc(minHeap->
capacity * sizeof(struct MinHeapNode*));
return minHeap;
}
int main()
{
char data[] = {'a', 'b', 'c', 'd', 'e', 'f'};
int freq[] = {5, 9, 12, 13, 16, 45};
int size = sizeof(data) / sizeof(data[0]);
return 0;
}