Exponential Search in Kotlin

Exponential search is a search algorithm that is used to find an element in a sorted array by repeatedly doubling the search range until the element is found or the search range exceeds the size of the array. The algorithm works as follows: how the exponentialSearch function works: Exponential search has a time complexity of … Read more

Jump Search in Kotlin

Jump search is a searching algorithm that works on sorted arrays. It is similar to binary search, but instead of dividing the array into two equal halves, it jumps or skips some elements based on a step size until it finds an element greater than or equal to the search key. Once the element is … Read more

Radix Sort in Kotlin

Radix sort is a non-comparative sorting algorithm that sorts integers by grouping them based on their individual digits, or more generally, on their individual “radix” (base). The algorithm sorts the input integers from least significant digit (LSD) to most significant digit (MSD), with each pass sorting the integers based on the current digit position. The … Read more

Heap Sort in Kotlin

Heap sort is a popular sorting algorithm that works by first creating a binary heap from the array to be sorted and then repeatedly removing the root element of the heap, which is the maximum element, and placing it at the end of the array. The remaining elements in the heap are then reorganized to … Read more

Merge Sort in Kotlin

Merge sort is a popular sorting algorithm that works by recursively dividing an array into smaller sub-arrays until each sub-array has only one element, and then merging the sub-arrays back together in sorted order. The merging process involves comparing the first element of each sub-array and adding the smaller of the two elements to a … Read more

Quick Sort in Kotlin

Quicksort is a popular sorting algorithm that works by dividing an array into two smaller sub-arrays based on a chosen pivot element, such that all elements to the left of the pivot are smaller and all elements to the right are larger. The two sub-arrays are then recursively sorted using the same process, until the … Read more

Bubble Sort in Kotlin

Bubble sort is a simple sorting algorithm that repeatedly iterates through the array, compares adjacent elements and swaps them if they are in the wrong order. During each pass through the array, the largest element will “bubble” to the end of the unsorted part of the array, so the algorithm gets its name from this … Read more

Selection Sort in Kotlin

Selection sort is another simple sorting algorithm that works by repeatedly finding the minimum (or maximum) element from the unsorted part of the array or list and placing it at the beginning of the sorted part. The algorithm divides the array or list into two parts: the sorted part and the unsorted part. The sorted … Read more

Insertion Sort in Kotlin

Insertion sort is a simple sorting algorithm that works by building the final sorted array or list one element at a time, by inserting each unsorted element into its proper position within the sorted array or list. The algorithm maintains a sub-array of sorted elements and inserts each new element into its proper position within … Read more

Binary Search in Kotlin

Binary search is a search algorithm that works by repeatedly dividing the search interval in half. It is a very efficient algorithm for searching sorted arrays or lists. The algorithm begins by comparing the target value with the middle element of the array or list. If the target value matches the middle element, the search … Read more