Posts

Showing posts with the label algorithm

Merge Sort Algorithm

Image
Merge Sort is a sorting algorithm that implement divide and conquer method. It generally use to motivates guiding principles for algorithm analysis (worst-case and asymptotic analysis) and also provide the analysis generalizes to “Master Method”. (PS: algorithm also known as Pseudocode.) Purpose of merge sort: If you given an arrays of n numbers that is unsorted for example like "5,4,1,8,7,2,6,3", you are required have the output of the same number arrays sorted in increasing order like"1,2,3,4,5,6,7,8". Illustrate how merge sort work How Merge sort Work? The arrays will divide into half Recursively  sort the first half of the input array recursively sort the second half of the input array Merge the 2 sorted half array into 1 like the picture above. Pseudocode for Merge: C = output [length = n] A = 1st sorted array [n/2] B = 2nd sorted array [n/2] i = 1 j = 1

Quine-McCluskey (Tabulation) Method

Image
Quine-McCluskey (Tabulation) Method is an alternative method to replace Karnaugh-Map(K-maps). When there are more than 6 variables ,K-maps are not efficient to minimized standard from Boolean function. However, for functions with more than six variables, it becomes very difficult to visualize how the minterms should be combined into subcubes. In addition, the K-map algorithm is not as straight forward to program the computer with. There exist a tabulation method called Quine-McClusky method that are better suited for programming the computer, and thus can solve any function having any number of variables. Example: f (w,x,y,z) = Σ(0,2,5,7,10,13,14,15) The minterms is group according to the numbers of 1's in the minterms binary representation. For Example the Group 0 does not have any 1's binary(0000),the group 1 has only one 1's(0010), the group 2 got 2 subcube minterms that have two 1's. The next step, we construct another tables by combining the minterms in ...