I interviewed with a couple of companies… mostly just to see what else is out there. It’s funny, but I’m sure I’m not the only one that noticed techies have huge chips on their shoulders. lol.
Company 1:
(After about 30 minutes of technical probing)
Interviewer So, where in this system (as he points to a UML diagram on the whiteboard) are we likely to experience a bottleneck?
Me The database of course.
Interviewer (Looking confused) The processor takes a huge load though. I think the processor is the bottleneck. (WRONG!)
Me (trying hard to be nice) Ummm, disk access time is far slower. You’re comparing nanoseconds with milliseconds… not to mention the locks that are taking place.
Interviewer Hmmm. Look. You’re an intellectual athlete… but I don’t think you’re the a good fit for this job.

What a basehead. How can you think the bottleneck was the processor?

Company 2:
(After a 30 minute phone interview full of algorithmic questions, we have an in-person meeting)
Interviewer So, how would you write a program that takes an array of unsorted integers and 1) sort them in numerical order and 2) separate the even numbers from the odd numbers in the same array…. Also, there’s a catch. You are on very limited resources, so you can’t create a new array. The sort would have to occur in place.
Me Hmm. Okay. Since we’re limited to a single array, I would use a bubble sort…. but in that bubble sort, I would swap values based on whether the number is even/odd and by its numerical order. (yes, an insert sort also performs in place and is more efficient unless it’s a worst case scenario, still O(n^2) but the bubble sort is self-explanatory and much simpler to explain without a whiteboard.)
Interviewer Ummm, that wouldn’t work. That would only work for a numerical sort…. but it wouldn’t separate evens from odds.
Me Yes it would. I can show you.
Interviewer No it wouldn’t. We don’t have time.
Me Yes it would.
Interviewer No it wouldn’t. This is how I would do it. (He continues to ramble about maintaining pointers on each end of the array and swapping places based on its even/odd status. Basically, a multi-pass process.)
Me Ummm, my way is better.
Interviewer No. Your way wouldn’t work.
Me Okay. Whatever.

Surprise. They tell my recruiter that I am “unfit” for their company. Hahaha. Doesn’t bother me a bit… because I’m right, and he was wrong. I went home and coded that program in 7 minutes and it works like a charm:

``````
#include <stdio.h>
#include <stdlib.h>
#include <time.h>

void evenoddsort(int *unsorted, int count){
int i,j,temp;
for(j=0;j<count;j++){
for(i=0;i<count-1;i++){
if((unsorted[i]%2 == 1 && unsorted[i+1]%2 == 0)
|| (unsorted[i] > unsorted[i+1] && unsorted[i]%2 == unsorted[i+1]%2)){
temp = unsorted[i];
unsorted[i] = unsorted[i+1];
unsorted[i+1] = temp;
}
}
}
}

void createrandomarray(int *randarray, int count){
int i;
srand(time(NULL));
for(i=0;i<count;i++){
randarray[i] = rand() % 100;
}
}

void printarray(int *myarray, int count){
int i;
for(i=0;i<count;i++){
printf("%d\n",myarray[i]);
}

}

int main(int argc, char *argv[]){
if(argc == 2){
int argi = atoi(argv[1]);
int numarray[argi];

createrandomarray(numarray,argi);

printf("\nUNSORTED\n");
printarray(numarray,argi);

evenoddsort(numarray,argi);

printf("\nSORTED\n");
printarray(numarray,argi);

return 0;
}
else{
printf("\nUsage: evenoddsort <integer>\n");
return 1;
}
}
``````

Compile it and run it. My solution is more “elegant” and it does it in 1 bubble sorting pass.

So why do techies have chips on their shoulders? Because… no matter what kind of degree they have… no matter what kind of college they attended… no matter how much time and money they spent on school… when a college dropout like myself shows up and proves them wrong, their feelings get hurt.

From → Hacks