Interesting and funny sort- BOGO SORT

Interesting and funny sort- BOGO SORT

Β·

2 min read

You might have learned about Sorting and its different types like merge sort, quick sort, bubble sort, selection sort and others... but today we have a Bogo Sort?

Yes, in this article we are going to learn about bogo sort... which most of you might be unfamiliar.

Bogo Sort?

De-optimizing Sorting Algorithms to O(∞) | by Kevin Feng | Star Gazers |  Medium

Bogo Sort, often dubbed as "stupid sort" or "monkey sort," is a whimsical algorithm that epitomizes chaos rather than order.

Unlike its efficient counterparts, Bogo Sort takes a drastically different approach – it shuffles the elements of an array randomly and checks if they are sorted.

Imagine sorting a deck of cards. Bogosort's approach is like shuffling the deck repeatedly, checking if it's sorted after each shuffle.

If not, shuffle again and repeat until, by some cosmic coincidence, the cards happen to be in order.

Simple meaning if you didn't understand,

Like, we do in Bubble sort, we keep sorting one part as sorted and keep moving and incrementing the value of i as variable in for loop,

similarly bogo sort, keep taking random jumps and without taking care of the loop.

Algorithmic Madness:

Second Take: TikTok's algorithmic madness forces artists to focus on  short-lived virality - Daily Bruin

Sorry, we are using this word

but Bogo sort deserves it πŸ˜† just joking guys..

The steps of Bogo Sort are deceptively simple:

  1. Randomly shuffle the elements of the array.

  2. Check if the array is sorted.

  3. If sorted, stop; if not, repeat step 1.

Theoretical Analysis:

The time complexity of Bogo Sort is notoriously difficult to analyze due to its unpredictable nature.

On average, the algorithm's performance is abysmal, with an expected time complexity of O((n+1)!), where 'n' is the number of elements in the array.

This exponential time complexity implies that Bogo Sort becomes exponentially slower as the size of the input array increases.

Real-World Applications:

10,000+ Free Machine & Technology Images - Pixabay

Unsurprisingly, Bogo Sort has almost no real-world applications.

Its inefficiency renders it unsuitable for any important computer jobs that need precise and fast sorting of massive datasets.

Despite its impracticality, Bogo Sort is an interesting thought exercise and a cautionary story about the value of algorithmic efficiency.

Hope you loved this BlogπŸ’–

Follow for more such blogs

Don't forget to follow me on:

Twitter And LinkedIn

Β