Re: Detailed explanation of how a QuickSort Works
- From: "Mike Williams" <mikea@xxxxxxxxxxxxxxxxx>
- Date: Sun, 8 Apr 2007 10:07:14 +0100
"Paul MH" <paulmorrishill@xxxxxxxxxxxxxx> wrote in message news:1175984924.860130.30740@xxxxxxxxxxxxxxxxxxxxxxxxxxxxxxx
The reason i dont use code that i dont understand is that, lets say
im doing a project for a course and someone asks me to explain
what this does and i say "I dont know i didnt write it" that wouldnt
be very good.
I applaud your attiutude, but I think you perhaps missed the "it's only half a joke" phrase in my response. I do understand that in an academic environment you need to be able to show that you understand all of the code you write, but the point I was making is that "in the real world" people often use code that they don't really fully understand and they treat such code merely as a "black box" where all they really know is the output which is generated by any specific item of input. And even in the academic world you must often accept the simple fact of life that it is actually totally impossible for any one person to know everything. For example you might write some code to play an mp3 song, perhaps something like the following:
Static player1 As Object
Set player1 = New FilgraphManager
player1.RenderFile "c:\bad moon rising.mp3"
player1.Run
Most people (including myself) do not *really understand* the above code. All they really know is that if you use the RenderFile method of player1 on a valid mp3 file (or other valid media file) and then use the Run method then the song will play. But actually loading the data from the mp3 file from the disk and analyzing that data and decompressing it and arranging to stream it in a way that causes the song to be played through your speakers is a fairly complicated task, and almost all programmers will happily leave all that "knowledge" safely in the hands of the Player1 object (in the above code) and will treat it merely as a "black box" in the way I mentioned above. So, having accepted that it is simply not possible to know everything, many people sometimes take that a little step further and actually use certain sometimes very large blocks of VB code which they did not themselves write and which they do not themselves totally and fully understand, and they use them in their own programs on the same "black box" principle. They don't always do this of course, and they don't really like doing it, but they sometimes do it nonetheless. Otherwise, if they always allow themselves to be led down the path of making sure they fully and totally understand every single line of code they use, they will spend so much time on the project that they simply will not make any money out of it! And in the commercial world, making money is of course by far the most important thing! Once you step out into the commercial world you no longer have the luxury of the "ivory towers" way of looking at things. I suppose it is sad, in a way, but it is a fact of life. By the way, in order for the above code to work you will need to set a reference to the quartz.dll (the ActiveMovie Control type library).
thanks again this has really helped me. i did a search through my
hard drive for files, it found 91,144 files and order them by size in
about 4 seconds (these are arrays with types) whereas before the
same proccess would have taken over 40 minutes
You're welcome. By the way, when sorting a large number of strings (especially strings of varying lengths) you will find it very much quicker to modify your sort routine so that it sorts "Long pointers" to the strings rather than sorting the string data itself. This is generally referred to as an "Index Sort". It won't speed up your own drive searching code very much (because a lot of the time in that specific code is spent drilling through the file data on the disk or in the disk buffer and that time will still be required) but in general it can increase the speed of standard string sorts quite a lot.
Mike
.
- Follow-Ups:
- Re: Detailed explanation of how a QuickSort Works
- From: Paul MH
- Re: Detailed explanation of how a QuickSort Works
- References:
- Detailed explanation of how a QuickSort Works
- From: Paul MH
- Re: Detailed explanation of how a QuickSort Works
- From: Mike Williams
- Re: Detailed explanation of how a QuickSort Works
- From: Paul MH
- Detailed explanation of how a QuickSort Works
- Prev by Date: Re: Concatenating control names
- Next by Date: Re: Concatenating control names
- Previous by thread: Re: Detailed explanation of how a QuickSort Works
- Next by thread: Re: Detailed explanation of how a QuickSort Works
- Index(es):
Relevant Pages
|
Loading