Status message

Maintenant, vous regardez: Using memoization for performance

Using memoization for performance

When doing heavy computations one thing that can be done for increasing performance is not
to repeat any calculation that has already been done and that must be reused. Instead cache the
calculated value in memory, which is called memoization. A great example of this is the Fibonacci
program:

  1. package main
  2. import (
  3. “fmt”
  4. time
  5. )
  6. const LIM = 41
  7. var fibs [LIM]uint64
  8. func main() {
  9. var result uint64 = 0
  10. start := time.Now()
  11. for i:=0; i < LIM; i++ {
  12. result = fibonacci(i)
  13. fmt.Printf(“fibonacci(%d) is: %d\n”, i, result)
  14. }
  15. end := time.Now()
  16. delta := end.Sub(start)
  17. fmt.Printf(“longCalculation took this amount of time: %s\n”, delta)
  18. }
  19.  
  20. func fibonacci(n int) (res uint64) {
  21. // memoization: check if fibonacci(n) is already known in array:
  22. if fibs[n] != 0 {
  23. res = fibs[n]
  24. return
  25. }
  26. if n <= 1 {
  27. res = 1
  28. } else {
  29. res = fibonacci(n-1) + fibonacci(n-2)
  30. }
  31. fibs[n] = res
  32. return
  33. }

Tags:

Comments

Fantastic website you have here but I was curious about if you knew of

any user discussion forums that cover the same topics

discussed in this article? I'd really love to be a part of community where

I can get suggestions from other experienced people that share the same interest.

If you have any suggestions, please let me know.

Thanks a lot!

Here is my webpage; fortnite free vbucks

When some one searches for his essential thing, thus he/she needs to be available that

in detail, so that thing is maintained over here.

Here is my webpage: hack star trek command

What's Taking place i am new to this, I stumbled

upon this I've found It positively useful and it has helped me out loads.

I hope to give a contribution & assist other customers like its aided me.

Great job.

Feel free to visit my blog post; summoners war hack

I've been browsing online more than three hours today,

yet I never found any interesting article like yours.

It's pretty worth enough for me. In my opinion, if all webmasters and bloggers made good content as you did, the net will

be much more useful than ever before.

Visit my page hack marvel strike

I would like to thank you for the efforts you have put in writing this

site. I'm hoping to view the same high-grade content by you in the future as

well. In fact, your creative writing abilities has encouraged

me to get my own website now ;)

Check out my webpage: last shelter survival hack

Very shortly this site will be famous amid all blog visitors, due to

it's fastidious content

my blog - v bucks free generator

Hola! I've been reading your weblog for some time

now and finally got the bravery to go ahead and give you a shout out from Kingwood Tx!

Just wanted to say keep up the great work!

my webpage - free vbucks

Good answers in return of this question with genuine

arguments and explaining everything regarding that.

Have a look at my web-site :: vbucks free

The integral walk of the fearless is vindicatory too granitic to not , that is why GTA 5 money shaft is

the best chicane for GTA 5 players around the earth.

My web site; wings io

I know this website offers quality based posts and extra stuff, is there any other

site which presents these things in quality?

Also visit my homepage; check out more

Hey there! Someone in my Facebook group shared this site with us so I came to give it a

look. I'm definitely loving the information. I'm bookmarking and will be tweeting

this to my followers! Exceptional blog and great style and design.

Also visit my web blog ... free psn codes

First of all I would like to say fantastic blog!

I had a quick question which I'd like to ask if you do not mind.

I was interested to know how you center yourself and clear your thoughts before writing.

I've had difficulty clearing my thoughts in getting my ideas out.

I do enjoy writing however it just seems like the first 10 to 15 minutes tend to be wasted

simply just trying to figure out how to begin. Any suggestions or

hints? Thanks!

my blog post ... free the vbucks

Great work! This is the type of information that are meant

to be shared around the net. Disgrace on Google for now not positioning this submit

higher! Come on over and seek advice from my web site .

Thanks =)

Also visit my website; v bucks free

