Had interview today...stumped by a technical question

Page 4 - Seeking answers? Join the AnandTech community: where nearly half-a-million members share solutions and discuss the latest tech.

Descartes

Lifer
Oct 10, 1999
13,968
2
0
Originally posted by: DAGTA
Originally posted by: Descartes
Originally posted by: DAGTA
Originally posted by: Descartes
Originally posted by: DAGTA
Originally posted by: xospec1alk
Originally posted by: Gibson486
Originally posted by: Descartes
Originally posted by: stan394
Originally posted by: Gibson486
Originally posted by: stan394
what does 'sorting a 2-dimension array' mean? i mean, i had a hard time picturing what is supposed to be the 'right' behavior.

you have an X and a Y

hm.. let's say you have this 2-dimensional array

3 8 7 5
1 2 5 3
6 4 9 7

what does it look like after you sort it?

That's not a 2-d array.

x and y, what more do you want?


it has more than two dimensions....


It does? I'm waiting for you or Descartes to explain.

Assuming each digit in the above examples represent a discrete item in the array I think it should be obvious. If they are not discrete then you have a one-dimensional array, and if they are discrete you have a four-dimensional.

Either way it's not a two-dimensional.


Wow... and to think... you make more money than me....

A lot more I'm sure. What's your point?

May I suggest you pick up a remedial first year college book that includes a chapter in programming arrays. I've taught this stuff, in a university, with a senior professor and a dept chair checking my work... neither of them found flaws in my understanding of two dimensional arrays.

Maybe you need to learn how to articulate an argument without resorting to the ad hominem? I'm not going to get in a pissing match where a bunch of people start throwing around credentials, most of which are of questionable veracity.
 

BlueFlamme

Senior member
Nov 3, 2005
565
0
0
Anyone other than me still curious as to the answer the interview lady gave OP?

EDIT: Saw the edit in the OP. Bad question. Do you get to ask a vague one in return?
 

imported_Tick

Diamond Member
Feb 17, 2005
4,682
1
0
Originally posted by: torpid
Originally posted by: BigJ
Originally posted by: Descartes

Hello ignoramus, read my post. I didn't say what he presented was NOT a 2d array. I was referring to the printed example earlier.

What Gibson posted here?

Originally posted by: stan394
Originally posted by: Gibson486
Originally posted by: stan394
what does 'sorting a 2-dimension array' mean? i mean, i had a hard time picturing what is supposed to be the 'right' behavior.

you have an X and a Y

hm.. let's say you have this 2-dimensional array

3 8 7 5
1 2 5 3
6 4 9 7

what does it look like after you sort it?

How is that not a 2-dimnesional array? 3 rows by 4 columns?

Well technically it's just a big string with spaces and carriage returns.

Umm, no, where you write the numbers makes it an array. It may not have brackets or what not, but it's still an array. The fact that he added carraige returns and spaces made it an array.
 

Descartes

Lifer
Oct 10, 1999
13,968
2
0
Originally posted by: BlueFlamme
Anyone other than me still curious as to the answer the interview lady gave OP?

He replied in an earlier post. He said the answer was, "Use a compare function." A silly answer, imo, as the question seemed to focus on a description of how it would be in terms of OO vs. procedural, and distilling the answer to a simple function name says very little about understanding the difference, imo.
 

imported_Tick

Diamond Member
Feb 17, 2005
4,682
1
0
Originally posted by: Descartes
Originally posted by: DAGTA
Originally posted by: Descartes
Originally posted by: DAGTA
Originally posted by: Descartes
Originally posted by: DAGTA
Originally posted by: xospec1alk
Originally posted by: Gibson486
Originally posted by: Descartes
Originally posted by: stan394
Originally posted by: Gibson486
Originally posted by: stan394
what does 'sorting a 2-dimension array' mean? i mean, i had a hard time picturing what is supposed to be the 'right' behavior.

you have an X and a Y

hm.. let's say you have this 2-dimensional array

3 8 7 5
1 2 5 3
6 4 9 7

what does it look like after you sort it?

That's not a 2-d array.

