How create algorithms

F

FloWo3

Hi,

how do you create (design) algorithms.
I'm talking about thinking about it and come to an idea.

Tanks, FroxX
 
K

Karl Heinz Buchegger

FloWo3 said:
Hi,

how do you create (design) algorithms.
I'm talking about thinking about it and come to an idea.

Paper, lots of paper.
Pencil, lots of pencil
Trying to solve the problem on Paper
and pencil. Once I can solve the problem
on paper -> repeat the whole thing and
monitor what I do.

Once you think you have an algorithm, go through
it with someone else. It really doesn't matter if
that someone understands what you are talking about.
Just having the need to express your ideas in talken
language is enough. You can even talk to a teddy bear
and it works.
 
P

Pierre Couderc

FloWo3 said:
Hi,

how do you create (design) algorithms.
I'm talking about thinking about it and come to an idea.

Tanks, FroxX

The morning in the bed, a quarter of hour before the ring bells.
I take the problem (usually the algoritm) of the day before, and usually
I get it...


Pierre Couderc
 
O

osmium

FloWo3 said:
how do you create (design) algorithms.
I'm talking about thinking about it and come to an idea.

My most effective tool is my sub-conscious. I try to understand what the
problem is and then go on with my life. If I'm lucky, which I quite often
am, a solution will come to me in the next few hours.
 
W

Will Twentyman

FloWo3 said:
Hi,

how do you create (design) algorithms.
I'm talking about thinking about it and come to an idea.

I figure out how to do it by hand, keeping track of *everything* I do
and *everything* I have to remember. If you don't know how to do it
yourself, you don't have an algorithm.
 
H

Howard

Karl Heinz Buchegger said:
Paper, lots of paper.
Pencil, lots of pencil
Trying to solve the problem on Paper
and pencil. Once I can solve the problem
on paper -> repeat the whole thing and
monitor what I do.

Once you think you have an algorithm, go through
it with someone else. It really doesn't matter if
that someone understands what you are talking about.
Just having the need to express your ideas in talken
language is enough. You can even talk to a teddy bear
and it works.

Yeah, but my teddy bear keeps correcting me..it's really annoying! :)

-Howard
 
M

Mike Wahler

Karl Heinz Buchegger said:
Paper, lots of paper.
Pencil, lots of pencil
Trying to solve the problem on Paper
and pencil. Once I can solve the problem
on paper -> repeat the whole thing and
monitor what I do.

Once you think you have an algorithm, go through
it with someone else. It really doesn't matter if
that someone understands what you are talking about.
Just having the need to express your ideas in talken
language is enough. You can even talk to a teddy bear
and it works.

:) This isn't as strange as it might sound to some. Since
I mostly work alone at home, I usually can't discuss problems
'face to face' with someone. When I get stuck, sometimes I'll
'consult' with my cat. Of course his only answers are "Meow"
and perhaps rubbing against my leg. But As Karl says, just
vocalizing an issue can help uncover a solution. And Kitty
seems to appreciate the attention. :)

-Mike
 
R

Richard Pennington

Mike Wahler wrote:
[snip]
:) This isn't as strange as it might sound to some. Since
I mostly work alone at home, I usually can't discuss problems
'face to face' with someone. When I get stuck, sometimes I'll
'consult' with my cat. Of course his only answers are "Meow"
and perhaps rubbing against my leg. But As Karl says, just
vocalizing an issue can help uncover a solution. And Kitty
seems to appreciate the attention. :)

-Mike

My cats seem to have a one track mind:

Me: "What do you think about using multiple traversal pointers
and choosing the one or more that succeed?"
Cat:"Time to eat already! Meow!"

Me: "Is it better to use a global hash table or one for each scope?"
Cat:"Time to eat already! Meow!"

....

-Rich
 
S

Shailesh Humbad

FloWo3 said:
Hi,

how do you create (design) algorithms.
I'm talking about thinking about it and come to an idea.

Tanks, FroxX

Recipe for Algorithm

20 parts reading
1 part inspiration
99 parts perspiration

adjust to taste
 
D

David Hilsee

Richard Pennington said:
Mike Wahler wrote:
[snip]
:) This isn't as strange as it might sound to some. Since
I mostly work alone at home, I usually can't discuss problems
'face to face' with someone. When I get stuck, sometimes I'll
'consult' with my cat. Of course his only answers are "Meow"
and perhaps rubbing against my leg. But As Karl says, just
vocalizing an issue can help uncover a solution. And Kitty
seems to appreciate the attention. :)

-Mike

My cats seem to have a one track mind:

Me: "What do you think about using multiple traversal pointers
and choosing the one or more that succeed?"
Cat:"Time to eat already! Meow!"

Me: "Is it better to use a global hash table or one for each scope?"
Cat:"Time to eat already! Meow!"

With my cat, the response is always "Why aren't you petting me? Meow!" I
think he's very intelligent, because he always has an answer for all of my
questions. I don't always understand his answers, but that's just a
communication issue. It still helps me (just as it helps Mike Wahler),
because I can have a phony conversation with my cat for a fair amount of
time before he becomes bored and walks away. :) I figure that some people
might think I was fit for a straightjacket if they saw me doing that. If
he's not around, I wind up talking to myself, which works almost as well,
but isn't much better when witnessed by others. :)
 
M

Mabden

FloWo3 said:
how do you create (design) algorithms.
I'm talking about thinking about it and come to an idea.

Examine the problem in small steps. Break down each little piece into
baby steps.

Contrary to other posts, I don't use paper and pen unless I'm trying to
visualize the actions of a loop of something like that.

I start in with an editor (not necessarily an IDE, Notepad works fine)
and start by just typing in comments of the steps I think I need, like
this:
---------------------------------------
// allocate variables

// open input file

// read data from file (into struct, line at a time, or whatever)
---------------------------------------

As I'm working I fill in things I find I need, like this:
---------------------------------------
// allocate variables
// loop counter, if necc.
// line buffer
// struct for file data, or alloc as needed

// open input file

// loop to read data from file into struct one line at a time
// read a line into line buffer
// parse line buffer into struct

// close file

// do something with data struct

// deallocate as necc.
---------------------------------------

The above is more C-like than C++, but you get the idea.

I try get the full problem scoped out before writing any real code, and
if some step is very complicated I just open another notepad for that
function or class. Eventually, I find things that I can fill in as real
code, but I try to resist that as long as possible.

Some will say that you have to use paper for this process, but editors
work for me. YMMV. On the plus side of this method you end up with fully
commented code at the end. And the comments are sometimes more correct,
since they change as the design is fleshed out - before the code is
written.
 

Ask a Question

Want to reply to this thread or ask your own question?

You'll need to choose a username for the site, which only take a couple of moments. After that, you can post your question and our members will help you out.

Ask a Question

Members online

Forum statistics

Threads
474,175
Messages
2,570,947
Members
47,498
Latest member
yelene6679

Latest Threads

Top