Tag Archives: Algorithm

Binary search algorithm

1. Getting. In binary search algorithm, we find an element x in a sorted array by using the principle of divide and conquer. First, we compare x to the middle point of the array. If x is less than the middle point, then we search the left of array. Otherwise, we look for the right… Read More »

Heap’s algorithm for Permutations

Problem: Find the biggest number from the array [3, 1, 2] (n = 3). For example: 321 is largest number in comparison with all possible numbers from the array. Solving: We need to resolve 2 things. Final all possible Permutations from the array. So possible permutation is n! = 3! = 6 cases. Find a maximum number from… Read More »

Quick Sort Algorithm

Quick sort discovered by C.A.R Hoare in 1962. It is a fast algorithm for internal or in-memory sorting except for sorting data in disk files. Figure 1: Time and Space complexity of quick sort. There are three basic steps: Partition the array or sub-array into left (smaller keys) and right (larger keys) groups. Call ourselves to sort… Read More »