Post #109,086
7/10/03 6:52:56 PM
|
Phew
Eons ago when I was a baby C programmer my company would give C tests to applicants. The final question was to implement a sort program. Not to call qsort(), but to actually write the full implementation. If you did a bubble sort they laughed you out of the office. Shell and Quicksorts were acceptable. Are there any others commonly used? I dunno. I used to.
I was just learning C, after being hired as tech support, so I didn't have to suffer though it.
|
Post #109,091
7/10/03 7:22:08 PM
|
This may be too harsh
for a junior coder.
I would provide the algorithm, and ask him/her to code it. Or ask how quicksort works, on paper.
But not both.
In fact, I am pretty sure I can't code proper quicksort in a hurry. That's what books/compilers/debuggers/unitttests are for.
--
Less Is More. In my book, About Face, I introduce over 50 powerful design axioms. This is one of them.
--Alan Cooper. The Inmates Are Running the Asylum
|
Post #109,108
7/10/03 8:59:35 PM
|
Exactly
I would ask
What is an exact equivalent syntax to *(*(A+m) + n) not using asterisks?
I think pressure programming proves nothing. It's like a hotdog eating contest. I would stress theoretical aspects of the language and how it fits together to make programs, calling library functions, proper division between headers and code etc. If you understand the implications of the language then you will at worst be a sloppy implementor.
-drl
|
Post #109,188
7/11/03 8:41:33 AM
|
This is not "pressure programming"
This is an ansient and venerable algorithm of removing elements that match certain criterion from an array. Expressed in the candidate's language of choice (English for Barry).
Your example, on the other hand, is extremely C-dependent, not algorithmic at all.
--
Less Is More. In my book, About Face, I introduce over 50 powerful design axioms. This is one of them.
--Alan Cooper. The Inmates Are Running the Asylum
|
Post #109,198
7/11/03 9:27:10 AM
|
Yes, precisely
A monkey can implement and algorithm (place box, step on, retrieve banana). What you want is real understanding of the semantics of the medium at hand. IMO.
-drl
|
Post #109,206
7/11/03 9:57:31 AM
|
That particular algorithm has been really successful
at weeding out people with no understanding of medium whatsoever. For the rest, there are other tests.
--
Less Is More. In my book, About Face, I introduce over 50 powerful design axioms. This is one of them.
--Alan Cooper. The Inmates Are Running the Asylum
|
Post #109,334
7/11/03 7:49:40 PM
|
They did not do this to juniors
Like I said, they didn't do it to me.
But this was in the days of pre-ANSI K&R C. Very limited libraries. Very few coders. Using "real" Unix or original Tandy 6000 Xenix.
There were far fewer candidates in those days, and they were of much higher quality than now, simply because the barriers to entry were far higher.
It was not too much too ask then.
It would be now.
|
Post #109,105
7/10/03 8:53:22 PM
|
Re: Phew
Did you give the algorithm?
-drl
|
Post #109,144
7/11/03 12:00:29 AM
|
Insertion Sort
Many systems, it seems, use an "insertion sort", especially when I was in the mainframe world.
Insertion sort basically takes an "old" data set, and builds a "new" data set by inserting the records in order. The "old" unsorted set still remained, until the next job step deleted it.
It was pretty fast.
Glen Austin
|
Post #109,172
7/11/03 3:51:27 AM
|
Merge Sort is better
and I think really common in the mainframe world - because you can use it with tape drives if you have to and can sort enormous datasets in very little extra space with great speed.
"One of the main causes of the fall of the Roman Empire was that, lacking zero, they had no way to indicate successful termination of their C programs." -- Robert Firth
|
Post #109,170
7/11/03 3:37:19 AM
|
What a waste of time
I can't remember how to do a qsort. I'd have to look it up. I vaguely recall finding a pivot and then recursively sorting the sublists on either side of it.
I got the same thing on an interview the other day. Wanted to know how to write a server that listened on a socket and forked requests into different threads. I said you do something like open, then select or poll or something like that to wait for the connection and I can't remember exactly but this is boilerplate code I can find on the web or in any basic unix network programming manual.
Seemed to satisfy him. After all, its true.
"One of the main causes of the fall of the Roman Empire was that, lacking zero, they had no way to indicate successful termination of their C programs." -- Robert Firth
|
Post #109,212
7/11/03 10:24:03 AM
7/11/03 10:25:16 AM
|
I think qsort is a bad example.
I only now have an idea how it works because I've read that chapter in my Algorithms book several times!
Wade.
Is it enough to love Is it enough to breathe Somebody rip my heart out And leave me here to bleed
| | Is it enough to die Somebody save my life I'd rather be Anything but Ordinary Please
| -- "Anything but Ordinary" by Avril Lavigne. |
Edited by static
July 11, 2003, 10:25:16 AM EDT
|
Post #109,219
7/11/03 10:42:47 AM
|
I'm trying hard to recall
...the last time I wrote code to sort anything. Been years now. "ORDER BY", anyone? ;)
I'm gonna go build my own theme park! With Blackjack! And hookers! In fact, forget the park!
|