x and y, what more do you want?


it has more than two dimensions....


It does? I'm waiting for you or Descartes to explain.

Assuming each digit in the above examples represent a discrete item in the array I think it should be obvious. If they are not discrete then you have a one-dimensional array, and if they are discrete you have a four-dimensional.

Either way it's not a two-dimensional.


Wow... and to think... you make more money than me....

A lot more I'm sure. What's your point?

May I suggest you pick up a remedial first year college book that includes a chapter in programming arrays. I've taught this stuff, in a university, with a senior professor and a dept chair checking my work... neither of them found flaws in my understanding of two dimensional arrays.

Maybe you need to learn how to articulate an argument without resorting to the ad hominem? I'm not going to get in a pissing match where a bunch of people start throwing around credentials, most of which are of questionable veracity.

End Latin abuse now.
 

Stuxnet

Diamond Member
Jun 16, 2005
8,392
1
0
Originally posted by: stan394
Originally posted by: BlueFlamme
Anyone other than me still curious as to the answer the interview lady gave OP?

I am.

The OP said she said to use the compare() function. One part of the whole solution; definitely not a complete answer.
 

torpid

Lifer
Sep 14, 2003
11,631
11
76
Originally posted by: Tick
Originally posted by: torpid
Well technically it's just a big string with spaces and carriage returns.

Umm, no, where you write the numbers makes it an array. It may not have brackets or what not, but it's still an array. The fact that he added carraige returns and spaces made it an array.

Ehhh.... well I'll just let this one go. I was making a little joke.
 

imported_Tick

Diamond Member
Feb 17, 2005
4,682
1
0
Originally posted by: torpid
Originally posted by: Tick
Originally posted by: torpid
Well technically it's just a big string with spaces and carriage returns.

Umm, no, where you write the numbers makes it an array. It may not have brackets or what not, but it's still an array. The fact that he added carraige returns and spaces made it an array.

Ehhh.... well I'll just let this one go. I was making a little joke.

Ok. I'm just so sick of programmers and their syntax obsession.

Also, could someone please explain why the afore mentioned array wasn't 2d?
 

QED

Diamond Member
Dec 16, 2005
3,428
3
0


Descartes, just so we understand you properly... how many dimensiona is the following representation of an array, assuming each digit is a discrete element?

3 8 7 5 2
1 2 5 3 1
6 4 9 7 3

Is this a 5 dimensional array because it has 5 columns??? Or something else?

Just trying to understand your logic here...
 

Ausm

Lifer
Oct 9, 1999
25,213
14
81
Originally posted by: mugs
Originally posted by: Descartes
Are you people flipping serious, or are you just not developers? If not then I understand, and that's ok...

Absolutely serious and I am a developer.


Yeah I deal with arrays all the time and Descartes is wrong.


Ausm
 

stan394

Platinum Member
Jul 8, 2005
2,112
0
76
Originally posted by: jbourne77
Originally posted by: stan394
Originally posted by: BlueFlamme
Anyone other than me still curious as to the answer the interview lady gave OP?

I am.

The OP said she said to use the compare() function. One part of the whole solution; definitely not a complete answer.

yes, i got carried away with the hijacked discussion and forgot to read about the original problem :p
 

DAGTA

Diamond Member
Oct 9, 1999
8,172
1
0
Originally posted by: Descartes
Maybe you need to learn how to articulate an argument without resorting to the ad hominem? I'm not going to get in a pissing match where a bunch of people start throwing around credentials, most of which are of questionable veracity.

It's simply a fact that you are wrong about it not being a 2-D array. With most people I would have let this drop by now so I guess it is your snobbishness and attitude that lead me to repeating this a few times to drive the point home. The way those numbers were written was acceptable notation for displaying a 2-dimensional array in text format.

If you are still in doubt, go read up on it and find out. You don't need to come back to this thread and admit you were wrong, but at least know the definition of a 2-dimensional array if you are going to continue charging what you do for your work.
 

Descartes

Lifer
Oct 10, 1999
13,968
2
0
Originally posted by: mugs
Originally posted by: Howard
I stll don't understand how it's not a 2D array...

