Selection sorting technique

Let me ask you a question, are you someone who keeps forgetting the selection sorting technique?
When someone asks you to write a logic for the selection sort, you go blank and get confused with how to use the selection sorting technique to solve a given problem?

let me tell you a story

When I was in fifth grade, they shuffle class based on scores after each test. Sixty of us are sitting in a class and the teacher will distribute scorecards to all of us. The class is arranged from lowest to highest to focus more on the low scorer.

How does he get the lowest scorer?

In a class of 60 and going through each of the scorecards figuring out the lowest is very hard. He did a technique here, he considered the lowest one to be the first one sitting in a class and asked each one from the beginning.

Is your score less than 50? which is Praneeth’s score, one who is sitting in the beginning. The next guy was Akash and he said YES.
Now Akash became the lowest scorer in the class and it continued until he arranged according to his need.To arrange it took him around 60 minutes. It wasn’t the same as the earlier class. In an earlier class, he was able to do it in 15 minutes.

Why so? he started thinking.

After sometimes he was able to find what was wrong.
In an earlier class, his effort was less. The class was almost in the order he wanted.

Which algorithm did he use? I want you to think for a moment.







He used selection sort.

What did we learn from a story?

When he needs to arrange the entire class, it took him O(n2) but the earlier class wasn’t the same. It took him O(1) time to arrange, when class was already in a order.
When you have more data to arrange the selection sort is inefficient. The teacher thought this is inefficient. He used another technique next time. Which I will write in the next article.

Thank you
Akshitha H.




Software developer, feminist,exploring new technologies

Love podcasts or audiobooks? Learn on the go with our new app.

Recommended from Medium

Plotting gridded data on a web map: Python and/or Javascript?

Receive Large Files in your Google Drive

✍🏻Industry use Cases of Using Kubernetes 📝

Starting to learn to code after 20 years of procrastinating

How to add a drop shadow to an image in Java

Pros & Cons you must know before using Ruby on Rails for your startup.

AWS ETL: Insert data to a relational database using Glue Job

Get the Medium app

A button that says 'Download on the App Store', and if clicked it will lead you to the iOS App store
A button that says 'Get it on, Google Play', and if clicked it will lead you to the Google Play store
Akshitha Shetty

Akshitha Shetty

Software developer, feminist,exploring new technologies

More from Medium

Learning how to program is easier than you think

The diamond problem in java is coming due to multiple inheritances.

Simple steps to make a full-stack application.

Stand out as a Java Developer with these tips!