Login | Register   
Twitter
RSS Feed
Download our iPhone app
TODAY'S HEADLINES  |   ARTICLE ARCHIVE  |   FORUMS  |   TIP BANK
Browse DevX
Sign up for e-mail newsletters from DevX


advertisement
Search the Tips
Tip Bank > C++ > Algorithms

Algorithms - Page 2

21-40 of 380     Previous     Next
CombSort - A compact routine that sorts data in place
by David B. Ring
CombSort. A compact routine that sorts data in place (no extra memory needed) and runs in approximately O(N log N) time. Not stable (does not preserve original order of records with equal keys). Like InsertionSort, works by taking a key from the right side of the list and comparing it with ...
HeapSort - A compact routine that sorts data in place
by David B. Ring
HeapSort. A compact routine that sorts data in place (no extra memory needed) and is guaranteed to run in O(N log N) time no matter how the input data is arranged. On the down side, it's slower than other N log N sorts (Quick and Merge) and not stable (does not preserve the original order of ...
InsertionSort - A simple routine with minimal overhead
by David B. Ring
InsertionSort. A simple routine with minimal overhead. Should never be used to sort long lists because of its O(N^2) behavior, but is the method of choice for sorting short (5-50 key) lists or long lists that have been mostly sorted by a faster algorithm. InsertionSort is faster than either ...
MergeSort - A stable sort
by David B. Ring
MergeSort. A stable sort (preserves original order of records with equal keys). Like HeapSort, easily adapted to any data type and guaranteed to run in O(N log N) time, but almost twice as fast. On the down side, needs an extra array of N items, but these can be pointers if the keys ...
MSD RadixSort - An algorithm that can achieve O(N) behavior
by David B. Ring
MSD RadixSort. No sort based on comparisons can be faster than O(N log N). RadixSort makes no comparisons and can therefore achieve O(N) behavior. To do this, it examines keys one byte at a time, counting the number of keys that have each possible byte value. The counts are then used to ...
QuickSort—Exploiting the Principle of Exchanging Keys
by David B.
QuickSort, CombSort, and ShellSort all exploit the principle of exchanging keys that are far apart in the list rather than adjacent. QuickSort does this most elegantly and rapidly. The approach is to choose a "pivot" value (ideally, the median key) and then to work from each end of ...
SelectionSort - Short, simple and sloooow
by David B. Ring
SelectionSort. Short, simple and sloooow. This is another O(N^2) sort that should never be used on long lists. Like InsertionSort, it needs no extra memory (in place) and preserves the existing order of records with equal keys. Unfortunately, it's slower, and there's no reason to use it ...
ShellSort - A compact routine that sorts data in place
by David B. Ring
ShellSort. A compact routine that sorts data in place (no extra memory needed) and runs in O(N (log N)^2) time. Not stable (does not preserve original order of records with equal keys). Like InsertionSort, works by taking a key from the right side of the list and comparing it with keys to ...
ShuttleMergeSort - An improved MergeSort
by David B. Ring
2/4/03. The previous version of ShuttleMergeSort failed on very short lists. The code below corrects the problem and eliminates a couple of unnecessary variables. Sorting times for one million random longs, double or strings are 67, 90 and 95 seconds (Excel 2001 / 800 mhz PowerBook / MacOS 10.2.
SortBase - Support sorting routines
by David B. Ring
SortBase - Support sorting routines
Filter Listbox Contents Depending on What Has Been Selected
by Alex Whyte
This is similar to the
A Smart Way to Determine Whether a Year is a Leap Year
by Prasad Haridass
Use the following ...
An Efficient Way to Find Mod Value For Using Mod of Even
by Prasad Haridass
To determine whether a number is divisible by some even number you have to use the Mod operator in VB. The following code is an alternate, faster way of doing ...
Using the Command.Tag Porperty to Enable Buttons
by Paul Fields
Use the Command.Tag property to enable one button to be used for two distinct states (On/Off, True/False). This is helpful for changing filters, modes, etc. It saves screen
Trim Multiple Spaces in a String to a Single Space
by Prasad Haridass
If a string has two or more consecutive spaces, this will bring them down to a single space.
Display a Checked Listbox With Selected Items Only
by Pete Blair
Add 2 list boxes to a form: list1 and list2. Set list1
Using the PaintPicture Method
by Andreas Hillqvist
It is possible to use the PaintPicture Method of the PictureBox or Form by entering different dimensions for source height/width and destination dimensions.
Another Way to Delete Files or Filetypes
by Jan Buskens
This routine uses all the good stuff that FileSystemObject offers. ...
Determine Current User
by Pratibha Gupta
In Windows, the computer can be set up so that many different users can log into the computer. The current user
Use Mid$ to Compose a Big String
by Guoran Xie
The following code is a fast way to compose a big string by using Mid$ function instead of using the concatenating operator. The strings concatenated in a loop are often variable. So use S1 to ...
21-40 of 380     Previous     Next
Sitemap