Gunnar Peipman's ASP.NET blog

ASP.NET, C#, SharePoint, SQL Server and general software development topics.

Sponsors

News

 
 
 
DZone MVB

Links

Social

Testing sorting algorithms

Some time ago I had to deal with sorting algorithms. Besides my main task I found a good way how to test custom sorting algorithms. This blog entry is one of early birds, more about sorting algorihtms is coming soon. Hopefully some time after TechEd 2007 for Developers. The procedure I wrote to test sorting algorithms is simple and works. Of course, I am always opened for better ideas if somebody wants to suggest some. Here's the little overview about what I've done.

 

NB! This blog is moved to gunnarpeipman.com

Click here to go to article

Comments

Petar Petrov said:

What will happen if the array contains duplicates ? Your IsSorted() method will return false and for me the array {1,2,2,2,3} is sorted.

I think you need to change the comparision from

(array[i - 1].CompareTo(array[i]) > 0) to

(array[i - 1].CompareTo(array[i]) >= 0).

# October 29, 2007 5:32 AM

DigiMortal said:

Thanks Petar, it was my bug. Now it is fixed :)

# October 29, 2007 6:33 AM