Pages: 1 2 [3]
|
 |
|
Author
|
Topic: University of Phoenix for undergrad? (Read 17136 times)
|
Morat20
Terracotta Army
Posts: 18529
|
What's a work loop? (I know what a sempahore is. I don't use them in my current job, which means I haven't used them in like...5+ years...but I've had to play with pretty much every form of synchronization and locking issues in the past).
In the context you used, I'd imagine the actual gist of the question is "When you wrote your semaphores, did you stupidly make the assumption that all your processes and threads would be working at the same priority and not partially or totally interrupted by all the other zillion things the PC does?"
|
|
|
|
KallDrexx
Terracotta Army
Posts: 3510
|
If I asked the 'how would you reverse a string question', and they responded:
"I would step through it in reverse and copy it to a new string, because I know that works and I could get it working quickly. If I were given the opportunity to optimize it without impacting the schedule, then I might think about doing it in-place to save the overhead. I might also think about threading it if I didn't need the results immediately."
That person would go high on my list.
If someone said that to me on an interview alarm bells would be going off. That kind of talk smells a lot like they are just reciting buzz words and have no knowledge of how to apply them to real world problems. Threading is ridiculous for reversing a string and optimizing it by doing it in place isn't worth the work unless you are working in a memory constrained embedded application. The point isn't to show how technical and how many terms you recite off the top of your head. The point is to show that you can take a problem, create an algorithm to solve that problem, and know real world uses for the concepts used in the problem. Presenting a solution to a problem in a realistic way is a lot more meaningful than trying to present it in an overly-complicated way like your example, because usually when people try and over-complicate solutions where not needed you end up with shitty code that can't be maintained for no benefit.
|
|
|
|
Morat20
Terracotta Army
Posts: 18529
|
A lot of what's a good idea is industry or doman specific. Modern computers, do you really need to screw around with short ints and risk overflow errors, or just make it long and ignore it?
Well yes and no. Are you bandwidth constrained? Are you working embedded? I'd probably go with short's and bounds checking if I was constantly sending them across a narrow channel.
One thing I hate is being asked questions that have a domain specific response without being given the relevant domain. "How would you do X?" Well, I'd do it Y. "Well didn't you consider that you'd be making a million requests every second?"
No, I didn't. Because you didn't say that. And because I have no idea what you actually do. I can think of systems where you'd be making small requests where'd you want to lock until you got a response. Others where you'd be making large ones, but bandwidth isn't really an issue.
I really hate getting asked questions that are very obviously "Here's a common problem/situation we encounter where we have a standard solution. Guess what it is without knowing what our actual requirements are like!"
|
|
|
|
Sky
Terracotta Army
Posts: 32117
I love my TV an' hug my TV an' call it 'George'.
|
Bottom line seems to be: know what you're doing. There are enough shops out there that you will eventually find one that matches your style. Even the most competent person won't fit every environment properly. Says as much about the interviewer and the corporate culture as the prospect.
|
|
|
|
bhodi
Moderator
Posts: 6817
No lie.
|
One of my co-workers also enjoys asking people hard questions to see how they squirm. I think I've talked about this before, we call it "the gameshow". My favorite example is "Please write a function for me on this whiteboard that, when passed an integer, will determine all prime numbers between 1 and that interger and return them in a list." He has had people just stand up and walk out of the interview before. I really do think he's slightly sadistic, but the point isn't whether you get it right, it's how you react under pressure and to determine the depth of your knowledge on a subject. Getting it right helps, of course. Here are a few from the programming section (in C) What is make? what's it good for (looking for dependancies)?
- What is K&R C? ANSI C? Posix?
- What is signal?
- How does fork() work?
- What is an atime? An mtime? The difference between them?
- What is setuid() for?
- What is system(), why don't you want to use it?
- What is an inode?
- What is an atomic operation?
- what does 'printf("%c", 0["hi"]);' do?
- Behavioral
- Program X is dumping core, what do you do? (looking for gdb, dbx, printf()'s inline, etc).
- throw out some c declarations and see if they can explain what they do
|
|
« Last Edit: April 22, 2011, 12:15:57 PM by bhodi »
|
|
|
|
|
Morat20
Terracotta Army
Posts: 18529
|
Shit, I doubt I could answer any of those. Well, other than fork. I know what fork does. Then again, I haven't used C in like ten years. Hell, I couldn't remember what "internal" was to C# and I last used that only two years ago. (Then again, assemblies and me never did get along).
As for a function doing primes. Shit. Psuedocode wise...Um, something like:
Create a return array. For(x=1;x<=cap;x++) { prime = true; for(y=1;y<x;y++) { if(x mod y == 0) //not a prime prime = false; if(prime == false) return; } if(prime == true) addX to returnList }
I think that would do it. Not in an elegant or particularly efficient way though. Shit, now I sorta want to code it up and see if it works. Offhand, that took about 5 minutes of futzing around and is probably wrong.
In case you're wondering, I made myself work that up because, you know, interviewing and I could use the practice. And when you guys point out how I fucked it up, I didn't just blow a potential job. I also can't remember how to return an array from a function in C. Probably by address, although IIRC C# allows arrays as a return type.
|
|
« Last Edit: April 22, 2011, 12:37:26 PM by Morat20 »
|
|
|
|
|
Miguel
Terracotta Army
Posts: 1298
कुशल
|
If someone said that to me on an interview alarm bells would be going off. You're obviously looking for a different kind of candidate, which is fine. Every company is different....also keep in mind that the stuff I posted earlier was for phone screening criterion, not necessarily what is asked in an in-person interview. ...but the fundamentals don't change. That's the entire point. You don't have a prayer of solving differential equations before you understand the rules of addition and subtraction. You can't design a bridge before you understand how metals behave under stress. As for a function doing primes. Shit. Psuedocode wise...Um, something like:
Create a return array. For(x=1;x<=cap;x++) { prime = true; for(y=1;y<x;y++) { if(x mod y == 0) //not a prime prime = false; if(prime == false) return; } if(prime == true) addX to returnList }
Do you understand why this algorithm (as written) is O(n^2) on input size?
|
“We have competent people thinking about this stuff. We’re not just making shit up.” -Neil deGrasse Tyson
|
|
|
Goumindong
Terracotta Army
Posts: 4297
|
My favorite example is "Please write a function for me on this whiteboard that, when passed an integer, will determine all prime numbers between 1 and that interger and return them in a list."/quote]
And the proper answer is "you really want me to make a prime counting function for you? Are you retarded, why not just break the system?"
Also that prime counting function doesn't work. y has to start at 2 or everything will not be a prime (since all numbers are in the set of integers modulo 1)(i am assuming that x mod y == 0 implies that x is congruent to 0 (modulo y))
Also, you can stop at y<x/2
|
|
|
|
MahrinSkel
Terracotta Army
Posts: 10859
When she crossed over, she was just a ship. But when she came back... she was bullshit!
|
Do you understand why this algorithm (as written) is O(n^2) on input size?
Because any algorithm for finding primes is going to be n 2? If you get an applicant that has an algorithm that isn't, put them in for a Nobel and short the shit out of every company that makes money off of crypto. --Dave
|
--Signature Unclear
|
|
|
Morat20
Terracotta Army
Posts: 18529
|
Do you understand why this algorithm (as written) is O(n^2) on input size?
Yep. It's the nested loops. The outer one runs from 1 to N and the inner one runs from X to N, which means your order is n^2. For each iteration of the outer loop you have to run an inner loop from X to N. So for N = 1000, you run iteration one with 999 iterations in the inner loop, then iteration two with 998....so 1000^2 is roughly correct. However, the best you can really do is emulate -- shit, maybe it's the seive method? -- in which case you can run your inner loop from X to (N/2)+1. Which is probably balanced out by doing more operations inside the inner loop. Finding primes is algorithmically complex. As least it's not an NP problem. Dave: I think that was a demonstrative follow-up question. And it's an important one. I doubt they'll care how efficient or order your off-the-cuff algorithms are, but they'll want to be sure you can explain it. I don't do much optimization work myself, but you'll want to make sure programmers can wander through code and spot the points where you program will be spending the most time. Still have no idea what a work loop is. :)
|
|
« Last Edit: April 22, 2011, 04:20:49 PM by Morat20 »
|
|
|
|
|
MahrinSkel
Terracotta Army
Posts: 10859
When she crossed over, she was just a ship. But when she came back... she was bullshit!
|
This is why I never claimed to be more than a "competent" programmer. I have no problem at all with brute-forcing my way past a problem, and then optimizing only if it turns out I actually need to. For example, that algorithm would work just fine as you weren't running it on too large a number. And if I needed to optimize it, I'd probably make a table with all the primes in the range I was going to encounter and just yank them out of there rather than mess around with trying to shave cycles off the loop.
I'm not a coder by nature, I learned to program because it was a useful set of tools, not because I enjoy thinking in computer logic.
--Dave
|
--Signature Unclear
|
|
|
Strazos
Greetings from the Slave Coast
Posts: 15542
The World's Worst Game: Curry or Covid
|
I'm so glad I dropped programming/CS while I was still in HS. 
|
Fear the Backstab! "Plato said the virtuous man is at all times ready for a grammar snake attack." - we are lesion "Hell is other people." -Sartre
|
|
|
Morat20
Terracotta Army
Posts: 18529
|
This is why I never claimed to be more than a "competent" programmer. I have no problem at all with brute-forcing my way past a problem, and then optimizing only if it turns out I actually need to. For example, that algorithm would work just fine as you weren't running it on too large a number. And if I needed to optimize it, I'd probably make a table with all the primes in the range I was going to encounter and just yank them out of there rather than mess around with trying to shave cycles off the loop.
I'm not a coder by nature, I learned to program because it was a useful set of tools, not because I enjoy thinking in computer logic.
--Dave
lol. "Make a table" was my first thought too. We do a sort of agile process -- lots of rapid prototyping -- so we go with "what works easiest" so we have something that works to play with. Then we go back and optimize. It's kind of a tough balance, because you have to make early design decisions with an eye towards flexibility and efficiency, because if you don't then all the "make it work right now, even if it's crude" shit builds up and you have to go back and redo everything. OTOH, when you do have to go back and redo everything -- you generally know exactly how you want it to look and act, and you've had several iterations of customer feedback to make sure it's on point. I'll be spending my upcoming week on night shift reading .NET in a nutshell so I can remember how the fuck .NET works. I got moved back to it after a two years of ColdFusion and I am abjectly confused again. Updating a mature product, so I'm just sort of thrown in the deep end again. Oh well, looks good on the resume and it'll be fresh if I'm asked about it.
|
|
|
|
Miguel
Terracotta Army
Posts: 1298
कुशल
|
Dave: I think that was a demonstrative follow-up question. And it's an important one. I doubt they'll care how efficient or order your off-the-cuff algorithms are, but they'll want to be sure you can explain it. I don't do much optimization work myself, but you'll want to make sure programmers can wander through code and spot the points where you program will be spending the most time.
Still have no idea what a work loop is. :)
It was, and you answered fine. Based on some of your previous answers you have the basics down pretty well so I wouldn't sweat it too much. You'll do fine.  A work-loop is kernel-speak for a thread which is doled out to device drivers for them to 'do stuff'....it carries with it the normal hazards of thread programming along with certain guarantees (at least in theory) about the state of memory (and the state of hardware) while the work-loop is running. A lot of synchronization is required if multiple independent event-based kernel drivers try to talk to the same hardware at the same time (ostensibly because they are listening to the same hardware notifications), and work-loops provide some minimal guarantee's by convention. They still are a real PITA in practice, just like threads are. 
|
“We have competent people thinking about this stuff. We’re not just making shit up.” -Neil deGrasse Tyson
|
|
|
naum
Terracotta Army
Posts: 4263
|
One of my co-workers also enjoys asking people hard questions to see how they squirm. I think I've talked about this before, we call it "the gameshow". My favorite example is "Please write a function for me on this whiteboard that, when passed an integer, will determine all prime numbers between 1 and that interger and return them in a list." He has had people just stand up and walk out of the interview before. I really do think he's slightly sadistic, but the point isn't whether you get it right, it's how you react under pressure and to determine the depth of your knowledge on a subject. Getting it right helps, of course. Here are a few from the programming section (in C) What is make? what's it good for (looking for dependancies)?
- What is K&R C? ANSI C? Posix?
- What is signal?
- How does fork() work?
- What is an atime? An mtime? The difference between them?
- What is setuid() for?
- What is system(), why don't you want to use it?
- What is an inode?
- What is an atomic operation?
- what does 'printf("%c", 0["hi"]);' do?
- Behavioral
- Program X is dumping core, what do you do? (looking for gdb, dbx, printf()'s inline, etc).
- throw out some c declarations and see if they can explain what they do
Been a few years since doing C professionally, but most of those are stuff any C programmer should be able to rattle off (even to my age addled brain, only a few might be fuzzy but I think I would be able to BS my way through/or come back to me if I gazed at some live (or dead) code). It's been a 6+ years since interviewing for a dev spot, but are developer interviews still conducted like this? Even at the startups I worked for, the interviews were mere formalities to confirm I was not a raging A-hole or beset with any hideous abnormal behavioral pathologies… …the last 2 interviews, I was told late, that it was all "academic" after (a) wearing a polo shirt with a "#!" insignia and (b) detailed what work I did in "Korn shell"… Back in mainframe days, remember some harrowing interviews where you got tag-teamed in a round-robin drilling, then were given code and asked to decipher and debug -- "interviews" that lasted 3-4 hours or more. In one, for a job that I turned down, one guy went at me in rapid fire fashion, peppering me with ABEND root-cause practices -- S0C4, S0C7, etc.… in which I answered but then retorted, "Wow, you guys sure have a lot of programs crashing here, what's going on with your development/support process?"… A few months back, I was at a Ruby conference and one of the speakers gave a talk on their hiring practices at a Ruby on Rails company (Hashrocket, I believe it was) -- their "interview" sessions last an entire week, 40+ hours, where the candidate is required to take some vacation time (if he/she has another job already), pair up with a developer (they practice the "pair programming" discipline devotedly), and then do lunches & dinners with the rest of the company team. The "office" looks more like a house rented by college kids with ping pong/pool tables, karaoke & wii/xbox/ps3 and the speaker bragged about how they spend hundreds of dollars on groceries -- not that they require you to "eat in", just that they want to make it more convenient not to head out for lunch. Sounds a little too intimate for my liking, but I wonder if this type of practice will ever become more mainstream…
|
"Should the batman kill Joker because it would save more lives?" is a fundamentally different question from "should the batman have a bunch of machineguns that go BATBATBATBATBAT because its totally cool?". ~Goumindong
|
|
|
Ingmar
Terracotta Army
Posts: 19280
Auto Assault Affectionado
|
Sounds a little too intimate for my liking, but I wonder if this type of practice will ever become more mainstream…
s/intimate/creepy
|
The Transcendent One: AH... THE ROGUE CONSTRUCT. Nordom: Sense of closure: imminent.
|
|
|
Miguel
Terracotta Army
Posts: 1298
कुशल
|
Here's another interview question I was told that I always liked (although I don't use it in screens or live interviews any longer):
How is the number 5 represented in base -1?
|
“We have competent people thinking about this stuff. We’re not just making shit up.” -Neil deGrasse Tyson
|
|
|
Morat20
Terracotta Army
Posts: 18529
|
Here's another interview question I was told that I always liked (although I don't use it in screens or live interviews any longer):
How is the number 5 represented in base -1?
Base negative one? How do you have a number system based on a negative? How do you even HAVE a base 1 number system? I guess base 1 means all you have is 0, so five would have to be 00000, as you'd just count up the number of zeros. I'm guessing I don't understand the question somehow.
|
|
|
|
Miguel
Terracotta Army
Posts: 1298
कुशल
|
Here's another interview question I was told that I always liked (although I don't use it in screens or live interviews any longer):
How is the number 5 represented in base -1?
Base negative one? How do you have a number system based on a negative? How do you even HAVE a base 1 number system? I guess base 1 means all you have is 0, so five would have to be 00000, as you'd just count up the number of zeros. I'm guessing I don't understand the question somehow. Start with the definition of any number in any base, and the answer falls out. How does base 10 work? What does each digit represent? What about base 2?
|
“We have competent people thinking about this stuff. We’re not just making shit up.” -Neil deGrasse Tyson
|
|
|
Morat20
Terracotta Army
Posts: 18529
|
Start with the definition of any number in any base, and the answer falls out. How does base 10 work? What does each digit represent? What about base 2?
That's my point -- the base system defines range of integers represented by one "place". So in binary you can represent two values -- 0 and 1. In Base 10, you can represent 10 values in a single slot -- 0 through 9. Base 16? Zero through F. Base one would be that each slot is represented by a single value (0) thus 5 in Base 1 would be 00000. I have no idea how one would represent a negative number of values in a single slot.
|
|
|
|
Count Nerfedalot
Terracotta Army
Posts: 1041
|
That reminds me not an of an interview question but a joke:
Why do "real" programmers sometimes get Christmas and Halloween confused?
Because OCT31 = DEC25 is a true statement
|
Yes, I know I'm paranoid, but am I paranoid enough?
|
|
|
Miguel
Terracotta Army
Posts: 1298
कुशल
|
That's my point -- the base system defines range of integers represented by one "place". So in binary you can represent two values -- 0 and 1. In Base 10, you can represent 10 values in a single slot -- 0 through 9. Base 16? Zero through F.
You have basically stated the idea of the answer, but you have to throw away your concepts for what the base representation of a number 'should be'. I'll give the answer in a spoiler if you want to think about it some more:
|
“We have competent people thinking about this stuff. We’re not just making shit up.” -Neil deGrasse Tyson
|
|
|
|
Pages: 1 2 [3]
|
|
|
 |