Monday, May 24, 2010

Microsoft visual c++ programs?

how do i create a Microsoft Visual C++ program that would use sequential sorting if i want to display the numbers defined by any user in ascending order and bubble sorting if the user wants to display the numbers in descending order?

Microsoft visual c++ programs?
check out http://www.pscode.com for great sample codes.
Reply:Here are a couple of good websites to check out.


http://www.codeproject.com


http://www.codeguru.com


I am sure if you searched those sites, you will find a bunch of sorting algorithims.


They usually distribute both the executable file and the source files.


You probably have to register in order to download, but it is free.
Reply:Don't use a bubble sort. It is the second slowest sort there is. (The only slower one that I know of is the serial search sort.)


Even the shell sort in Kerningham and Ritchie's C manual is almost reasonable. It is 4-5 lines of code so even if you duplicate it for ascending and descending it is quite reasonable to use.


Note: You can usually get rid of the slow divide by 2 with a bitwise right-shift %26gt;%26gt;


No comments:

Post a Comment