0

so this might be a weird question, and it might be better to ask a psychologist but i thought since they probably wouldn't know much about programming, i could ask you guys. So i have an assignment and it asks me to solve a problem using an algorithm. So i finish the problem and then usually look online for better algorithms and see how people did theirs. But i was working on a problem that i had solved to about maybe 50%, but then i ran into a wall.

So i looked online and found this great algorithm, i want to use it (i have already implemented it) but i feel a bit jealous and guilty that i couldn't think of a way to solve it and like i have done something wrong. I will obviously cite where i got the algorithm from, so i'm not cheating. How should i view something like this, try to what i learned from the algorithm and try to apply it in the future? Do you guys ever feel like oh i copied it and i was unable to think about it on my own. I have like an ocd about this stuff. Thanks for any help and support

  • 2
    SO is not the right place to ask this. But anyways, when you find that someone else have done a good implementation then read through it and then use it as a reference for your implementation. Don't just copy the entire code – arunmoezhi Mar 21 '14 at 03:27
  • When it comes to getting things done, I usually do the opposite: start by looking online for the solution, then, if I don't find it, feel guilty that my Google skills are insufficient. :) – Timothy Shields Mar 21 '14 at 03:27
  • That sounds like a great life lesson. You won't always be able to think of everything all the time. I was once asked a question in an interview and I gave them the only thing I could think of at the time. 4 years later it occurred to me what the better answer was, and a quick Google confirmed it. – Mark Ransom Mar 21 '14 at 03:27
  • Do you want to reinvent wheel or contribute by taking steps based on other people experience? Choose what makes you feel comfortable! – Riz Mar 21 '14 at 03:29
  • @MarkRansom What was the question? – G. Bach Mar 21 '14 at 03:34
  • Giving credit to the source is enough for not being guilty at all. And nobody was born knowing everything: today internet is a wonderful source of information. Think as being employed: would you be more guilty in developing your algorithm by your own in 2 weeks, or in finding it and having your work done in few hours? And after that you know it, it is part of your knowledge and you will be more capable to discover something really new. Final observation: even if you discover "something" by your own, if it is patented, that's doesn't matter at all - royalties are due as well. – Sigi Mar 21 '14 at 03:34
  • @G.Bach how to sort a singly linked list. And just to show I'm not always so stupid, I came up with this answer within 5 minutes of the question, having never heard of the problem before: http://stackoverflow.com/a/232248/5987 – Mark Ransom Mar 21 '14 at 03:38
  • If you want to learn more and have the time, after you have finished your first version based on another answer, try and create a second one, based on the ideas in the first version, but without referring to it or the answer you previously referred to. If not successful, refer to the other answer again and repeat. This should give you at least as thorough a learning experience as if you had solve the problem for yourself, and the experience of rewriting the same algorithm again and again may improve your programming style, as you see the result of small variations in implementation. – mcdowella Mar 21 '14 at 05:54

2 Answers2

2

Consider this: if you had to always start from scratch and reinvent everything someone else figured out before you you'd still be sitting in a cave, hunt and gather plants for food - you get the picture.

Someone else invented the computer but you don't feel guilty about that, do you? There are a number of algorithms out there that are very fundamental and you use them even when you don't realize it - searching, sorting, memory management etc.

Copying is progress, it gives you the time to solve the new problems and someone else may end up copying your solutions if they are good.

...

However to get good you have to grunt through the basics and really get them. And blatantly copying won't give any better of a clue how to come up with your own. On top of that copying may be illegal - if a certain algorithm is protected by a patent for example.

My take is to use your better judgement and don't be too shy to copy but make sure you really understand what you're copying and strive to better yourself so that eventually others find you worth copying.

Sten Petrov
  • 10,943
  • 1
  • 41
  • 61
0

Referring to algorithms from the internet is obviously not cheating. B'coz that is the reason why a noble guy has uploaded it. You should be certain that you would not always be able to think the best algorithm even if you have the right knowledge. Algorithms are like art and it comes the best when you are in the right state of mind... Hence don't worry and enjoy programming.

Messiah
  • 99
  • 7