Merge Sorted Arrays – Coding Problem

Given two sorted integer arrays arr1 and arr2, merge arr1 and arr2 as one sorted array. Example Input: arr1 = [1,2,3] arr2 = [2,5,6] Output: [1,2,2,3,5,6] Solution1: we compare the corresponding elements of both arraysWe add the smaller element to a new array and increment the index of the array from which the element was added.Again we compare the elements of … Continue reading Merge Sorted Arrays – Coding Problem

Stooge Sort

The Stooge sort is a recursive sorting algorithm. It is defined as below (for ascending order sorting). Step 1 : If value at index 0 is greater than value at last index, swap them. Step 2: Recursively, a) Stooge sort the initial 2/3rd of the array. b) Stooge sort the last 2/3rd of the array. … Continue reading Stooge Sort

Bitonic Sort

Bitonic Sort is a classic parallel algorithm for sorting. Bitonic sort does O(n Log 2n) comparisons.The number of comparisons done by Bitonic sort are more than popular sorting algorithms like Merge Sort [ does O(nLogn) comparisons], but Bitonice sort is better for parallel implementation because we always compare elements in predefined sequence and the sequence of … Continue reading Bitonic Sort

Fibonacci Search

Fibonacci Search is a comparison-based technique that uses Fibonacci numbers to search an element in a sorted array. Similarities with Binary Search: Works for sorted arrays A Divide and Conquer Algorithm. Has Log n time complexity. Differences with Binary Search: Fibonacci Search divides given array in unequal partsBinary Search uses division operator to divide range. … Continue reading Fibonacci Search