• J A F (unregistered) in reply to Grimoire
    Grimoire:
    Anonymous:
    kswanton:

    One of the apps was to write a sort algorithm, and it could be any sort algorithm.



    There is no point in such a test. It just proves that someone can memorize things. It does not prove if someone is able to think, systematically approach a complicated problem and solve it, can write production quality code, can prioritize tasks etc. If you look for brain-dead code monkeys that might be a good test. Otherwise not.

    If I need a sort, I take it from the library. If there is none in the library, I google for an implementation. If there is non, I get out that old CS textbook and implement one. But not earlier. Memorizing sort algorithms was and is a waste of time.

    I agree 100%.  When interviewing, I ask the candidate to "sort an array of 10000 integers".  Full marks for using either the C library qsort or one of STL's sorts, partial marks for implementing an O(n lg n) sort, low marks for O(n^2), and ridicule for doing nothing (j/k).  About 75% of the candidates I've asked this have written their own sort.  Half of that 75% tried and failed to write an O(n lg n) sort, and the other half successfully wrote bubblesort.

    Does the world really need another poor implementation of bubblesort?


    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.
  • J A F (unregistered) in reply to Unklegwar
    Anonymous:
    See what happens when you reply to those "Get your Degree, choose from 50 majors!" emails?

    In defense of the class, I'm thinking that the whole listbox thing was to visually represent the linked list so the student can see what's going on? One can hope.



    One would, however, the Visible = False on the second slide would make that difficult.
  • (cs) in reply to CornedBee
    CornedBee:
    OK, perhaps I'm stupid, but what's the point of implementing a sorted linked list? How often do you need a container that has O(N) insertion complexity, O(N) lookup complexity for an arbitrary element, and happens to deliver the elements in sorted order on iteration? That's one of the most pointless data structures I've ever heard of.
    Since we have O(N) insertion already, we may as well use an array list, like std::vector, and keep that sorted. Then we have O(log n) lookup complexity and probably faster iteration. (Pointer arithmetic instead of pointer dereference for moving forward.) Oh, and constant-time random access, in case anyone cares. Oh yeah, and reverse iteration. Did I mention less memory overhead?


    Meh. Useless data structure implemented in a braindead way. I guess it fits.
    Well, actually it probably doesn't, because I don't think the ListBox uses a linked list internally.


    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.
  • (cs) in reply to Jeff S
    Jeff S:
    Anonymous:

    Jeff S:
    Anonymous:
    i thought i had it bad at my university when we were instructed to make our own list, vector, and stack classes and NOT use STL...that was FUN                       


    That, my friend, wins the "WTF comment of the day!" award.

    You mean they actually forced you to learn how data structures work? Who would ever need to know that stuff????

     

    I sincerely hope you forgot <sarcasm> tags around your comment.  Of course you should know how data structures work.  You might never have to use it, but it will make you a better programmer.  And maybe some day you will have to code in a language that doesn't have STL, and you have to implement something like that yourself.  Personally I throw in a data structure question every time I interview someone for a position, and so far very few got it right, but the ones that did were clearly better programmers.        



    Yes, of course I was being sarcastic.  that's why I indicated that his comment itself was a WTF, though I can see how that may not have been clear.

    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.

  • (cs) in reply to themagni

    Alex Papadimoulis:

    Maybe Chris should have looked at that Best Universities list after all ...

    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.

    themagni:

    2. "What does their code look like? Do they use Whitesmith indentation? Do they comment?"

    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

    themagni:

    I know, you guys all have broadband. Some of my code has shipped (as recently as last year) to people that are 3 days away from electricity, never mind the Internet. (Laptops powered by car batteries.)

    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?

     

  • XMLord (unregistered) in reply to mw
    Anonymous:
    I was fully prepared to do a "top-this" with my own story, but then I saw the second slide.


    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.
  • MusiGenesis (unregistered) in reply to kswanton
    kswanton:

    ... it could be any sort algorithm.  ...

    <o:p> </o:p>



    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.
  • MusiGenesis (unregistered) in reply to MusiGenesis

    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).

  • incoherent (unregistered) in reply to MusiGenesis
    Anonymous:
    kswanton:

    ... it could be any sort algorithm.  ...

    <o:p> </o:p>



    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.
    Bubble sort is 4 lines of code and is guaranteed to complete, at the very least.  RandomSort is only good for being cheeky, which may have been the intention.
  • (cs) in reply to kswanton
    kswanton:
    Did you use the results of the test as an indication of who to hire or who *not* to hire? I find tests useful for the latter.  As for you giving higher marks to someone who can use a library function vs. writing their own, I'm not sure I agree.  I agree with your 'why reinvent the wheel' type of though, but what happens when the wheel has not been invented yet?  Free/open thinkers are needed, not just someone who can use a library/google.


    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."
  • (cs) in reply to MusiGenesis
    I asked a guy to write a function to sort a linked list once. He wrote two lines of code and looked constipated for a while. He couldn't even tell me what it was he didn't understand.


    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.

  • (cs) in reply to MusiGenesis
    Anonymous:
    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.


    I rather doubt that that's faster to implement than bubble sort or quicksort.
  • Unklegwar (unregistered) in reply to J A F
    Anonymous:
    Anonymous:
    See what happens when you reply to those "Get your Degree, choose from 50 majors!" emails?

    In defense of the class, I'm thinking that the whole listbox thing was to visually represent the linked list so the student can see what's going on? One can hope.



    One would, however, the Visible = False on the second slide would make that difficult.


    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.
  • (cs) in reply to J A F
    Anonymous:
    Anonymous:
    kswanton:

    One of the apps was to write a sort algorithm, and it could be any sort algorithm.



    There is no point in such a test. It just proves that someone can memorize things. It does not prove if someone is able to think, systematically approach a complicated problem and solve it, can write production quality code, can prioritize tasks etc. If you look for brain-dead code monkeys that might be a good test. Otherwise not.

    If I need a sort, I take it from the library. If there is none in the library, I google for an implementation. If there is non, I get out that old CS textbook and implement one. But not earlier. Memorizing sort algorithms was and is a waste of time.


    We have  saying in Math about using formulas... Don't memorize it, understand it... I think it applies to sorting algorithms as well


    Perfectly stated ..... couldn't agree more.
  • (cs) in reply to Dan
    Anonymous:
    In my first year, I wrote a sort function called a "fux0rt". It would check if the elements were in order. If they were not, it would randomly change them and check again. If I got asked to do that during an interview, that's what I'd pull out and write.

    That wouldn't get you the job. Unless your program has infinite time to run, it's not guaranteed to complete.

    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.

  • dsfgsdf (unregistered) in reply to themagni
    Heh.   The last interview I was at, I made them sweat.  I asked the architect technical questions to see how "l33t" he was.  I've had it with going to companies run by monkeys, and I now grill the interviewers so I can get a good handle on the skill level of the people I'm going to be working with.
     
    The project manager was also at the meeting, and after a few questions and her indrection I found out that the reason they were so eager to hire was because their project was TWO years behind schedule.  She actually blamed the client, which may be true or not, but she totally absolved themselves of any responsibility.  That's when I determined I wasn't going to work for them.
  • (cs) in reply to kswanton
    kswanton:

    I worked for a place that liked to test new candidates to better gauge if they were the ‘right stuff’.  One of the tests was to put the person in front of a computer and have them write a couple of apps.  One of the apps was to write a sort algorithm, and it could be any sort algorithm.  Clearly anyone who could implement a bubble sort was the ‘right stuff’ (sarcasm)



    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.
  • (cs) in reply to Digitalbath
    Digitalbath:

    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.



    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?  :)
  • (cs) in reply to kswanton
    kswanton:
    Did you use the results of the test as an indication of who to hire or who *not* to hire? I find tests useful for the latter.  As for you giving higher marks to someone who can use a library function vs. writing their own, I'm not sure I agree.  I agree with your 'why reinvent the wheel' type of though, but what happens when the wheel has not been invented yet?  Free/open thinkers are needed, not just someone who can use a library/google.

    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.
  • dsfgsdf (unregistered) in reply to Grimoire
    I ask questions like "Have you used a versioning system?".  If they say "Yes", great.  If they say "No, but I'd like to use one and understand the value of having one", that's good.  If they say "What's versioning?" I throw them out.
     
    I've also asked the question "What does HTML stand for?"  I discovered through this one question that one candidate completely falsified his resume.
  • (cs) in reply to jbange
    Anonymous:
    Grimoire:

    I agree 100%.  When interviewing, I ask the candidate to "sort an array of 10000 integers".  Full marks for using either the C library qsort or one of STL's sorts


    Hmmm... Do you say "feel free to use any part of the STL to do this" in the instructions?  If not, it becomes a judgement call on  the part of the interviewee whether you are a smart programmer who'll appreciate ingenuity rather than a bureaucratic drone with an answer sheet. Given that it may not be clear whether you'd understand the validity of a call to qsort, I'd also have probably just rattled of a simple bubblesort that I knew even a suit would understand. I've had bosses before who would've said "you didn't show us any code for this 'qsort' routine you invented". Some might say "I wouldn't work anywhere where the guy hiring me wouldn't understand a smug reference to the C lib or STL", but many of us can't afford that sort of pride... ;)

    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.
  • (cs) in reply to Bus Raker
    Bus Raker:

    themagni:

    2. "What does their code look like? Do they use Whitesmith indentation? Do they comment?"

    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

    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.)

    themagni:

    I know, you guys all have broadband. Some of my code has shipped (as recently as last year) to people that are 3 days away from electricity, never mind the Internet. (Laptops powered by car batteries.)

    Bus Raker:

    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? 

    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.

    Bus Raker:
    The leads to the philosophical question, if your laptop was burning down and you could only save 11mb, what would it be?

    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.

  • Jon (unregistered) in reply to themagni
    themagni:

    In my first year, I wrote a sort function called a "fux0rt".

    It would check if the elements were in order. If they were not, it would randomly change them and check again. If I got asked to do that during an interview, that's what I'd pull out and write.

    My favourite silly sorting algorithm is: while (!is_sorted(begin, end)) next_permutation(begin, end);
    Grimoire:
    When interviewing, I ask the candidate to "sort an array of 10000 integers".  Full marks for using either the C library qsort or one of STL's sorts, partial marks for implementing an O(n lg n) sort, low marks for O(n^2), and ridicule for doing nothing (j/k).
    How many marks would you award them for a radix sort?
  • (cs)

    Alex Papadimoulis:

    The choice of Visual Basic 6 as the course language seemed awfully strange, especially considering that Data Structure courses generally introduce the concept of pointers and pointer-usage in creating stacks, lists, queues, etc.

    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...

  • (cs) in reply to Angstrom
    Angstrom:
    codenator:

    I'm sorry but what?!!

    Maybe this is against the forum rules but can we please have the name of the school? lecturer? I mean if this is true I really think they should be named and shamed, that is terrible!!! I think the princeton lecturer would like to know as well that his work is being copied by another lecturer.

    Run away, do yourself a favour and quit and try for another school....VB6 wow that's bad, what do they teach in 2nd 3rd years? maybe it gets better.

    If this isn't University of Toronto I'll eat my metaphorical hat.  I just helped a friend of mine grasp skip lists for the UofT comp sci course she's taking and the template source (in java) was a line-for-line port of some VB6 code.

    With the VB6 source still in comments.




    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.


  • (cs)

    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.


  • Stephen Touset (unregistered) in reply to Steve
    Anonymous:
    i thought i had it bad at my university when we were instructed to make our own list, vector, and stack classes and NOT use STL...that was FUN                       


    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?
  • (cs) in reply to CornedBee
    CornedBee:
    OK, perhaps I'm stupid, but what's the point of implementing a sorted linked list? How often do you need a container that has O(N) insertion complexity, O(N) lookup complexity for an arbitrary element, and happens to deliver the elements in sorted order on iteration? That's one of the most pointless data structures I've ever heard of.

    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.
  • jt (unregistered) in reply to anonymous
    Anonymous:
    Coincoin:

    Anonymous:
    That's like training lifeguards to dial 911 when someone is drowning.

    It's rather like training lifeguards to dial 0 to ask for the directory service number. Then call 411 and ask for the emergencies number. And finally call 911.



    More like training lifeguards to yell "Hey, that person is downing! Someone help!"


    Like having the lifeguard put a note in a bottle and toss it in the pool. Yes - pool.
  • (cs) in reply to dsfgsdf
    Anonymous:
     
    I've also asked the question "What does HTML stand for?"  I discovered through this one question that one candidate completely falsified his resume.

    Duh, everyone knows that HTML is the standard abbreviation for Hotmail.  Why would you ask a programmer a question about email services?

  • (cs) in reply to Jon
    Anonymous:
    Grimoire:
    When interviewing, I ask the candidate to "sort an array of 10000 integers".  Full marks for using either the C library qsort or one of STL's sorts, partial marks for implementing an O(n lg n) sort, low marks for O(n^2), and ridicule for doing nothing (j/k).
    How many marks would you award them for a radix sort?

    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.
  • (cs) in reply to John
    Anonymous:
    Anonymous:
    kswanton:

    One of the apps was to write a sort algorithm, and it could be any sort algorithm.



    There is no point in such a test. It just proves that someone can memorize things. It does not prove if someone is able to think, systematically approach a complicated problem and solve it, can write production quality code, can prioritize tasks etc. If you look for brain-dead code monkeys that might be a good test. Otherwise not.

    If I need a sort, I take it from the library. If there is none in the library, I google for an implementation. If there is non, I get out that old CS textbook and implement one. But not earlier. Memorizing sort algorithms was and is a waste of time.

    Better than no test at all...

    Anyway, my tech school experiance was ... interesting; of the two instructors one was out pregnant for a while, and the other way having an affair with another instructor. I ended up teaching most of the students what they needed to know (which was fun).

    But then, in high school I took a college class in COBOL for fun.

    I still have my COBOL textbook, from the class I took in 1970.  The book is virtually brand-new . . .

  • (cs) in reply to yy2bggggs
    yy2bggggs:

    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)


    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.

  • Franz Kafka (unregistered) in reply to Grimoire
    Grimoire:


    Does the world really need another poor implementation of bubblesort?


    Nope, but an itnerview can be intended to either show coding competence or problem solving competence, and they lead to very different  answers.

    CornedBee:
    OK, perhaps I'm stupid, but what's the point of implementing a sorted linked list? How often do you need a container that has O(N) insertion complexity, O(N) lookup complexity for an arbitrary element, and happens to deliver the elements in sorted order on iteration? That's one of the most pointless data structures I've ever heard of.


    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.
  • Dubya (unregistered)

        This is the lamest WTF ever posted.  Slow day?

  • Ferdinand (unregistered) in reply to Franz Kafka

    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.

  • (cs) in reply to brazzy
    brazzy:
    kswanton:
    Did you use the results of the test as an indication of who to hire or who *not* to hire? I find tests useful for the latter.  As for you giving higher marks to someone who can use a library function vs. writing their own, I'm not sure I agree.  I agree with your 'why reinvent the wheel' type of though, but what happens when the wheel has not been invented yet?  Free/open thinkers are needed, not just someone who can use a library/google.


    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.

    So, you're saying you'd prefer stupid progammers?

  • (cs) in reply to yy2bggggs
    yy2bggggs:

    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.


    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.

  • Franz Kafka (unregistered) in reply to rsynnott
    rsynnott:

    So, you're saying you'd prefer stupid progammers?



    Nah, just programmers not so enamored of their talent.

    capthca: craptastic

  • (cs) in reply to Franz Kafka
    Anonymous:
    rsynnott:

    So, you're saying you'd prefer stupid progammers?



    Nah, just programmers not so enamored of their talent.

    capthca: craptastic

    Nah, looks like he wants drones.

  • Jon (unregistered) in reply to rsynnott
    rsynnott:
    Nah, looks like he wants drones.
    You sure you read his post correctly? He wants people who actively look for simpler ways to do things -- it's not at all to do with being a stupid drone.
  • illuminatedwax (unregistered) in reply to brazzy
    brazzy:
    kswanton:
    Did you use the results of the test as an indication of who to hire or who *not* to hire? I find tests useful for the latter.  As for you giving higher marks to someone who can use a library function vs. writing their own, I'm not sure I agree.  I agree with your 'why reinvent the wheel' type of though, but what happens when the wheel has not been invented yet?  Free/open thinkers are needed, not just someone who can use a library/google.


    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 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.

  • (cs) in reply to merreborn
    merreborn:
    yy2bggggs:

    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)


    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.


    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.

  • (cs) in reply to illuminatedwax
    brazzy:
    You need programmers that realize when what they are working on is an NP-complete problem.


    I see, so a good interview question to ask would be:
    Is P = NP?
  • (cs) in reply to themagni
    themagni:
    ...

    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.

    ...

    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.

  • Dwonis (unregistered) in reply to yy2bggggs
    yy2bggggs:
    I see, so a good interview question to ask would be:
    Is P = NP?


    A good answer would be:

    I'm sorry; that information is classified.
  • illuminatedwax (unregistered) in reply to yy2bggggs
    yy2bggggs:
    brazzy:
    You need programmers that realize when what they are working on is an NP-complete problem.


    I see, so a good interview question to ask would be:
    Is P = NP?

    No, because that wouldn't weed out Slashdot readers.
  • anonymous (unregistered) in reply to illuminatedwax

    Is one of their course titles "Enterprise Development using AJAX"?

    Or rather "Enterprisey Development"...LOL

  • Andrae (unregistered) in reply to yy2bggggs
    yy2bggggs:
    CornedBee:
    OK, perhaps I'm stupid, but what's the point of implementing a sorted linked list? How often do you need a container that has O(N) insertion complexity, O(N) lookup complexity for an arbitrary element, and happens to deliver the elements in sorted order on iteration? That's one of the most pointless data structures I've ever heard of.

    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.


    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()))
  • (cs) in reply to Andrae
    Anonymous:
    yy2bggggs:
    On a sorted link list, deletion of a node is O(1).  In a vector, it's O(N).  Suddenly, a vector doesn't
    ...
    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.

    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.


Leave a comment on “Studying at WTF University”

Log In or post as a guest

Replying to comment #:

« Return to Article