DEV Community

Danities Ichaba
Danities Ichaba

Posted on

1 1

Topt 5 sorting algorithms

Sorting algorithms are a set of instructions that takes an array or list as an input and arrange the items into a particular order.

Why sorting algorithms are important?
Since sorting can often reduce the complexity(level of complex) of a problem, it is ah important algorithms in computer science.

  1. Selection Sorting: This sorts an array by repeatedly finding the maximum elements (considering ascending order) from unsorted part and putting it at the beginning.

Selection sort visuals

2 Bubble Sort: This is the simplest sorting algorithms that works by repeatedly swapping the adjacent element they are in wrong order.

Bubble Sort visuals

3 Insertion Sorting: This is the sorting algorithms when the sorted array is build having one item at a time. The array elements are compared with each other sequentially and they are arranged simultaneously in some particular order.

Insertion Sorting Visuals

4 Merge sorting: This is a divide and conquer algorithms it divides the input array into two halves, call itself for the two halves and then merges the two sorted halves.

Merge sorting visuals

5 Quick Sort: Like merge sort, quick Sort is a divide and conquer algorithms. It picks an element as pivot and partition the given array around the picked pivot.

Quick Sort visuals

Top comments (0)

Sentry image

See why 4M developers consider Sentry, “not bad.”

Fixing code doesn’t have to be the worst part of your day. Learn how Sentry can help.

Learn more

👋 Kindness is contagious

Please leave a ❤️ or a friendly comment on this post if you found it helpful!

Okay