Home arrow JavaScript arrow Page 2 - Quicksort
JAVASCRIPT

Quicksort


There are different algorithms for sorting an array of strings. Time-critical client applications often use the algorithm called Quicksort, which is very efficient for such applications. This two-part article series takes a close look at writing and using such a function.

Author Info:
By: Chrysanthus Forcha
Rating: 4 stars4 stars4 stars4 stars4 stars / 4
October 20, 2008
TABLE OF CONTENTS:
  1. · Quicksort
  2. · Tutorial Approach
  3. · The Quicksort Algorithm
  4. · Quicksort by Observation
  5. · Computer Implementation

print this article
SEARCH DEVARTICLES

TOOLS YOU CAN USE

advertisement
Quicksort - Tutorial Approach
(Page 2 of 5 )

You can sort an array of strings in ascending order (as in the dictionary) or in descending order (opposite to a dictionary's format). I will consider only the ascending order in this article.

Well, in an array of data (strings), it is possible to have two or more data items (strings) which are the same. So I will use the term “non-decreasing” instead of “ascending” to allow for data items that are the same.

I will first describe the algorithm. Normally, you sort an array of strings, not an array of letters from the alphabet. I use letters from the alphabet to do most of the explanation in this article. At the end of the article, I show how the function works with an array of strings.

After describing the algorithm, I explain how the computer can implement the algorithm. The implementation I give in this article is my own implementation. There are other implementations; I will not talk about those. I then write the function in JavaScript. I explain everything step by step.

We shall sort the following list before we consider strings:

Q, W, E, R, T, Y, U, I, O, P

The counting of array (list) elements is always done from position zero. So in the above list; Q is in position 0; W is in position 1; E is in position 2 and so on with P in position 9. There are 10 elements all together.


blog comments powered by Disqus
JAVASCRIPT ARTICLES

- More Top jQuery Plugins for Menus
- Top jQuery Tutorials for Beginners
- New UI Framework and SDK for JavaScript Rele...
- JavaScript OpenPGP Tool, Node.js 0.6.3 Avail...
- Yahoo Releases Cocktails Language and Develo...
- Customizing jQuery Slideshows: Dynamic Contr...
- Customizing jQuery Slideshows: the animate()...
- Customizing jQuery Slideshows: slideUp() and...
- Customizing jQuery Slideshows: hide() and sh...
- Web Workers: Performing Calculations in Para...
- More Top JavaScript Frameworks and Libraries
- More Dynamic jQuery Styling Techniques
- The Top JavaScript Libraries
- The Top JavaScript Frameworks
- Dynamic jQuery Styling

Dev Articles Forums 
 RSS  Articles
 RSS  Forums
 RSS  All Feeds
Weekly Newsletter
 
Developer Updates  
Free Website Content 
Contact Us 
Site Map 
Privacy Policy 
Support 



© 2003-2012 by Developer Shed. All rights reserved. DS Cluster 4 - Follow our Sitemap
Popular Web Development Topics
All Web Development Tutorials