This repository contains a collection of algorithms implemented in Go.
The binary search algorithm is implemented in the binary_search
package. It performs a binary search on a sorted array to find a target element.
The selection sort algorithm is implemented in the selection_sort
package. It sorts an integer array in ascending order by repeatedly selecting the minimum element from the unsorted portion of the array and placing it in its correct position.
The quicksort algorithm is implemented in the quick_sort
package. It efficiently sorts an integer array by dividing the input into smaller sub-arrays, sorting them recursively, and combining them to obtain the final sorted array.
The merge sort algorithm is implemented in the merge_sort
package. It is a highly efficient sorting algorithm that follows the divide-and-conquer approach. It works by dividing the unsorted array into smaller subarrays, sorting them recursively, and then merging them back together to obtain the final sorted array. Merge sort guarantees a time complexity of O(n log n) and is known for its stability, preserving the relative order of elements with equal values. The algorithm's systematic merging of sorted subarrays makes it a reliable choice for sorting tasks that require stability and consistent performance.
The Breadth-First Search (BFS) algorithm is implemented in the breadth_first_search
package. This algorithm is used to traverse or search a graph or tree in a breadthward motion. It explores all the vertices or nodes of a given level before moving to the next level.