- Feature Articles
- CodeSOD
- Error'd
- Forums
-
Other Articles
- Random Article
- Other Series
- Alex's Soapbox
- Announcements
- Best of…
- Best of Email
- Best of the Sidebar
- Bring Your Own Code
- Coded Smorgasbord
- Mandatory Fun Day
- Off Topic
- Representative Line
- News Roundup
- Editor's Soapbox
- Software on the Rocks
- Souvenir Potpourri
- Sponsor Post
- Tales from the Interview
- The Daily WTF: Live
- Virtudyne
Admin
I think that a more relevent question would be to provide a hypothetical situation, say
- I have a list of n elements that are mostly sorted
- Provided a list of elements that need to be sorted after a each of a series of inserts
and then ask how to sort it, or suggest a particular sorting algorithm and ask what would be the benefits/drawbacks of that algorithm and possibly have them suggest a better one.I think this would be a better indication of the ability of the candidate than their ability to use a class library or implement a bubble sort.
Admin
One would, however, the Visible = False on the second slide would make that difficult.
Admin
Duh. You never need it. How many times have you had to write an instant messenger client? How many times have you had to code a network proxy from scratch? How many times have you had to use any of the low level datastructure programming that you had to learn for your degree? (I actuallly do write my own linked lists, oddly...The standard ones in Java are too bloated)
To answer your question, it is not about actually using any such thing, but, instead, to re-enforce the lessons on sorting, as well as making them do a relatively heavy operation on a linked list which will involve a lot of relinking. A nice test of knowledge. If you can sort a linked list, as opposed to an array or some other more pedestrian datastructure, you've mastered some basic material, and should move on in the degree program. If not, you should fail.
Admin
Jeff S, please tell me you laughed (even if it was just a little bit) when you saw the irony in someone misinterpreting your post as being serious when you have been on the other side of the that situation before. :) That would make my day. Thank you.
Admin
Maybe Chris didn't have the $30K per year. And middle class parents that didn't want to foot the bill and didn't qualify for financial aid.
Whitesmiths indentation? Had to look it up ... never taught me indentation styles in college. Guess didn't go to a University on the 'Best' list. Guess I used the BSD/Allman style. Those Allman Brothers could really jam, and code!
http://en.wikipedia.org/wiki/Indent_style
Hmmm ... guess we need to change all of our code to accomodate the handful running programs off of their java powered cell phones in New Guinea. We also need a handicap ramp to the summit of Everest. ;-) Hmmm 11mb, will it be the .net framework or Britanny's latest release? The leads to the philosophical question, if you're laptop was burning down and you could only save 11mb, what would it be?
Admin
Same here. I have a few wtf stories from my university, but nothing like this.
If I were him, I'd ask for a refund. You can get a better education by having a monkey for a teacher.
Admin
Any sort algorithm? I would have used the RandomSort method: randomly rearrange all the data and check to see if it's sorted correctly. If not, rearrange randomly and check again. Repeat until the data are sorted correctly.
Not very fast performance, but very fast to implement.
Admin
You can indeed implement a linked list in VB6 (or even VB4, if you're sufficiently anachronistic) without using a ListBox. You just create a class named Link (or whatever), and create two member variables of type Link, named PreviousLink and NextLink. If PreviousLink is null, then it's the first link in the list; if NextLink is null, it's the last link in the list. To create the linked list, start with the first Link; create a new Link object, set its PreviousLink variable to the first Link (literally set me.PreviousLink = FirstLink) while setting FirstLink's NextLink property to the second Link. Repeat all the way through the list you're trying to create. End of story (EOS).
Admin
Admin
I disagree. The vast majority of programming work very rarely requires you to invent algorithms or do anything ingenious. In fact, ingenious code is BAD if it's not also clear and easy to understand. The single most important quality of a good developer is an impulse to say "wait a second, there must be a better/simple way to do this!" when faced with convoluted, overly complex or verbose code, often in the process of writing it themselves. And for something as basic as sorting, that better/simpler thing is a library call. If you are developing any large project, "free/open thinkers" with a tendency to roll their own are in fact very harmful.
But it's true that in a test environment, it's not necessary obvious what is being asked for. The task should be "while working on a web shop, you find that you have to sort an array of 10000 integers. How would you do this?", in which case a library call is the right answer and any implementation of a sorting algorithm the wrong one.Or "Implement the sorting of an array of 10000 integers, do not assume the availability of any libraries."
Admin
I got asked this question once. Except, it was specifically C++ and specifically std::list. The answer was, of course, std::list::sort(). I don't understand why they told me to do it in 'less than ten lines' though. It only took 1.
Admin
I rather doubt that that's faster to implement than bubble sort or quicksort.
Admin
right then. There goes my theory. Now I have no reason not to cry, at the thought of having to someday work with those graduates.
CAPTCHA: quality. indeed.
Admin
Perfectly stated ..... couldn't agree more.
Admin
If they didn't chuckle at the implementation, I wouldn't want to work there. It's a gag solution to an assignment from one of my first-year classes.
Remember that at an interview, your duties are twofold: First and foremost, determine if the company is the place that you want to work for. Second, prove to the employer that you are the ideal candidate.
Admin
Admin
As further evidence to back your position, I can't think of a single time in the last two years I've been coding at my current job, that I've had to write a sort algorithm. The closest thing I can think of is the time I wrote a longest common substring algo, based on a prototype I found via google.
I could write just about any sort you want, if you give me an hour with a textbook or google. Without, you're not gonna get much better than a bubble sort outta me: I haven't needed to use any of that sort of knowledge since school.
Sure, if I'm going to be working somewhere where that sort of knowledge is vital (why would you ever write a sort more than, at max, one time per project?) then I'll "swap" that info back in to my "main memory". Until then, it's in "long term storage": books and the net.
Admin
not really, it wasn't that funny or ironic I didn't think .... I think many of us have been on "the other side of that situation" before. I mean, have you read some of the comments in this very thread alone? :)
Admin
Every question I ask in an interview has a point. It is meant to test a certain aspect I find desirable in a programmer. In this case, the question is phrased in such as way as to indicate that they can provide ANY solution that they see fit. They are told that if they were to sit down in front of a computer right now and sort this list, how would they do it. In this scenario, I expect them to use the language to it's fullest and use the built in functions.
As for giving higher marks, the test is not graded with a number per sec, but rather used as an overall indicator. If they do very well on the rest of the interview, and bomb this one part, I would not use it as an excuse to not hire them. However, if they were weak on some parts, then this question could be an indication of an overall problem.
There are other questions that are asked that test their knowledge of algorithms, such as when is it ok to use a bubblesort instead of a quicksort. But I would not, as a rule, as a candidate to implement something that is part of a language's library, just to see if they can do it.
Admin
Admin
I don't specifically say STL, but I do let them know that they can use "the libraries". I tell them that if they were to sit down at a machine right now, with the job of sorting this list using C/C++ and it's libraries, how would you do it. In the case where the candidate does bang out a bubblesort, I ask them if there is better way, perhaps with a library function call. If they give me the blank look that I've seen far too often, then I know they aren't acceptable. If they instead get a sheepish look, and jot down the correct syntax to make the standard C or STL call, then they get (mostly) full marks, as they were probably nervous, and misunderstood the question.
The idea is not to confuse them, but to help them get to the right answer, so you can see how they really work. Sometimes they need a slight nudge in the right direction, and other times a bulldozer won't get them there. The good candidates are the ones that require the least nudging.
Admin
I had to look it up last month - somebody here was "infecting" the code with some really weird indentation and I wanted to know WTF was going on.. The Whitesmiths indentation would be a "Ew, pass." condition.
(I use BSD/Allman.)
Okay, more market share for me. ;) I'm just saying that there's a reason why some people still use VS6: It creates significantly smaller programs than VS.NET once you include the VS Framework. Oh, you can also do stuff like use the serial ports and write to files, should you be into that sort of thing. However, I think that's more of a philosophical question than this forum covers.
If my laptop was on fire, I'd just leave the data there to die. There's no point to getting injured for some data that should have been backed up anyway.
Admin
Admin
At my university (the University of York (http://www.york.ac.uk/) our Algorithms and Data Structures course uses Ada as the teaching language - a language without pointers or any of the other dangerous things that C has which makes it confusing to program basic algorithms and data structures in.
Using VB is just silly...
Admin
I feel HR should have a simple VB6 tool that screens for resumes that contain this school and sorts them so they appear at the bottom of the "ListBox UI control" of interview candidates......
Better still it won't be written in VB and it'll just screen for resumes containing this school and mark them permanently as No Hires...or better still v2.0 will just delete them.
Admin
I'll admit that I've used the Listbox sorting design pattern before, although it wasn't for production code but rather an algorithmic proof of concept for Delaunay Triangulation (Given a random grid of points, output the triangular mesh). It's definitely easier to debug a complex algorithm when each step's output is visible. Once the algorithm is proven, it can easily be ported to production code along with optimizations.
Honestly, I can't think of any project where I needed sorting that wasn't available in the language or libraries I was using. That doesn't make the exercise useless in regards to coursework though. What people need to realize is that formal education is a foundation upon which the rest of a career lies. An exercise such as this emphasizes base concepts that can be applied to the myriad of design problems found in real life. During college, my department head told me that formal education perhaps accounted for 20% of all the knowledge required during a career. I personally would say that's optimistic and it's closer to 10% for any field where technology changes rapidly.
Admin
Welcome to the entire point of data structures classes.
A list, vector, and stack are just about the easiest data structures I can conceive of writing. You complaining about it is nearly as big a WTF as the original post. I suppose you expect that compiler courses teach you how to click the "Compile and Run" button in an IDE?
Admin
Okay, you just listed order notation for a few operations on a vector, and on a linked list. Then you asked, what use could a linked list be. Well, let's add another operation: Delete.
On a sorted link list, deletion of a node is O(1). In a vector, it's O(N). Suddenly, a vector doesn't look superior to a linked list in every way possible, which means there's a potential trade-off.
How often this will be useful is another matter--probably not often. But this could in fact make the sorted linked list preferable in certain circumstances, and these circumstances do in fact occur. This is another justification for knowing your data structures.
Back to the general topic--yes, VB6 supports pointers. Just declare an array. An integer that is an index into this array is a pointer. The array itself is what we call memory. You dereference a pointer to this memory by using the name of the array, and passing the pointer as the index. (If you think I'm lying, tell me exactly why I'm wrong, and what the words "pointer" and "memory" really mean--I dare you).
As such, it should be perfectly sufficient to teach data structures properly, especially to a fake princeton professor.
Admin
Like having the lifeguard put a note in a bottle and toss it in the pool. Yes - pool.
Admin
Duh, everyone knows that HTML is the standard abbreviation for Hotmail. Why would you ask a programmer a question about email services?
Admin
If it was correct, and he could justify the additional memory requirements, then it is acceptable, even laudable. But I would grill him/her on whether they felt the risk of introducing their own sorting method, even one that was O(n) was worth the additional time taken. For 10000 integers, quicksort or mergesort is still very quick.
The idea is not to pidgeon hole the developer, but to find out how much they know and what kind of developer they are. Someone who can implement a radix sort correctly (let alone someone who even knows what that is) is likely a good developer. How they justify their solution is also and excellent point to judge them on.
Admin
I still have my COBOL textbook, from the class I took in 1970. The book is virtually brand-new . . .
Admin
http://en.wikipedia.org/wiki/Pointer
"Pointers are so commonly used as references that sometimes people use the word "pointer" to refer to references in general; however, more properly it only applies to data structures whose interface explicitly allows it to be manipulated as a memory address."
I think we can agree that your example does not meet the strictest definition of pointer.
Admin
Nope, but an itnerview can be intended to either show coding competence or problem solving competence, and they lead to very different answers.
The point is that it's useless and therefore probably new to the interviewee, while being simple enough to expect them to grok quickly. It's a great itnerview question, if you're looking for a code question.
Admin
This is the lamest WTF ever posted. Slow day?
Admin
I dunno, knowing how to implement all those sorting algorithms really weighed down my brain. So I drank until they all went away and my brain was light and nimble again.
Admin
So, you're saying you'd prefer stupid progammers?
Admin
I work with a production system that's been using pretty much this approach for years; a number of data files (e.g. lines of a sales order) have the basic record structure (index, header_key, prev_index, next_index, list_of_detail_fields), with prev_index=0 at the head and next_index=0 at the tail, and the header record stores the index of the head.
Admin
Nah, just programmers not so enamored of their talent.
capthca: craptastic
Admin
Nah, looks like he wants drones.
Admin
Admin
But in real life algorithms are rarely that simple. You need a developer that can adapt to that situation using the algorithm techniques that they've learned - e.g. divide and conquer or dynamic programming. You need the developer to look at not only the simplicity of the code, but what it does, and say "there's a better way to do this that takes an order of magnitude less time." You need programmers that realize when what they are working on is an NP-complete problem.
You need a balance: you need a programmer that realizes that what he's trying to implement has already been written, but you need someone who can write it themselves if need be. In any interview, the interviewee will be looking to show off their skills - why hold it against them? If I were an interviewer, I would ask them a follow-up question based on their answer - if they picked "library function" I'd say, "how would you implement this function?"
Someone else said it, but mathematicians/physicists use integral tables and calculators - but they know how to do these things on paper in the absence of these tools. Not directed at the parent post, but a lot of people remind me of those kids in high school who complained that they would never use any fo the stuff they learned in math class.
Admin
Not really--it's all about treatment. Abstraction is key here, especially when teaching a data structures course (there are plenty of VM's to look at--you can bubble sort a deck of cards, implement linked lists on disks, and have memory leaks in java). If memory is your array, and using the name is dereferencing it, then yes--an integer, used as a reference to this memory, is a pointer.
Not that I necessarily trust wiki as a binding authority, but I think its description is pretty fair. The main point I think the wiki artucke is trying to get across, is that handles, hash table keys, etc aren't properly considered pointers. Consider:
1. Integer is a data structure
2. Array is memory (in this case, it's explictely treated as "your memory")
3. Indexing an array (dereference interface) explicitely treats the pointer (integer) as a memory address
Seems to meet all of the requirements to me.
Admin
I see, so a good interview question to ask would be:
Admin
Have you even used VS.Net? VB6 apps are about 7 megs if you need ADO. Admittedly, if you don't need ADO, they're pretty small. But to think that VB6 is better from a functionality perspective is insane. VB6's file IO library is from the 1970s. You can't possibly think that INPUT# is a good thing. I build custom streams all the time to parse files and the stuff that's in the .Net framework is worth hundreds of hours of time savings for me. The serial port and FTP stuff that's sadly missing from the .Net Framework 1.1 isn't really in VB6 either. They're in a few ActiveX controls that can be used from a VB.Net or C# app just as easily as a VB6 app.
There's really very few reasons to ever touch VB6 again other that being too stubborn to learn a new language. If you want small library-free apps, use VC++.Net.
Admin
A good answer would be:
Admin
No, because that wouldn't weed out Slashdot readers.
Admin
Is one of their course titles "Enterprise Development using AJAX"?
Or rather "Enterprisey Development"...LOL
Admin
Actually delete on a sorted-linked-list is O(N) as well. But what I would want to know is why you're wasting time with lists and vectors. If we are talking sort then we are talking balanced trees.
Linked-lists have the advantage of being dynamic, inductive types with O(1) prepend. If you're not taking advantage of this, then you're using the wrong datastructure. While a List.sort method makes sense (for those times you need to sort a list you are using for other reasons), a sorted linked list is just a waste of time.
OTOH, as a filter to avoid wasting time interviewing no-hopers, it's not too bad; better to avoid something that can be pulled directly from the standard library though.
--
List.reverse(Tree.foldin(List.prepend, List.foldl(Tree.insert, list, new Tree()), new List()))
Admin
Delete is O(1). Sure, find is O(N), and therefore, find-and-delete is O(N), but you're assuming you always have to find in a sorted linked list, which is just not true.