Programming This forum is for all programming questions.
The question does not have to be directly related to Linux and any language is fair game. |
Notices |
Welcome to LinuxQuestions.org, a friendly and active Linux Community.
You are currently viewing LQ as a guest. By joining our community you will have the ability to post topics, receive our newsletter, use the advanced search, subscribe to threads and access many other special features. Registration is quick, simple and absolutely free. Join our community today!
Note that registered members see fewer ads, and ContentLink is completely disabled once you log in.
Are you new to LinuxQuestions.org? Visit the following links:
Site Howto |
Site FAQ |
Sitemap |
Register Now
If you have any problems with the registration process or your account login, please contact us. If you need to reset your password, click here.
Having a problem logging in? Please visit this page to clear all LQ-related cookies.
Get a virtual cloud desktop with the Linux distro that you want in less than five minutes with Shells! With over 10 pre-installed distros to choose from, the worry-free installation life is here! Whether you are a digital nomad or just looking for flexibility, Shells can put your Linux machine on the device that you want to use.
Exclusive for LQ members, get up to 45% off per month. Click here for more info.
|
|
08-04-2004, 07:36 PM
|
#1
|
LQ Newbie
Registered: Aug 2004
Posts: 3
Rep:
|
Do you memorize the algorithm?For...
hi
This thread may seem silly to some,but it's this problem is really getting on my nervs
When you read source code for whatever kind of program,do you try to
memorize the algorithm?How long does it stay in your memory?
For example,when I read TFTP source code on linux,I tried to remember
the program's algorithm(by memorizing I don't mean the names of variables and function, but instead what function calls what function,where in program is function called and what for)
Anyway,I noticed that in week or two after remembering the algorithm(and not thinking about it),I almost completely forgot it
This wouldn't be such a problem if not for the fact that programming is all about algorithms.
Do you try to memorize algorithms or do you keep them in memory only for the time you need them,and if later need for particular algorithm arises,you learn it all over again?
any and all help will be appreciated
|
|
|
08-04-2004, 08:13 PM
|
#2
|
Senior Member
Registered: Apr 2003
Location: Lancaster, England
Distribution: Debian Etch, OS X 10.4
Posts: 1,263
Rep:
|
by shakedown1987
When you read source code for whatever kind of program,do you try to
memorize the algorithm?
i generally only read the source to something if im interested in how it does something, if i see something generic and think "wow, thats really good" like a new data structure then i tend to remember it otherwise i'll forget in about 5 minutes, i only remember function calls if they're functions that i call regularly and i only remember the names not the arguments - i had to look in a man page yesterday to find the printf format specifier for a hex number.
Do you try to memorize algorithms or do you keep them in memory only for the time you need them,and if later need for particular algorithm arises,you learn it all over again?
it depends what you mean by algorithm, i remember generic stuff like
a) inserting/deleting to/from a linked list
b) searching trees
c) greedy algorithm
d) etc...
but i dont remember code for them, i remember the principles and then i write the code. if by algorithms you mean things like
a) opening a tcpip listening socket
b) creating a window in (insert favourite gui library here)
c) talking to an HTTP server
then i remember them if im using them at the time but if im not using them then i forget very quickly, and its not possible to remember everything like this because there are more APIs out there than words in the english language(well maybe not but there are a lot)
|
|
|
08-04-2004, 08:31 PM
|
#3
|
LQ Newbie
Registered: Aug 2004
Posts: 3
Original Poster
Rep:
|
Can you give me an exaple of how high level algorithm you memorize should be?For example,greedy algorithm or searching trees...what about it is stored in your memory?
I know I'm asking alot,but it would really help alot
cheers
|
|
|
08-04-2004, 09:01 PM
|
#4
|
Senior Member
Registered: Apr 2003
Location: Lancaster, England
Distribution: Debian Etch, OS X 10.4
Posts: 1,263
Rep:
|
its really hard to differentiate between what i remember and what i work out when i think about it, but here goes - this is what i think i remember
greedy)
Code:
loop
if(not solved) tryNextSolution()
end loop
searching trees)
Code:
function search(Node)
criterionMatched?()
for_all(Node.Children) search()
end function
singly linked list)
Code:
object node
node ptr next
data
end object
i dont actually remember that exact psuedocode, i remember the principles, the psuedocode is the only way i know to write it in words though.
Last edited by kev82; 08-04-2004 at 09:03 PM.
|
|
|
08-05-2004, 08:04 AM
|
#5
|
LQ Newbie
Registered: Aug 2004
Posts: 3
Original Poster
Rep:
|
But doesn't the fact that you only remember what must be done,and not how to actually implement it in code,means that
you must reinvent the same wheel everytime you try to implement the same algorithm(provided you
don't keep around source code for very long)?
I googled for greedy algorithm and basicly there are two ways you could remembered it.
A
Code:
1-Start with nothing.
2-at every stage without passing the given amount.
add the largest to the coins already chosen.
or
B
Code:
1-Initially the set of chosen items is empty i.e., solution set.
2-At each step
a)item will be added in a solution set by using selection function.
b)IF the set would no longer be feasible
-reject items under consideration (and is never consider again).
c)ELSE IF set is still feasible THEN
-add the current item.
It seems that greedy algorithm is ussually short.But if you were to remember 2000+ lines of code algorithm,then the B could get awfully large?
Which one would you choose to remember?
I really am sorry for taking your time
|
|
|
08-05-2004, 08:21 AM
|
#6
|
Member
Registered: Jan 2004
Location: Munich
Distribution: SuSE 9.2, 10.2, 10.3, knoppix
Posts: 276
Rep:
|
>But doesn't the fact that you only remember what must be done,and not how to actually implement it in >code,means that you must reinvent the same wheel everytime you try to implement the same algorithm
>(provided you don't keep around source code for very long)?
Interesting. Well, in my opinion it is actually so that you reinvent the wheel again and again,
but it sounds more awful than it really is, since the main part of this is done automatically by
the brain. That's in fact how memory works - the brain doesn't really store all the details,
but only the significant ones (whatever they may be, words, pictures, smells - depends on the person),
and when remembering, uses theses details as kind of landmarks, and the missing details are
reconstructed (not recalled) using these landmarks.
As far as I'm concerned, memorizing an algorithm means I'm keeping
a. kind of flowcharts of the various components and how they are connected
b. name of the components
c. name of the algorithm - because the most important ability when trying to appear intelligent is
not to memorize things exactly, but rather know where to look them up.
If you're interested in the brain, you may want to take a look at "The working brain" by Aleksandr
Luria. You will, for example, find a copy at amazon.com.
HTH
BTW why do you ask such things?
|
|
|
All times are GMT -5. The time now is 01:53 PM.
|
LinuxQuestions.org is looking for people interested in writing
Editorials, Articles, Reviews, and more. If you'd like to contribute
content, let us know.
|
Latest Threads
LQ News
|
|