LoginSignup
6
6

More than 5 years have passed since last update.

メモ化再帰と探索をPythonとGoで実装

Posted at

メモ化再帰と探索を組み合わせて実行時間を早くできる、という記事※を拝見したので、
サンプルコードをPythonとGoで実装し直してみる。

https://github.com/kazuhirokomoda/algorithm-and-data-structure/blob/master/DP_recursive.py
https://github.com/kazuhirokomoda/algorithm-and-data-structure/blob/master/DP_recursive.go

※ こちらの記事
http://www.itmedia.co.jp/enterprise/articles/1003/06/news002_5.html

Goは今回初めて触ったけど、今回の内容だったら特に問題なく馴染めた感じ。

実行時間もついでに測ってみたけど、全く同じアルゴリズムで
average execution time (10 times)
python: 23.14 [s]
go: 7.398 [s]
という感じでした。
ささっとアルゴリズムを書く時に、goも使えるようになるといいのかも。

6
6
2

Register as a new user and use Qiita more conveniently

  1. You get articles that match your needs
  2. You can efficiently read back useful information
  3. You can use dark theme
What you can do with signing up
6
6