본문 바로가기

College Computer Science/Algorithm5

[알고리즘] 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 4 Implement the following algorithms in the C programming language and put the described input to the algorithm in order to check the answer. Submit 1) a report containing outputs of the following problems and 2) the codes you have written (screenshots okay). 1. Implement an algorithm of Fibonacci numbers using dynamic programming and get the answers when feeding 𝑛=5 and 𝑛=10 into the algorithm as.. 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.
[알고리즘] Assignment 2 Submit a word, hwp or pdf file to the e-class that contains (1) your answers for the following exercises, and (2) your codes written in the C programming language and their results for programming exercises (screenshots okay). 1. (programming) Write a program that takes a number n and displays the largest k satisfying the following equations: 2^k 2022. 1. 28.
[알고리즘] Assignment 1 2022. 1. 28.