GeekInterview.com
   Home |  Tech FAQ  |   Interview Questions |  Placement Papers |  Tech Articles |  Learn |  Freelance Projects |  Online Testing |  Geeks Talk |  Job Postings |  Knowledge Base | Site Search |  Add/Ask Question

GeekInterview.com  >  Interview Questions  >  Programming  >  C
Go To First  |  Previous Question  |  Next Question 
 C  |  Question 19 of 438    Print  
What is the quickest sorting method to use?
The answer depends on what you mean by quickest. For most sorting problems, it just doesn’t matter how quick the sort is because it is done infrequently or other operations take significantly more time anyway. Even in cases in which sorting speed is of the essence, there is no one answer. It depends on not only the size and nature of the data, but also the likely order. No algorithm is best in all cases.
There are three sorting methods in this author’s “toolbox” that are all very fast and that are useful in different situations. Those methods are quick sort, merge sort, and radix sort.
 
The Quick Sort
The quick sort algorithm is of the “divide and conquer” type. That means it works by reducing a sorting
problem into several easier sorting problems and solving each of them. A “dividing” value is chosen from the input data, and the data is partitioned into three sets: elements that belong before the dividing value, the value itself, and elements that come after the dividing value. The partitioning is performed by exchanging elements that are in the first set but belong in the third with elements that are in the third set but belong in the first Elements that are equal to the dividing element can be put in any of the three sets—the algorithm will still work properly.
 
The Merge Sort
The merge sort is a “divide and conquer” sort as well. It works by considering the data to be sorted as a
sequence of already-sorted lists (in the worst case, each list is one element long). Adjacent sorted lists are merged into larger sorted lists until there is a single sorted list containing all the elements. The merge sort is good at sorting lists and other data structures that are not in arrays, and it can be used to sort things that don’t fit into memory. It also can be implemented as a stable sort.
 
The Radix Sort
The radix sort takes a list of integers and puts each element on a smaller list, depending on the value of its least significant byte. Then the small lists are concatenated, and the process is repeated for each more significant byte until the list is sorted. The radix sort is simpler to implement on fixed-length data such as ints.
 


  
Total Answers and Comments: 1 Last Update: April 19, 2007   
  
 Sponsored Links

 
 Best Rated Answer

No best answer available. Please pick the good answer available or submit your answer.
April 19, 2007 04:52:27   #1  
agni_suresh896 Member Since: November 2005   Contribution: 1    

RE: What is the quickest sorting method to ...
The algorithms which follows divide and qunquer technique provides fastest implementation.

 
Is this answer useful? Yes | No

 Related Questions

The answer is the standard library function qsort(). It’s the easiest sort by far for several reasons: It is already written. It is already debugged. It has been optimized as much as possible (usually). 
Latest Answer : Greetings!can u plz explain me the sorting function with its implementation in a small program and send it to my e-mail Id : venki_m182003@yahoo.com ...

The answer depends on what you mean by quickest. For most sorting problems, it just doesn’t matter how quick the sort is because it is done infrequently or other operations take significantly more 
Latest Answer : The algorithms which follows divide and qunquer technique provides fastest implementation. ...

A sorting program that sorts items that are on secondary storage (disk or tape) rather than primary storage (memory) is called an external sort. Exactly how to sort large data depends on what is meant 
Latest Answer : Any how after merging that it will create the same problem to sort out. Will you please explain about that? ...

Just as qsort() was the easiest sorting method, because it is part of the standard library, bsearch() is the easiest searching method to use. If the given array is in the sorted order bsearch() is the 

A binary search, such as bsearch() performs, is much faster than a linear search. A hashing algorithm can provide even faster searching. One particularly interesting and fast method for searching is to 
Latest Answer : quick short method is a best one ...

To hash means to grind up, and that’s essentially what hashing is all about. The heart of a hashing algorithm is a hash function that takes your nice, neat data and grinds it into some random-looking 
Latest Answer : hash is actually using a maping function to map the items to keys,  if two different items map to one key, a collision solution is needed. ...