Because Descartes is choosing to ignore the obvious and interpret it in a way that he knows the person who posted it did not intend. He's nitpicking about the printed representation in an attempt to make himself look smarter.

No, I really didn't choose to do so. My first reaction was erroneous as I was thinking of it differently at the time, I admit it, and now I understand what everyone was saying.

I'll say it: My mistake. Suggesting I don't know what a 2D array is is rather silly, and anyone that knows me should quickly realize that.
 

torpid

Lifer
Sep 14, 2003
11,631
11
76
Originally posted by: jbourne77
Originally posted by: stan394
Originally posted by: BlueFlamme
Anyone other than me still curious as to the answer the interview lady gave OP?

I am.

The OP said she said to use the compare() function. One part of the whole solution; definitely not a complete answer.

If the question were reworded it might be the right answer. Heh.

Something like, "You are writing an object and want to allow other developers who use the object to sort a list of your object using standard sorting methods. What do you need to minimally do to accomplish this possibility?"

Ehh... well that one sucks too, but I'm sure you could come up with something.
 

imported_Tick

Diamond Member
Feb 17, 2005
4,682
1
0
Originally posted by: torpid
Originally posted by: jbourne77
Originally posted by: stan394
Originally posted by: BlueFlamme
Anyone other than me still curious as to the answer the interview lady gave OP?

I am.

The OP said she said to use the compare() function. One part of the whole solution; definitely not a complete answer.

If the question were reworded it might be the right answer. Heh.

Something like, "You are writing an object and want to allow other developers who use the object to sort a list of your object using standard sorting methods. What do you need to minimally do to accomplish this possibility?"

Ehh... well that one sucks too, but I'm sure you could come up with something.

Ha, I actually understood that question, so it's an improvement.
 

mugs

Lifer
Apr 29, 2003
48,920
46
91
Originally posted by: Descartes

No, I really didn't choose to do so. My first reaction was erroneous as I was thinking of it differently at the time, I admit it, and now I understand what everyone was saying.

I'll say it: My mistake. Suggesting I don't know what a 2D array is is rather silly, and anyone that knows me should quickly realize that.

Sorry I said that. Your replies here usually display a high level of intelligence, so it surprised me that you were blinded by your first impression and unable to see what the person who posted the array had in mind.

I'm still wondering where you got a fourth dimension from.
 

skimple

Golden Member
Feb 4, 2005
1,283
3
81
Originally posted by: torpid

In some languages it will actually be accurate, beacuse 2d arrays are really just arrays of arrays, so each row represents an array. In other languages it would look like this because it's all stored in consecutive memory:

Hmmm. Being an EE instead of a CE, maybe I'm getting my terminology mixed up. But isn't a 2d array an array of vectors? Or a single vector consisting of vectors as elements?

I'm thinking Matrix math, LU decomp. etc. Maybe for programming puproses you make no distinction.
 

torpid

Lifer
Sep 14, 2003
11,631
11
76
Originally posted by: mugs
Originally posted by: Descartes

No, I really didn't choose to do so. My first reaction was erroneous as I was thinking of it differently at the time, I admit it, and now I understand what everyone was saying.

I'll say it: My mistake. Suggesting I don't know what a 2D array is is rather silly, and anyone that knows me should quickly realize that.

Sorry I said that. Your replies here usually display a high level of intelligence, so it surprised me that you were blinded by your first impression and unable to see what the person who posted the array had in mind.

I'm still wondering where you got a fourth dimension from.

I believe he was thinking that the numbers represented a single dimensional array of the size represented by the number...? e.g.

3 1 5
2 3 4

=
Array of size 3, array of size 1, array of size 5.

Eh, who knows. He was clearly thinking too far outside the box. That happened to me once... the new radiohead cd had just come out and someone told me "radiohead sold out" and I was panicking thinking I wouldn't be able to get the CD anywhere.
 

BlueFlamme

Senior member
Nov 3, 2005
565
0
0
Vecor, Array, List, different names for the same thing iirc. (and of course what they are made of changes how you view it, you can have a vector of lists of strings, etc. etc.)
 

