Search icon CANCEL
Arrow left icon
Explore Products
Best Sellers
New Releases
Books
Videos
Audiobooks
Learning Hub
Conferences
Free Learning
Arrow right icon
Arrow up icon
GO TO TOP
Hands-On Data Structures and Algorithms with JavaScript

You're reading from   Hands-On Data Structures and Algorithms with JavaScript Write efficient code that is highly performant, scalable, and easily testable using JavaScript

Arrow left icon
Product type Paperback
Published in Jan 2018
Publisher Packt
ISBN-13 9781788398558
Length 332 pages
Edition 1st Edition
Languages
Arrow right icon
Author (1):
Arrow left icon
Kashyap Mukkamala Kashyap Mukkamala
Author Profile Icon Kashyap Mukkamala
Kashyap Mukkamala
Arrow right icon
View More author details
Toc

Sorting and Its Applications

Sorting is a very common algorithm that we use to rearrange a list of numbers or objects in an ascending or descending order. A more technical definition of sorting is as follows:

In computer science, a sorting algorithm is an algorithm that puts elements of a list in a certain order.

Now, let's assume that you have a list of n items, and you want to sort them. You take all the n items and determine all the possible sequences in which you can place these items, which, in this case, would be n! in total. We now need to determine which of these n! series does not have any inverted pairs to find out the sorted list. An inverted pair is defined as a pair of elements whose position in the list is represented by i, j where i < j, but the values xi > xj.

Of course, the preceding method is tedious and requires some heavy computation...

lock icon The rest of the chapter is locked
Register for a free Packt account to unlock a world of extra content!
A free Packt account unlocks extra newsletters, articles, discounted offers, and much more. Start advancing your knowledge today.
Unlock this book and the full library FREE for 7 days
Get unlimited access to 7000+ expert-authored eBooks and videos courses covering every tech area you can think of
Renews at €18.99/month. Cancel anytime