Both the merge sort and the radix sort are good sorting algorithms to use for linked lists.  
Latest Answer : For this no need to write sepate function. We can arrage the elements in order by using some comaprisons in creation of list.venkatesh_ch@fastmail.fm ...

The preprocessor will include whatever file you specify in your #include statement. Therefore, if you have the line  #include in your program, the file macros.inc will be included in 
Latest Answer : no ...

Using the #define method of declaring a constant enables you to declare a constant in one place and use it throughout your program. This helps make your programs more maintainable, because you need to 
Latest Answer : When you define constant variable there is possiblity that it's value may get changed in the program accidently by use of say pointer, but if you define constant by #define it's value can't be changed. This is also one of the benifit ...

The use of an enumeration constant (enum) has many advantages over using the traditional symbolic constant style of #define. These advantages include a lower maintenance requirement, improved program 


 Sponsored Links

 
Related Articles

jQuery Completed sorting and paging code

Learning jQuery The Finished Code The completed sorting and paging code in its entirety follows mosgoogle geshibot lang php" fn alternateRowColors function tbody tr odd this removeClass even addClass odd ; tbody tr even this removeClass odd addClass even ; return this; ; document
 

jQuery - Sorting Other Types of Data

Learning jQuery Sorting Other Types of Data Our sort routine should be able to handle not just the Title and Author columns but the Publish Dates and Price as well Since we streamlined our comparator function it can handle all kinds of data but the computed keys will need to be adjusted for other da
 

jQuery - Basic Alphabetical Sorting

Learning jQuery Basic Alphabetical Sorting Now let s perform a sort on the Title column of the table We ll need a class on the table header cell so that we can select it properly geshibot lang html" Title Author s Publish Date Price geshibot mosgoogle To perform the actual s
 

jQuery - JavaScript Sorting

Learning jQuery JavaScript Sorting There are times though when we either don t want to wait for server responses when sorting or don t have a server side scripting language available to us A viable alternative in this case is to perform the sorting entirely on the browser using JavaScript client sid
 

jQuery Sorting

Learning jQuery Sorting In this chapter we will use jQuery to apply techniques for increasing the readability usability and visual appeal of tables though we are not dealing with tables used for layout and design In fact as the web standards movement has become more pervasive in the last few years t
 

Concepts of Object-Oriented Programming

Object Oriented JavaScript In this chapter you ll learn about OOP Object Oriented Programming and how it relates to JavaScript As an ASP NET developer you probably have some experience working with objects and you may even be familiar with concepts such as inheritance However unless you re already a
 

What is Common Data Modeling Method

Common Data Modeling is one of the core considerations when setting up a business data warehouse. Any serious company wanting to have a data warehouse will have to be first serious about data models. Building a data model takes time and it is not unusual for companies to spend two to five years just
 

SQL Programming

SQL Programming Overview Anybody who has done something for a long time has probably wanted to change how things work at some point or another. A worker at a mill might have found a more efficient way of cutting logs, or a mathematics teacher might have had a hand in changing a school’s al
 

The Interview Snafu

How to turn someone else’s mistake to your advantage Your dream job is about to become reality. A recruiter gave you the heads up about the perfect position at Humungous Conglomerate, Inc. You went through five interviews as well as a battery of psychological tests mandated by their HR de
 

Winning a Job Interview with a Winning Resume

Does your resume unlock your potential, take your skills to the highest level and win you the interview and the job you want now? The job market today is highly competitive and even if you think you have what it takes to get an interview you won’t get over the line without a polished, prof
 





About Us  |   Privacy Policy  |   Terms and Conditions  |   Contact  |   Site Map  |   Add Question  |   Propose Category  |   RSS Feeds  |   Articles Sitemap  |   Site Updates  |   Add Resource

Copyright © 2005 - 2008 GeekInterview.com. All Rights Reserved
Page copy protected against web site content infringement by Copyscape