answersLogoWhite

0

Why is sorting is important?

Updated: 9/24/2023
User Avatar

Wiki User

9y ago

Best Answer

Sorting algorithms are important because searching for data is more efficient when the data is in sorted order. For instance, if we have data that can be sorted by a key value, we can locate the data associated with a key much more quickly if we start in the middle. If the key is there then we're done, otherwise we compare the keys to determine which half of the data contains our key, and disregard the other half completely. We then repeat the process with the remaining half, reducing the number of elements we need to search by half each time. Eventually, we will either find our key or there will be no elements left to search, in which case the key does not exist. This is much quicker than searching every element from first to last. In terms of complexity, the latter takes O(n) time to determine that a key does not exist (the worst case), whereas the former would take O(log n) time, which is substantially faster.

Sorting algorithms are also important because they teach us how to write efficient algorithms. Humans are creatures of habit and when tasked with sorting things we usually use the same simple methods. For instance, for a small set of data we might take the first two elements and sort them, then insert the third in its proper place, then the fourth, and so on. This technique approximates the insertion sort algorithm. For larger sets we might choose to divide the set into smaller sets, sort each of them individually, then repeatedly examine the top elements, taking the smallest each time and placing it in a new set. This is fairly similar to the merge algorithm. By expressing these actions as an algorithm we can test them to determine which is the most efficient.

We also have to take into account the stability of the algorithm. A stable sort keeps equal items in the same order they were input. This requirement may make the algorithm less efficient. Similarly, we must take into account whether the algorithm can be executed in place or whether auxiliary memory is required. An in place sort uses memory more efficiently but may sacrifice performance. This can be important when sorting disk-based arrays that are too large to fit into memory. Moving data around in memory is easier to achieve than moving data around on disk, thus it is often necessary to sacrifice disk space to maintain performance.

User Avatar

Myrtis Lang

Lvl 10
1y ago
This answer is:
User Avatar

Add your answer:

Earn +20 pts
Q: Why is sorting is important?
Write your answer...
Submit
Still have questions?
magnify glass
imp
Related questions

What is The sorting out of important and unimportant sounds called?

recognition


Why is sorting important when recycled?

so they will not mix up . Or if we sort it will not be so much garbage


Is selection sort internal sorting or external sorting?

internal sorting ..............Kaleem


Using only one program implement bubble sorting insertion sorting quick sorting and selection sorting?

Its simple!dirve a menu based prog by using switch case & then apply every sorting function to it.


What is a arranging characters in alphabetical order?

Sorting


What is Latin word for sorting?

diribitio and it translates to "sorting of the"


How tall is Mats Sorting?

Mats Sorting is 175 cm.


What method would you use to separate beans and buttons?

Hand sorting


Types of sorting in 8085 microprocessor?

Sorting is not a microprocessor specific thing. Sorting requires a program and, as such, is not dependent on which microprocessor is involved.


What are factors to consider when choosing sorting method?

There are lots of factors to consider. Some important ones are what are the best, worst, and average times it will take for the sorting method to complete given a certain amount of elements to sort. Also important is how much memory the algorithm will use, what he distribution of the data it is working on is, and whether you want the algorithm to ensure that if stopped part way though sorting that the data is not in a less sorted state than when it started.


What is sorting animals called?

The act of sorting animals is called Classification


What is internal and external sorting techniques?

Internal sorting it means we are arranging the number within the array only which is in computer primary memory. External sorting it is the sorting of numbers from the external file by reading it from secondary memory.