Big O 記法の練習
この演習では、Big O 記法の理解をさらに深めましょう。
最初のステップでは、次のリストのすべての要素を表示するアルゴリズムを作成します。
colors = ['green', 'yellow', 'blue', 'pink']
このアルゴリズムの計算量は \(O(n)\) になります。
2番目と3番目のステップでは、2つのアルゴリズムの計算量を求めていきます。
この演習はコースの一部です
Pythonで学ぶデータ構造とアルゴリズム
実践的なインタラクティブ演習
このサンプルコードを完成させて、この演習に挑戦してみましょう。
colors = ['green', 'yellow', 'blue', 'pink']
def linear(colors):
# Iterate the elements of the list
____:
# Print the current element of the list
print(____)
linear(colors)