Greedy Algorithm
-
Selection SortAlgoDS/Algorithm 2020. 1. 22. 17:35
1. Overview The selection sort algorithm sorts an array by repeatedly finding the minimum element (considering ascending order) from the unsorted part and putting it at the beginning. It's one of the Greedy Algorithms. 2. Description 2.1 Procedure The algorithm maintains two subarrays in a given array. In every iteration of selection sort, the minimum element (considering ascending order) from t..
-
Greedy AlgorithmAlgoDS/Algorithm 2020. 1. 22. 12:32
1. Overview Greedy is an algorithmic paradigm that builds up a solution piece by piece, always choosing the next piece that offers the most obvious and immediate benefit. So the problems where choosing locally optimal also leads to a global solution is the best fit for Greedy. Greedy Algorithm is an algorithmic paradigm that builds up a solution piece by pice It always chooses the next piece tha..
-
Insertion SortAlgoDS/Algorithm 2020. 1. 17. 19:13
1. Overview Insertion sort is a simple sorting algorithm that works the way we sort playing cards in our hands. It's one of the Greedy Algorithms. For nearly sorted data, consider that insertion sort is O(n) time. 2. Description 2.1 Procedure 12, 11, 13, 5, 6 Let us loop for i = 1 (second element of the array) to 4 (last element of the array) i = 1. Since 11 is smaller than 12, move 12 and inser..
-
Bubble sortAlgoDS/Algorithm 2020. 1. 17. 17:34
1. Overview Bubble Sort is the simplest sorting algorithm that works by repeatedly swapping the adjacent elements if they are in the wrong order. It's one of the Greedy Algorithms. 2. Description 2.1 Procedure Step 1: Starting with the first element(index = 0), compare the current element with the next element of the array. Step 2: If the current element is greater than the next element of the a..