I absolutely love your blog and find many of your post's to be exactly what

I'm looking for. Does one offer guest writers to write content available for you?

I wouldn't mind composing a post or elaborating on most of the subjects you write in relation to here.

Again, awesome weblog!

my web site v bucks free generator

I needed to thank you for this good read!!

I definitely loved every little bit of it.

I have you bookmarked to look at new things you post…

my web blog; last shelter survival hack

I don't even know the way I ended up right here, but

I believed this post was once great. I don't know

who you are but certainly you are going to a well-known blogger in case you aren't already.

Cheers!

Feel free to surf to my web site king of avalon cheats

Hello, Neat post. There is a problem along with your site in internet explorer,

may test this? IE nonetheless is the marketplace leader and a big component of other folks will pass

over your fantastic writing because of this problem.

Check out my page - free psn codes gift cards

What's Taking place i am new to this, I stumbled upon this I've discovered It absolutely helpful and it has aided me out loads.

I'm hoping to give a contribution & help different customers like its

helped me. Great job.

Here is my web site - free the vbucks

Sweet blog! I found it while searching on Yahoo News. Do you have any tips on how

to get listed in Yahoo News? I've been trying for a while but I never seem to get there!

Many thanks

Feel free to surf to my page; free psn codes generator

Thanks for any other wonderful article. The place else may just anybody get that type of information in such

an ideal way of writing? I've a presentation subsequent week, and I am

at the search for such info.

My web page: articole pescuit

We are a group of volunteers and opening a new scheme

in our community. Your web site offered us with valuable info to work on. You have done a formidable job and our

entire community will be thankful to you.

Here is my web blog: magazin pescuit

Typically, a thing that could be hosted inside office or

any public venue which is not too far from the office. One of the

regulars hit a nine dart finish against him, talk about playing the board.

Nobody wants a bad reputation; it makes it harder to discover partners for other events, and makes people uneasy

when caught you.

Also visit my homepage dartboard measurements

My developer is trying to convince me to move to .net from PHP.

I have always disliked the idea because of the costs.

But he's tryiong none the less. I've been using Movable-type on a number of

websites for about a year and am nervous about switching to

another platform. I have heard great things about blogengine.net.

Is there a way I can transfer all my wordpress posts into it?

Any help would be greatly appreciated!

my page: free v bucks

You are so awesome! I do not suppose I've read something like this before.

So nice to discover someone with original thoughts on this subject.

Really.. thanks for starting this up. This site is one thing that's needed on the

internet, someone with a little originality!

My web page; free vbucks generator

Hi! This is my first comment here so I just wanted to give a quick shout out

and say I truly enjoy reading your articles. Can you suggest any other

blogs/websites/forums that go over the same subjects? Thanks a ton!

my web site; v bucks free generator

Great site you have got here.. It's difficult to find quality writing like yours

nowadays. I truly appreciate individuals like you!

Take care!!

my homepage ... free the vbucks

I think this is among the most vital info for me. And i'm

glad reading your article. But wanna remark on some general things, The

website style is ideal, the articles is really great : D.

Good job, cheers

Here is my homepage ... free vbucks generator

Attractive part of content. I simply stumbled upon your weblog and in accession capital

to claim that I get in fact loved account your blog posts. Anyway I'll be subscribing in your augment and even I fulfillment you get admission to persistently fast.

My web blog: free vbucks generator

Hey there! This post could not be written any better!

Reading through this post reminds me of my old room mate!

He always kept chatting about this. I will forward

this write-up to him. Pretty sure he will have a good read.

Thanks for sharing!

Take a look at my page: v bucks free

I do trust all of the ideas you have presented for your post.

They are really convincing and can certainly work. Nonetheless, the posts are too brief for novices.

May you please extend them a little from subsequent time?

Thanks for the post.

Also visit my blog post rolriss high powered waterproof night vision binoculars

What's up Dear, are you really visiting this web site on a regular basis, if

so then you will definitely get good knowledge.

Check out my web site; lords mobile hack

You can definitely see your enthusiasm in the work you

