AlgorithmsCollection.binary_searchFunction
binary_search(array::Array{Int64,1}, target::Int64)

The binary search algorithm (BSA) finds a target value's position within a sorted array by using a half-interval cut per each cycle. Thus, the BSA compares the target value to the value of the array's middle element. In the case of inequality, the half array-piece in which the target cannot be will be erased. Next, the search continues on the remaining half array-piece and starts taking the middle element to compare it to the target value. This procedure has to be continued until the target value is found. The search may have to be stopped with a remaining empty half array-piece; consequently, the target is not in the array. For more information see: https://en.wikipedia.org/wiki/Binarysearchalgorithm

Arguments

  • array::Array{Int64,1}: Sorted array of integers
  • target::Int64: Target-value to find the position

Examples

julia> import ClassicAlgorithmsCollections
julia> arr = [10,11, 12, 14, 16, 18, 19, 20, 21, 22, 23, 24, 33, 35, 42, 47]
julia> target = 12
julia> ClassicAlgorithmsCollections.binary_search(arr, target)
3
AlgorithmsCollection.binary_pivot_searchFunction
binary_pivot_search(array::Array{Int64,1}, target::Int64)

The idea is to find the pivot point for finding the target in an unsorted array. For this reason, the array has to be divided into two subarrays; a binary search is performed on the subarrays.

Arguments

  • array::Array{Int64,1}: Unsorted array of integers
  • target::Int64: Target-value to find the position

Examples

julia> import ClassicAlgorithmsCollections
julia> arr = [2, 5, 4, 7, 2, 8, 9, 3, 10, 2]
julia> target = 3
julia> ClassicAlgorithmsCollections.binary_pivot_search(arr, target)
8
Missing docstring.

Missing docstring for closest_pair_search. Check Documenter's build log for details.

AlgorithmsCollection.interpolation_searchFunction
interpolation_search(array::Array{Int64,1}, target::Int64)

The Interpolation search algorithm (ISA) finds a target-position in a sorted array by using a numerical procedure. The sorting procedure uses a linear fitting for finding the target position of the remaining search space in the array in more detail. The array's target position is calculated by the straight slope between the lowest and largest boundary of the remaining array and the lowest array position itself during each optimization cycle. If the target-position cannot be found, the array-space will be shrink for the lower or higher boundary region based on a comparison. For more information see: https://en.wikipedia.org/wiki/Interpolation_search

Arguments

  • array::Array{Int64,1}: Sorted array of integers
  • target::Int64: Target-value to find the position

Examples

julia> import ClassicAlgorithmsCollections
julia> arr = [10,11, 12, 14, 16, 18, 19, 20, 21, 22, 23, 24, 33, 35, 42, 47]
julia> target = 12
julia> ClassicAlgorithmsCollections.interpolation_search(arr, target)
3

Array-Sorting

AlgorithmsCollection.bubble_sortingFunction
bubble_sorting(array::Array{Int64,1})

The Bubble sorting algorithm (BSA) is a primitive sorting algorithm that repeatedly steps through the array by using a double for-loop with n and n-1 size. During the walkthrough, the BSA compares adjacent elements and swaps wrong ordered elements until the array is sorted. For more information see: https://en.wikipedia.org/wiki/Bubble_sort

Arguments

  • array::Array{Int64,1}: Unsorted array of integers

Examples

julia> import ClassicAlgorithmsCollections
julia> arr = [64, 34, 25, 12, 22, 11, 90]
julia> ClassicAlgorithmsCollections.bubble_sorting(arr)
[11, 12, 22, 25, 34, 64, 90]
AlgorithmsCollection.insertion_sortingFunction
insertion_sorting(array::Array{Int64,1})

The insertion sorting algorithm builds the final sorted array by inserting elements that are greater than the key, to one position ahead of their current position step one item at a time. For more information see: https://en.wikipedia.org/wiki/Insertion_sort

Arguments

  • array::Array{Int64,1}: Unsorted array of integers

Examples

julia> import ClassicAlgorithmsCollections
julia> arr = [64, 34, 25, 12, 22, 11, 90]
julia> ClassicAlgorithmsCollections.insertion_sorting(arr)
[11, 12, 22, 25, 34, 64, 90]
AlgorithmsCollection.heap_sortingFunction
heap_sorting(array::Array{Int64,1})

As a comparison-based sorting algorithm, the heapsort algorithm (HSA) divides its input into a sorted and an unsorted region, and it iteratively shrinks the unsorted region by extracting the largest element from it and inserting it into the sorted region. A specialty is that the HSA keeps the unsorted region in a heap data structure to find the largest element in each step more quickly. In more detail, in the first part of the HSA (while-loop), the largest value has to be found and set to position one. In the second part of the HSA (while-loop), the array's first and largest value has to be swap to the last index of the array, and the swapping-procedure starts again for a new interval n-1. For more information see: https://en.wikipedia.org/wiki/Heapsort

Arguments

  • array::Array{Int64,1}: Unsorted array of integers

Examples

julia> import ClassicAlgorithmsCollections
julia> arr = [64, 34, 25, 12, 22, 11, 90]
julia> ClassicAlgorithmsCollections.heap_sorting(arr)
[11, 12, 22, 25, 34, 64, 90]
AlgorithmsCollection.merge_sortingFunction
merge_sorting(array::Array{Int64,1})

The merge sort algorithms (MSA) are a comparison-based sorting algorithm, which is referred to as the divide and conquer algorithms. The stable sort implementation is a widely used method for the MSA, which means that the order of equal elements is the same in the input and output. In the current implementation, a top-down implementation is used; however, a Bottom-up implementation can be used, too. In the top-down implementation, the MSA recursively splits the array into subarrays until the subarray size is < 2, merging those subarrays to produce a sorted array by using a new function merge. The back copying is blocked by alternating the direction of the merge with each recursion. For more information see: https://en.wikipedia.org/wiki/Merge_sort

Arguments

  • array::Array{Int64,1}: Unsorted array of integers

Examples

julia> import ClassicAlgorithmsCollections
julia> arr = [64, 34, 25, 12, 22, 11, 90]
julia> ClassicAlgorithmsCollections.merge_sorting(arr)
[11, 12, 22, 25, 34, 64, 90]
AlgorithmsCollection.quick_sortingFunction
quick_sorting(array::Array{Int64,1}, low = nothing, high = nothing)

The quick sort algorithm (QSA) works by selecting a pivot element from the array and partitioning the other elements into two subarrays, according to whether they are less than or greater than the pivot-window. Then the sorting of subarrays is recursively organized. This procedure repeatedly happens until each subarray is organized; consequently, the subarrays' merging is an organized array. For more information see: https://en.wikipedia.org/wiki/Quicksort#Parallelization

Arguments

  • array::Array{Int64,1}: Unsorted array of integers
  • low::Int64: Lowest index of the unsorted array or subarray
  • high::Int64: Highes index of the unsorted array or subarray

Examples

julia> import ClassicAlgorithmsCollections
julia> arr = [64, 34, 25, 12, 22, 11, 90]
julia> ClassicAlgorithmsCollections.quick_sorting(arr)
[11, 12, 22, 25, 34, 64, 90]