[알고리즘] Assignment 5 - LCS 알고리즘, BFS 알고리즘, Kruskal 알고리즘, Dijkstra 알고리즘, Prim 알고리즘
1. LCS (Longest Common Subsequence, 최장 공통 부분 문자열) #include #define MAX(a,b) ((a)>(b)? (a):(b)) int LCS_table[10][10] = { 0, }; void LCS_length(int str1_len, int str2_len, char* str1, char* str2) { for (int i = 1; i < str1_len; i++) { for (int j = 1; j < str2_len; j++) { if (str1[i] == str2[j]) { LCS_table[i][j] = LCS_table[i - 1][j - 1] + 1; } else { LCS_table[i][j] = MAX(LCS_table[i - 1][j], LC..
2022. 1. 28.
[알고리즘] Assignment 3 - 정렬 알고리즘 (bubble sort, insertion sort, merge sort, quick sort, radix sort, bucket sort)
1. Code #include #include #define SIZE 1000 #define DIGIT 4 int origin[SIZE], result[SIZE], result_2[SIZE]; void bubble_sort() { int i, j, temp; for (i = SIZE - 1; i > 0; i--) { for (j = 0; j origin[j + 1]) { temp = origin[j]; origin[j] = origin[j + 1]; origin[j + 1] = temp; } } } } void insertion_sort() { int i, j, temp; for (i = 1; i < SIZE; i++) { temp = origin[i];..
2022. 1. 28.