GithubHelp home page GithubHelp logo

algorithm_sandbox's People

Contributors

kenzo-tanaka avatar

algorithm_sandbox's Issues

分割統治法

a = gets.to_i
b = gets.to_i
c = gets.to_i
@x = gets.to_i

@payment_pattern = 0

def one_type_coin_payment(coin_type, coin)
  # ここで再帰的な処理が必要そう
  if @x % coin_type == 0 && (@x/coin_type) <= coin
    @payment_pattern += 1
  end
end

one_type_coin_payment(500, a)
one_type_coin_payment(100, b)
one_type_coin_payment(50, c)


print @payment_pattern

ビッグオー記法

そのアルゴリズムが処理を終了させるまでにどれくらい時間がかかるかを測定する指標。
例えば単純探索のような、要素を一つずつ調べていくようなアルゴリズムに関してはO(n) と表記。

ビッグオーは最悪の場合の計算時間を意味する。

コールスタック

複数関数の変数を保存するためのスタックをコールスタックという。

ある関数から他の関数を呼び出している時、呼び出し元の関数は部分的に終了している状態である。
なので、他の関数を呼び出す前に代入した変数はスタックに残った状態になっている。

再帰的な計算や処理をするときもコールスタックが使われる。

再帰的な処理のようなスタックを使う場面では、メモリをより多く使用する必要があるので、パフォーマンスが落ちる可能性がある。

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    🖖 Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. 📊📈🎉

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google ❤️ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.