Click here to Skip to main content
15,887,746 members

The Weird and The Wonderful

   

The Weird and The Wonderful forum is a place to post Coding Horrors, Worst Practices, and the occasional flash of brilliance.

We all come across code that simply boggles the mind. Lazy kludges, embarrassing mistakes, horrid workarounds and developers just not quite getting it. And then somedays we come across - or write - the truly sublime.

Post your Best, your worst, and your most interesting. But please - no programming questions . This forum is purely for amusement and discussions on code snippets. All actual programming questions will be removed.

 
GeneralRe: Sith Interviewing Tactics Pin
ProtoBytes14-Jul-09 15:48
ProtoBytes14-Jul-09 15:48 
AnswerRe: Sith Interviewing Tactics [modified] Pin
ProtoBytes15-Jul-09 2:15
ProtoBytes15-Jul-09 2:15 
GeneralRe: Sith Interviewing Tactics Pin
Chris Losinger15-Jul-09 3:08
professionalChris Losinger15-Jul-09 3:08 
GeneralRe: Sith Interviewing Tactics Pin
ProtoBytes15-Jul-09 3:42
ProtoBytes15-Jul-09 3:42 
GeneralRe: Sith Interviewing Tactics Pin
Chris Losinger15-Jul-09 3:57
professionalChris Losinger15-Jul-09 3:57 
GeneralRe: Sith Interviewing Tactics Pin
ProtoBytes15-Jul-09 4:10
ProtoBytes15-Jul-09 4:10 
GeneralRe: Sith Interviewing Tactics Pin
Chris Losinger15-Jul-09 4:49
professionalChris Losinger15-Jul-09 4:49 
GeneralRe: Sith Interviewing Tactics [modified] Pin
_Erik_7-Jul-09 4:15
_Erik_7-Jul-09 4:15 
Well, I think this is really a great question for an interview, becouse you can get a lot of conclusions depending on the answer.

If the answer was:

int BadFib(int n)
{
if (n == 1 || n == 2)
return 1;
else
return BadFib(n - 1) + BadFib(n - 2);
}

This answer means that the guy knows what recursion is, but he has no idea about algorithm complexity, and he does not mind performance at all. So, my next question would be: Can you do it better?

But now, if somebody came up with this solution:

public int GoodFib(int n)
{
return Fib(n, 1, 1);
}

private int Fib(int n, int n1, int n2)
{
if (n == 1 || n == 2)
return 1;
else if (n == 3)
return n1 + n2;
else
return Fib(n - 1, n1 + n2, n1);
}

This means that the guy knows what recursion is, he knows what algorithm complexity is, and he is worried about the performance of his code. So, my next question would be: When would yo be able to start with the job?

I guess the interviewer just wanted to know how skilled you were about programming.

modified on Tuesday, July 7, 2009 11:30 AM

GeneralRe: Sith Interviewing Tactics Pin
Paulo Zemek7-Jul-09 7:27
mvaPaulo Zemek7-Jul-09 7:27 
GeneralRe: Sith Interviewing Tactics Pin
Dan Neely7-Jul-09 9:14
Dan Neely7-Jul-09 9:14 
GeneralRe: Sith Interviewing Tactics Pin
_Erik_8-Jul-09 5:43
_Erik_8-Jul-09 5:43 
GeneralRe: Sith Interviewing Tactics Pin
ProtoBytes15-Jul-09 4:33
ProtoBytes15-Jul-09 4:33 
GeneralRe: Sith Interviewing Tactics Pin
Paulo Zemek16-Jul-09 14:14
mvaPaulo Zemek16-Jul-09 14:14 
GeneralRe: Sith Interviewing Tactics [modified] Pin
ProtoBytes7-Jul-09 18:04
ProtoBytes7-Jul-09 18:04 
GeneralRe: Sith Interviewing Tactics Pin
ProtoBytes7-Jul-09 20:53
ProtoBytes7-Jul-09 20:53 
GeneralRe: Sith Interviewing Tactics Pin
_Erik_8-Jul-09 1:54
_Erik_8-Jul-09 1:54 
GeneralRe: Sith Interviewing Tactics Pin
ProtoBytes8-Jul-09 6:29
ProtoBytes8-Jul-09 6:29 
GeneralRe: Sith Interviewing Tactics Pin
ProtoBytes8-Jul-09 6:51
ProtoBytes8-Jul-09 6:51 
GeneralRe: Sith Interviewing Tactics [modified] Pin
ProtoBytes8-Jul-09 7:59
ProtoBytes8-Jul-09 7:59 
GeneralRe: Sith Interviewing Tactics Pin
_Erik_10-Jul-09 3:47
_Erik_10-Jul-09 3:47 
GeneralRe: Sith Interviewing Tactics Pin
ProtoBytes10-Jul-09 5:09
ProtoBytes10-Jul-09 5:09 
GeneralRe: Sith Interviewing Tactics Pin
exyyle21-Jul-09 17:54
professionalexyyle21-Jul-09 17:54 
GeneralRe: Sith Interviewing Tactics Pin
ProtoBytes21-Jul-09 17:58
ProtoBytes21-Jul-09 17:58 
JokeRe: I think the Interviwer missed my example of recursion Pin
ProtoBytes22-Jul-09 3:54
ProtoBytes22-Jul-09 3:54 
GeneralRe: I think the Interviwer missed my example of recursion Pin
exyyle22-Jul-09 6:52
professionalexyyle22-Jul-09 6:52 

General General    News News    Suggestion Suggestion    Question Question    Bug Bug    Answer Answer    Joke Joke    Praise Praise    Rant Rant    Admin Admin   

Use Ctrl+Left/Right to switch messages, Ctrl+Up/Down to switch threads, Ctrl+Shift+Left/Right to switch pages.