Descartes

Lifer
Oct 10, 1999
13,968
2
0
Originally posted by: mugs
Originally posted by: Descartes

No, I really didn't choose to do so. My first reaction was erroneous as I was thinking of it differently at the time, I admit it, and now I understand what everyone was saying.

I'll say it: My mistake. Suggesting I don't know what a 2D array is is rather silly, and anyone that knows me should quickly realize that.

Sorry I said that. Your replies here usually display a high level of intelligence, so it surprised me that you were blinded by your first impression and unable to see what the person who posted the array had in mind.

I'm still wondering where you got a fourth dimension from.

Well, if you look at the visual representation you can probably see what my brain chose to respond to it that way. :)

I can't honestly say why my mind chose to respond to it that way. I could make excuses and say I was thinking about other things, etc. but I'd rather just admit a mistake. It was a brain lapse, or whatever the hell else someone wants to call it; it happens.

So, I will offer an apology for my rash reply to those have responded in kind. To those that jumped onboard as a way to simply attack me I do not.

:thumbsup:
 

Ausm

Lifer
Oct 9, 1999
25,213
14
81
Originally posted by: mugs
Originally posted by: Descartes

No, I really didn't choose to do so. My first reaction was erroneous as I was thinking of it differently at the time, I admit it, and now I understand what everyone was saying.

I'll say it: My mistake. Suggesting I don't know what a 2D array is is rather silly, and anyone that knows me should quickly realize that.

Sorry I said that. Your replies here usually display a high level of intelligence, so it surprised me that you were blinded by your first impression and unable to see what the person who posted the array had in mind.

I'm still wondering where you got a fourth dimension from.



Daayuum can you tell what he had for lunch?

;)

Ausm
 

torpid

Lifer
Sep 14, 2003
11,631
11
76
Originally posted by: skimple
Originally posted by: torpid

In some languages it will actually be accurate, beacuse 2d arrays are really just arrays of arrays, so each row represents an array. In other languages it would look like this because it's all stored in consecutive memory:

Hmmm. Being an EE instead of a CE, maybe I'm getting my terminology mixed up. But isn't a 2d array an array of vectors? Or a single vector consisting of vectors as elements?

I'm thinking Matrix math, LU decomp. etc. Maybe for programming puproses you make no distinction.

Semantically yes, but in some languages using some weird memory kung fu they actually store 2d arrays as single memory blocks and not in seperate locations. That is why if you traverse the 2d array going vertically instead of horizintally (or vice versa) when sorting, it can be somewhat less efficient.
 

Descartes

Lifer
Oct 10, 1999
13,968
2
0
Originally posted by: torpid
Originally posted by: mugs
Originally posted by: Descartes

No, I really didn't choose to do so. My first reaction was erroneous as I was thinking of it differently at the time, I admit it, and now I understand what everyone was saying.

I'll say it: My mistake. Suggesting I don't know what a 2D array is is rather silly, and anyone that knows me should quickly realize that.

Sorry I said that. Your replies here usually display a high level of intelligence, so it surprised me that you were blinded by your first impression and unable to see what the person who posted the array had in mind.

I'm still wondering where you got a fourth dimension from.

I believe he was thinking that the numbers represented a single dimensional array of the size represented by the number...? e.g.

3 1 5
2 3 4

=
Array of size 3, array of size 1, array of size 5.

Eh, who knows. He was clearly thinking too far outside the box. That happened to me once... the new radiohead cd had just come out and someone told me "radiohead sold out" and I was panicking thinking I wouldn't be able to get the CD anywhere.

You are correct. I'm actually taking a moment to think why that was my default thought process, because under normal circumstances it isn't. When I finally realized it I was a little disconcerted to say the least.
 

lonelyt

Member
Mar 16, 2003
79
0
0
Thanks everyone for the responses. Jbourne and Torpid cleared up the interviewer's answer for me, I really had no idea about the compare function you could write into objects. And Descarte's being a good sport, he already apologized for reading it wrong.