Algorithms

This page showcases various algorithmic concepts and provides examples of how to implement them.

  • Algorithm: Merge Sort

    Merge sort is an efficient sorting algorithm that divides a list into smaller sublists, sorts them, and then merges them back together.

    It works by recursively dividing the list into smaller sublists until each sublist contains only one element. Then, it sorts each sublist individually, and finally merges the sorted sublists into a single sorted list.

    Merge sort has a time complexity of O(n log n) and a space complexity of O(n).

  • Algorithm: Bubble Sort

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

    It works by repeatedly going through the list, comparing adjacent elements and swapping them if they are in the wrong order. This process is repeated until the list is sorted.

    Bubble sort has a time complexity of O(n) and a space complexity of O(1).