|
Thread Rules 1. This is not a "do my homework for me" thread. If you have specific questions, ask, but don't post an assignment or homework problem and expect an exact solution. 2. No recruiting for your cockamamie projects (you won't replace facebook with 3 dudes you found on the internet and $20) 3. If you can't articulate why a language is bad, don't start slinging shit about it. Just remember that nothing is worse than making CSS IE6 compatible. 4. Use [code] tags to format code blocks. |
Need some help finding an article.
A while ago I read this article that did pretty in-depth comparisons between optimization performance of g++ (don't remember which versions), VS 2008/2010, maybe 2005 and Apples compilers as well.
Did anyone read this as well and knows where I can find it again?
|
Edit: Figured it out!
|
I am not familiar with Python but it looks like
return x += i
should be
return x + i
|
On December 17 2012 04:13 Fission wrote:Show nested quote +On December 17 2012 04:10 Fission wrote: I don't really get what all the fuss is about "getting a CS degree". I took a bunch of cs courses in university for easy credits due to my experience, and I found the courses to be comically trivial and mostly worthless. Tons of emphasis on completely unrealistic nonsense, no talk of coding design or practices, professors who had never worked as programmers etc. There were no courses on many widely used industry standard technologies. There were no .net courses, no database applications courses (just theory), zip. Just shitloads of C, C++, and a few java courses. The "really hard" algorithms and analysis compsci courses were laughably easy compared to honors real analysis or any high level honors math classes.
I went to one of the top canadian engineering schools
I actually spent some time teaching CS at a Canadian Engineering School and I'd like to share my experiences with you guys. For reference I got my undergraduate degree in the US (in computer science) and my graduate degree in Canada. I originally learned programming in highschool. Partially self taught while auditing a few courses in my home town.
One of the most frustrating things for me as a teacher, was the lack of programming experience the students had. I taught a series of third year courses, but spent an in-ordinate amount of time have to review what I felt were relatively basic concepts (pass by reference, linked lists, etc). This made it extremely difficult to teach more advanced concepts (such as using linear algebra to perform refraction in a ray tracer). I was also frustrated by the poor quality of the code and limited knowledge of what I felt were fairly standard coding practices (refactoring for example).
While I was there I spent some time talking to the other faculty about the problems I felt in the students we were graduating (many would graduate without understanding basic concepts). There were a number who shared my sentiments or went the extra mile to teach their students; sadly this was the minority. The majority of the faculty were concerned with one of two opinions: 1) teaching is a chore and should be pawned off on under prepared, over worked gradstudents so they could focus on what really mattered: research, or 2) they were here to teach the science of computers, the theory, not to teach students how to program (they believed that was what differed them from trade schools).
The former opinion is actually the easier one to understand. All the rewards a professor received (grants, tenure, etc) are keyed to their research with teaching playing a back seat in the academic world. My brother, who is an economist, would say: they've been incentivized to spend as little effort on teaching as necessary. I think you can influence this some at individual universities, but as this is really the pervasive feeling of the larger academic community it'll be hard to make progress here.
The latter opinion is the one that really frustrated me. Having been at a couple different universities I've found this is a constant debate in the computer science curriculum. It tends to have it's roots in whether the computer science department grew out of the university's electrical engineering curriculum or mathematics curriculum. Those that grew out of engineering departments tend to have a stronger focus on labs and producing actual code, where as those that grew out of mathematics tend to have a stronger emphasis on theory. By now these departments are mature enough at almost all universities that they're a blend of the two, but the roots tend to show a little.
I don't know how to overcome tradition, and eventually I left to work in industry. As someone who's a solid developer at a major tech company and has interviewed over a hundred college graduate candidates I can safely say the following: There is no trade school that feeds into big companies like Google, Facebook, Amazon, or Microsoft. That place doesn't exist. These companies hire (aggressively) from major universities and colleges. I can assure you they care both about theory and about actual code (neither is left out).
If you actually want some advice on getting a job at such a place, I'd certainly say the CS degree can't hurt (in fact, it'll probably help get a recruiter's attention). However, far more important is your level of skill. Programming is a craft, and if you don't practice it you will not get better. I would recommend you write code every day. Work on your own projects or contribute to open source. Every time you're using a computer and you think there should be a programming way to make it easier, go learn that way. Doesn't matter if learning takes longer because you will benefit from the knowledge and experience.
|
Does anyone know how to search for a value and report its position in an array in java? Thanks.
|
Does anyone know how to search for a value and report its position in an array in java? Thanks.
for (int i=0; i<array.length; i++) { if (array[i] == value) { return i; } }
Keep in mind that if value is a String, you'll have to use array[i].equals(value) instead of array[i] == value.
|
Or a method, depending on return type.
public int getValue(int index) {
return array[index];
}
|
On December 20 2012 02:55 Thorakh wrote:Show nested quote +Does anyone know how to search for a value and report its position in an array in java? Thanks. for (int i=0; i<array.length; i++) { if (array[i] == value) { return i; } }
Keep in mind that if value is a String, you'll have to use array[i].equals(value) instead of array[i] == value.
Or binary search, or radix search.... wait... this is java, there's an api that will do this: http://docs.oracle.com/javase/6/docs/api/java/util/Arrays.html
If its unsorted, you can use Array.toString, then a String method like indexOf.
|
I just got from a job interview and I was asked with this problem
+ Show Spoiler +We are developing Calculator application it supports only 4 operators: +, -, *, / the input text can take a string as input containing more that one operator when the user clicks on "=" button, the application will parse and produce the output give me all the possible scenarios where you'll have to handle the exceptions to make this calculator non-crashable
my answers were
+ Show Spoiler +1) if there two or more operators used in succession i.e. (1 + + 1) 2) if the string input is not parsed to int or float 3) if the input is non numerical (not accepted, same as #2) 4) the input should be considered as long int to handle more values and also the output (not an error, duh =.=) 5) the string should parse negative numbers correctly 6) there should only be one decimal point 7) the input should end with a number i.e. (1 + is not accepted) 8) the input should have at least one operation used (not accepted, since you can input 1 then press =) 9) the calculator must abide by mathematical laws. (i.e. cannot divide by 0) 10) the calculator should have a limit of decimal places as answers to avoid infinite loops by repeating decimals 11) more about logical error handling, the calculator should follow the MDAS, multiplication, division, addition/subtraction 12) if parenthesis is used, it should also calculate in the proper order 13) decimals with no numbers must be avoided i.e. (5 + . + 9)
are there more errors that i have missed?
|
Hyrule19083 Posts
The simple answer is to parse it out into a tree. If there are any unbalanced nodes it's an invalid equation. Not sure if this would be accepted as just an answer but you can say "also you can make it a tree which should cover most issues" or whatever.
|
haven't thought about that, but i think he wanted me to enumerate the 'issues' =/
|
Hyrule19083 Posts
Yeah that's what I figured after I wrote my reply. 13 is redundant though because . doesn't parse to a number and it's not an operator.
|
To be fair, questions like that are rarely about the answer and almost definitely about the thought process. If you're jumping around into different areas while giving errors, it looks bad on you. You should've been asking more questions about what the calculator can do, rather than focusing on solving it. It doesn't really matter if you get all the cases as long as you show you understand how to test something.
The description is asking you to make sure the calculator doesn't crash, nothing about the logic of the operations. You should have clarified this immediately.
You should also ask how the calculator parses numbers, or are you implementing that functionality, because then you have to handle cases such as " - - 1 " or " 1 - + 0 " being valid operations since " - - 1 " could be handled as just " 1 ".
Anyways, having a structured approach would've looked good on you.
- validate this string only has legal characters ( numbers + operators only )
- validate this string is a mathematical operation ( building a tree )
- validate that all the mathematic operations produce real numbers ( check for division by 0 )
* actually, I think it doesn't have to be a balanced tree entirely. It can be balanced only for * and / operations, but as long as the + and - operators remain on the left side of a node, the equation could still be valid. No parentheses though so that should be clarified.
On December 20 2012 13:19 Craton wrote: You could've also tackled regional support, where different countries transpose the meanings of periods and commas.
This would've been awesome to note. XD
|
You could've also tackled regional support, where different countries transpose the meanings of periods and commas.
|
Hyrule19083 Posts
On December 20 2012 13:16 Blisse wrote:To be fair, questions like that are rarely about the answer and almost definitely about the thought process. If you're jumping around into different areas while giving errors, it looks bad on you. You should've been asking more questions about what the calculator can do, rather than focusing on solving it. It doesn't really matter if you get all the cases as long as you show you understand how to test something. The description is asking you to make sure the calculator doesn't crash, nothing about the logic of the operations. You should have clarified this immediately. You should also ask how the calculator parses numbers, or are you implementing that functionality, because then you have to handle cases such as " - - 1 " or " 1 - + 0 " being valid operations since " - - 1 " could be handled as just " 1 ". Anyways, having a structured approach would've looked good on you. - validate this string only has legal characters ( numbers + operators only )
- validate this string is a mathematical operation ( building a tree )
- validate that all the mathematic operations produce real numbers ( check for division by 0 )
* actually, I think it doesn't have to be a balanced tree entirely. It can be balanced only for * and / operations, but as long as the + and - operators remain on the left side of a node, the equation could still be valid. No parentheses though so that should be clarified. Show nested quote +On December 20 2012 13:19 Craton wrote: You could've also tackled regional support, where different countries transpose the meanings of periods and commas. This would've been awesome to note. XD the tautology is like
EQUATION: EXPRESSION EXPRESSION: EXPRESSION EXPRESSION: (EXPRESSION) EXPRESSION: NUMBER EXPRESSION: EXPRESSION OPERATOR EXPRESSION NUMBER: a number OPERATOR: + - * /
So that would cover just about everything (except inputting ++1 or something like that). So then you get just one case to check for. The rest works itself out.
|
I think the discussion of icystorage's specific interview question so far has been excellent in terms of solving the specific problem. Since you're not likely to need this specific knowledge again, though, here would be my analysis of the general case of which this question is a specific example:
- Blisse's point is very important. Past a certain point, your interviewer does not care whether your conclusion is correct. Forgetting a semicolon or missing one of several obscure edge cases is not going to sink your prospects. What your interviewer wants to see is that you approach a problem correctly.
- Elegance in a solution is one of the hallmarks of a good programmer. Your approach seems like it was to figure out every specific instance in which a string would evaluate as invalid, whereas a better solution is almost always to find the smallest possible set of general rules from which those specific instances arise. Such solutions are easier to maintain due to their simplicity, and they're also much less likely to have bugs, because they're less likely to have holes. If you check specifics, you'll only recognize specifics. If you check generalities, you'll recognize all specifics that match those generalities, even the ones you didn't think of.
- That being said, being able to reel off a list of invalid states like you did is actually really good, because that's what you do after you've design an algorithm. You get all crazy paranoid and put on your tinfoil hat and think about malicious users entering "-----------------------------------------------------------------1++++++++++++++++++++-+-+-+-+-++++3=x". If you can present an elegant solution and then go through a list of a couple of normal cases and a couple of crazy edge cases and explain why your solution handles all of them correctly, then you've got an excellent response.
So I'd say your response wasn't bad per se, it was just missing the important middle step. The way you answered is the way I would want someone I was considering for a QA position to answer.
|
honestly, this is my first job interview, i really got mentally blocked and was very nervous. there were theoretical questions like what's the difference between c and c++? what's in c++ OOP not in Java OOP? how do you make a class non-inheritable? most of the questions i got stumped and started to make up using stock knowledge.
i was kinda disappointed with the given problem. i guess the interviewer wanted me to enumerate the errors since when i showed him my answers he said i only got 9 right and asked me if I could get a tenth answer but I didn't. after that, i immediately went to TL and ask you guys what I missed and where I went wrong.
thank you so much for your replies. this really helps me in the future. i always approached my error handling in terms of looking for when i get errors, not the 'middle step' as you stated. the tree answer really enlightened me. thanks!
|
Interviewing is itself a really important skill. It's fine to have an interview that doesn't go well as long as you learn something from it.
|
On December 20 2012 20:30 icystorage wrote: honestly, this is my first job interview, i really got mentally blocked and was very nervous. there were theoretical questions like what's the difference between c and c++? what's in c++ OOP not in Java OOP? how do you make a class non-inheritable? most of the questions i got stumped and started to make up using stock knowledge.
i was kinda disappointed with the given problem. i guess the interviewer wanted me to enumerate the errors since when i showed him my answers he said i only got 9 right and asked me if I could get a tenth answer but I didn't. after that, i immediately went to TL and ask you guys what I missed and where I went wrong.
thank you so much for your replies. this really helps me in the future. i always approached my error handling in terms of looking for when i get errors, not the 'middle step' as you stated. the tree answer really enlightened me. thanks! wow wtf, I would have aced that interview ;_;
-difference between C and C++: mainly OOP. (Also lambdas, generics, much bigger standard library, etc) -C++ OOP not in Java: multiple inheritance, "rule of three" member functions, operator overloading. -how do you make a class non-inheritable? make it "final".
those are practical questions to me lol. Theoretical questions would be: name three O(log(n)) sorting algorithms... Difference between linked list and doubly linked list...
|
i actually answered some incompletely.
i was like 'the main difference about c and c++ is mainly about c++ being OOP' 'how?' boom. stumped. yeah i got the 'final' one correct tho i first answered to make it abstract and he said it was wrong (i was about to bang my head on the desk) then i said convert it to final.
yeah he also asked me the difference between array and ArrayList
|
|
|
|