write. The sector hopes for more passionate writers such as you who aren't afraid to

say how they believe. At all times follow your heart.

Also visit my web site ... free psn codes generator

Very soon this site will be famous among all blogging

visitors, due to it's nice articles

my webpage :: free steam wallet codes generator

You're so interesting! I don't believe I've read

something like this before. So wonderful to find somebody with

unique thoughts on this issue. Seriously.. many thanks for starting this up.

This site is one thing that's needed on the web, someone

with a bit of originality!

Here is my site - xbox live codes generator

What a data of un-ambiguity and preserveness

of precious know-how on the topic of unpredicted feelings.

Also visit my web blog; free vbucks

I don't even know how I ended up here, but I thought this post was good.

I don't know who you are but definitely you're going to a

famous blogger if you are not already ;) Cheers!

Here is my site - v bucks free generator

magnificent submit, very informative. I wonder why the other

specialists of this sector don't notice this. You must continue your writing.

I'm sure, you have a great readers' base already!

my web site v bucks free

Hey! I just wanted to ask if you ever have any problems with hackers?

My last blog (wordpress) was hacked and I ended up losing several weeks of hard work due to

no data backup. Do you have any methods to stop hackers?

Feel free to visit my web-site - free v bucks

Hi, I do think this is a great blog. I stumbledupon it ;)

I may revisit yet again since i have book marked it.

Money and freedom is the best way to change, may you be rich and continue to guide others.

Here is my web blog ... free v bucks

What's up to every , for the reason that I am actually keen of reading this web site's post to be updated regularly.

It consists of nice material.

Also visit my web site free vbucks

Hi there! This is my first comment here so I

just wanted to give a quick shout out and say I truly enjoy reading your blog posts.

Can you recommend any other blogs/websites/forums that go over the same subjects?

Thanks!

My blog post; hack marvel strike

Hey there! I've been following your blog for a while now and finally got the courage to go ahead and give you a shout out from

Dallas Tx! Just wanted to say keep up the great

job!

My page - hack marvel strike

Great article. I am dealing with some of these issues as well..

Feel free to visit my webpage; hack summoners war

I just like the valuable information you supply on your articles.

I'll bookmark your blog and check once more right here regularly.

I am quite certain I'll learn many new stuff right here!

Best of luck for the next!

Also visit my blog post :: free v bucks

Hi, I think your site could be having browser compatibility

problems. Whenever I take a look at your website in Safari,

it looks fine however when opening in Internet Explorer, it has some overlapping issues.

I simply wanted to provide you with a quick

heads up! Aside from that, fantastic website!

my web-site :: hack lords mobile

When some one searches for his essential thing, so he/she wishes to be available that in detail,

therefore that thing is maintained over here.

my site ... free xbox gift card codes

Thanks for finally talking about > Add new comment | Moi Verhole < Loved it!

my site; free psn codes

generator

I used to be able to find good info from your content.

Feel free to surf to my web-site; free steam gift card codes

Howdy! I know this is kinda off topic nevertheless I'd figured I'd ask.

Would you be interested in exchanging links or maybe guest authoring a blog article or vice-versa?

My blog discusses a lot of the same subjects as yours

and I think we could greatly benefit from each other. If you

happen to be interested feel free to send me an e-mail.

I look forward to hearing from you! Great blog by the way!

Feel free to surf to my blog post :: free the vbucks

Pages

Add new comment

Filtered HTML

  • Web page addresses and e-mail addresses turn into links automatically.
  • Allowed HTML tags: <a> <em> <strong> <cite> <blockquote> <code> <ul> <ol> <li> <dl> <dt> <dd>
  • Lines and paragraphs break automatically.

Plain text

  • No HTML tags allowed.
  • Web page addresses and e-mail addresses turn into links automatically.
  • Lines and paragraphs break automatically.
CAPTCHA
This question is for testing whether or not you are a human visitor and to prevent automated spam submissions.
16 + 4 =
Solve this simple math problem and enter the result. E.g. for 1+3, enter 4.