wu :: forums
« wu :: forums - New programming interview question ideas »

Welcome, Guest. Please Login or Register.
Oct 13th, 2024, 7:47am

RIDDLES SITE WRITE MATH! Home Home Help Help Search Search Members Members Login Login Register Register
   wu :: forums
   riddles
   cs
(Moderators: Icarus, SMQ, towr, Eigenray, william wu, ThudnBlunder, Grimbal)
   New programming interview question ideas
« Previous topic | Next topic »
Pages: 1  Reply Reply Notify of replies Notify of replies Send Topic Send Topic Print Print
   Author  Topic: New programming interview question ideas  (Read 6093 times)
bryanilee
Newbie
*





   


Posts: 2
New programming interview question ideas  
« on: Jul 15th, 2012, 10:27pm »
Quote Quote Modify Modify

I didn't see an existing thread on this, but I'm a newbie, so I might have missed something - apologies if I did.  Smiley
 
Anyone have ideas for new interview questions for a programming position?
 
Here's one I was thinking about:
In a simple "alphabetical" sort, you would get this sort order:
a
b
b1
b12
b154
b2
b3
b6
 
But sometimes you actually want the numerical part to be sorted as a number (and in some newer OS's this is how filenames are sorted):
a
b
b1
b2
b3
b6
b12
b154
 
Write an algorithm to sort strings in this order.  And in general it would be good to handle multiple numerical portions in strings, so you would want this ordering:
number 1 sub 1 a
number 1 sub 2 a
number 1 sub 12
number 2 sub 12
number 11 sub 1
number 11 sub 2
number 11 sub 12
etc.
 
----------
What do you think?  Too easy too hard?
IP Logged
towr
wu::riddles Moderator
Uberpuzzler
*****



Some people are average, some are just mean.

   


Gender: male
Posts: 13730
Re: New programming interview question ideas  
« Reply #1 on: Jul 16th, 2012, 10:29pm »
Quote Quote Modify Modify

Sounds like a reasonable question.
When you have just an alphabetic part plus a numeric part, you could do a numeric sort on that part first, and then a stable lexical sort. When you can have an arbitrary number of alternating alphabetic and numeric parts you need a slightly different approach (because one string might have more parts than another). But it's not too hard to design a comparison function that correctly compares corresponding parts.
IP Logged

Wikipedia, Google, Mathworld, Integer sequence DB
Grimbal
wu::riddles Moderator
Uberpuzzler
*****






   


Gender: male
Posts: 7527
Re: New programming interview question ideas  
« Reply #2 on: Jul 17th, 2012, 8:45am »
Quote Quote Modify Modify

I actually wrote such a function for comparing multi-part version numbers, like 2.17.1123.
 
You just need to see how far they are equal.  From there on, there are 4 cases, depending if the next character on either side is a digit or not.  If both are digits, compare as numbers the groups of digits that follow on each side.
« Last Edit: Jul 17th, 2012, 8:48am by Grimbal » IP Logged
zxy112
Newbie
*





   


Posts: 1
Re: New programming interview question ideas  
« Reply #3 on: Aug 14th, 2012, 9:25pm »
Quote Quote Modify Modify

something like a modified radix sort may do ... but there shud be a limitation in the alphanum set that needs to be sorted ...
IP Logged
Pages: 1  Reply Reply Notify of replies Notify of replies Send Topic Send Topic Print Print

« Previous topic | Next topic »

Powered by YaBB 1 Gold - SP 1.4!
Forum software copyright © 2000-2004 Yet another Bulletin Board