LinuxQuestions.org
Download your favorite Linux distribution at LQ ISO.
Go Back   LinuxQuestions.org > Forums > Non-*NIX Forums > Programming
User Name
Password
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


Reply
  Search this Thread
Old 08-04-2004, 07:36 PM   #1
shakedown1987
LQ Newbie
 
Registered: Aug 2004
Posts: 3

Rep: Reputation: 0
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
 
Old 08-04-2004, 08:13 PM   #2
kev82
Senior Member
 
Registered: Apr 2003
Location: Lancaster, England
Distribution: Debian Etch, OS X 10.4
Posts: 1,263

Rep: Reputation: 51
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)
 
Old 08-04-2004, 08:31 PM   #3
shakedown1987
LQ Newbie
 
Registered: Aug 2004
Posts: 3

Original Poster
Rep: Reputation: 0
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
 
Old 08-04-2004, 09:01 PM   #4
kev82
Senior Member
 
Registered: Apr 2003
Location: Lancaster, England
Distribution: Debian Etch, OS X 10.4
Posts: 1,263

Rep: Reputation: 51
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.
 
Old 08-05-2004, 08:04 AM   #5
shakedown1987
LQ Newbie
 
Registered: Aug 2004
Posts: 3

Original Poster
Rep: Reputation: 0
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
 
Old 08-05-2004, 08:21 AM   #6
Marius2
Member
 
Registered: Jan 2004
Location: Munich
Distribution: SuSE 9.2, 10.2, 10.3, knoppix
Posts: 276

Rep: Reputation: 31
>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?
 
  


Reply


Thread Tools Search this Thread
Search this Thread:

Advanced Search

Posting Rules
You may not post new threads
You may not post replies
You may not post attachments
You may not edit your posts

BB code is On
Smilies are On
[IMG] code is Off
HTML code is Off



Similar Threads
Thread Thread Starter Forum Replies Last Post
What is the best cryptographic algorithm? Linux.tar.gz Linux - Security 19 05-02-2006 09:54 PM
do you memorize library names? Starch Programming 2 03-25-2005 06:55 PM
Which sorting algorithm? nodger Programming 6 01-28-2005 07:13 PM
Airsnort Algorithm inthefuture Linux - Security 1 08-26-2004 11:01 PM
assistance with an algorithm mandrake_linux Programming 3 07-27-2001 05:03 AM

LinuxQuestions.org > Forums > Non-*NIX Forums > Programming

All times are GMT -5. The time now is 01:53 PM.

Main Menu
Advertisement
My LQ
Write for LQ
LinuxQuestions.org is looking for people interested in writing Editorials, Articles, Reviews, and more. If you'd like to contribute content, let us know.
Main Menu
Syndicate
RSS1  Latest Threads
RSS1  LQ News
Twitter: @linuxquestions
Open Source Consulting | Domain Registration