Skip to content

jaredblumer/js-algorithms

Repository files navigation

Sorting and Search Algorithms in JavaScript

Welcome to the Sorting and Search Algorithms repository! This repository provides examples of various sorting and search algorithms implemented in JavaScript.

Table of Contents

Sorting Algorithms

Bubble Sort is a simple sorting algorithm that repeatedly steps through the list, compares adjacent elements and swaps them if they are in the wrong order.

  • Time Complexity: O(n^2)
  • Space Complexity: O(1)

Selection Sort divides the input list into two parts: the sublist of items already sorted, which is built up from left to right at the front (left) of the list, and the sublist of items remaining to be sorted that occupy the rest of the list.

  • Time Complexity: O(n^2)
  • Space Complexity: O(1)

Insertion Sort builds the final sorted array one item at a time. It is much less efficient on large lists than more advanced algorithms such as quicksort, heapsort, or merge sort.

  • Time Complexity: O(n^2)
  • Space Complexity: O(1)

Merge Sort is an efficient, stable, comparison-based, divide and conquer sorting algorithm. Most implementations produce a stable sort, meaning that the implementation preserves the input order of equal elements in the sorted output.

  • Time Complexity: O(n log n)
  • Space Complexity: O(n)

Search Algorithms

Linear Search is a method for finding an element within a list. It sequentially checks each element of the list until a match is found or the whole list has been searched.

  • Time Complexity: O(n)
  • Space Complexity: O(1)

Binary Search is a fast search algorithm with a time complexity of O(log n). This search algorithm works on the principle of divide and conquer. For this algorithm to work, the data collection should be in a sorted form.

  • Time Complexity: O(log n)
  • Space Complexity: O(1)

Author

Jared Blumer, Full-Stack Software Engineer and Data Analyst

License

This project is licensed under the MIT License.

About

Implementations of Sorting and Search Algorithms in Javascript

Resources

Stars

Watchers

Forks

Releases

No releases published

Packages

 
 
 

Contributors