We pay for user submitted tutorials and articles that we publish. Anyone can send in a contributionLearn More
I have been wanting to write this series of articles for a long time. Over the years I have come across very bad code examples and I have always wanted to share them with you guys, kind of in the way of "Watch and DON’T learn" :).
Everything you are about to see in this series is based on my personal experience and completely real, so before we begin I have only one request:
Don’t try this at home!
Software Managers all around the globe, need to have some metric to estimate their workers. Sometimes the management event wants to create a precise and measurable way to know the programming progress and the developers productivity and performance. One of those methods is called SLOC – Source Lines Of Code. This metric is used measure the size of the software by counting the lines of the program source code. Some managers tend to love SLOC because it can be automated so it requires very little effort and the effect of it can be visualized. That is exactly what managers like! it is easy and it can be easily inserted into their reports, what could be better than that? It seems just perfect.
This is the fifteen post of the series of programming job interview challenge, 37 readers provided an answer to job interview challenge #14. As you can understand from the title, I have a little announcement to make, but lets first head on to last weeks question answers.
This time, Omar was the first one to provide an efficient and correct detailed answer:
Draw a line from the single point (any direction will do).
Count the number of times that this line intersects with lines of the polygon.
An even count (including zero) indicates that the point is outside of the polygon.
An odd count indicates that the point is inside the polygon.
Here is a nice image taken from Jon von Gillern blog post
The fourteenth post of the series of programming job interview challenge is out, 79 comments with answers were provided to job interview challenge #13. We didn’t publish a question last week due to a sever lack of time, so another week is gone and here we are again.
Mark R was the first to provide a correct and detailed answer (which I can quote here):
As you examine each character, classify it as either an opening or closing bracket. If it’s an opening bracket, push it onto a stack. If it’s a closing bracket, pop the top character off of the stack; if the stack was empty, or the character was not the matching open bracket, then return an error. At the end of input, if the stack is empty, you have a legal expression.
C++ has a built-in stack class, so this becomes a trivial problem. I’m not sure about other languages. You could always simulate a stack by appending and deleting characters from the end of a string.
So, in one word, the most efficient answer is use a stack. Here is a nice image which was crafted by David Tchepak in his blog post Brackets, braces, parentheses, and other such creatures:
During the Job Interview Challenge Series we are running here at Dev102.com, we usually get some comments from readers who think that the quality of a specific question is not good. Here are some of those comments:
On the other hand, many readers provided answers to the questions and enjoyed participating in those challenges. Some thought that the questions are very good:
The sixth of the series of programming job interview challenge is out. Other then commenting the solution, I remind you that you can post the solution on your blog and get a link next week!
Here is the solution to the previous challenge:
Two-way merge sort (External Sorting) : The idea is breaking the big file into subfiles, sorting them and than merging them back together. In the first pass read one page at a time, the records in the page are sorted (quicksort for example) and the page is written back to disk. in subsequent passes, each pair of sorted output from the previous pass are read and merged to produce sorted subfile twice as long:
1. Read each page, Sort it, Write it back
2. while more than one sorted subfile:
while subfiles from previous pass left to merge:
– Choose next two subfiles from previous pass
– Read each subfile into a memory page (one page at a time)
– Merge the subfiles (remember each of them is already sorted), write output to a memory page
– Write output page to disk when needed.
This is the fifth challenge in the series of programming job interview challenge. As usual, we’ll provide an answer to the previous challenge and give you a new challenge to keep you busy this week. Other then commenting the solution, I remind you that you can post the solution on your blog and let us know about it […]
This is the fourth post in the series of programming job interview challenge. Today, I will provide the answer to job interview challenge #3, talk about readers answers (all of the comments are now approved) and give you a new challenge. So, lets get into business:
The correct answer to challenge #3:
This post is third in the series of programming job interview challenge, if you are not yet familiar with these series please take your time and read:
Well, last weeks challenge was very successful, all of the comments which contain answers to the question are now approved and can be viewed in challenge #2 post.
Last week I posted A Programming Job Interview Challenge which was very successful, both in the amount of page views and, in the amount of comments and mails we received. This fact made us (the Dev102 team) decide to add a weekly programming job interview challenge column to www.Dev102.com.
Copyright © 2012 Dev102.com
Breeze : Designed by Amit Raz and Nitzan Kupererd