Skip to content

300.Longest Increasing Subsequence#5

Open
haniwachann wants to merge 1 commit intomasterfrom
08_Dynamic-Programming
Open

300.Longest Increasing Subsequence#5
haniwachann wants to merge 1 commit intomasterfrom
08_Dynamic-Programming

Conversation

@haniwachann
Copy link
Copy Markdown
Owner

読みやすいことを意識する。
他の解法も考えみる。

計算量:O(N)
Copy link
Copy Markdown

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

これは自乗でしょうか。

```


- 0(NlogN)の計算量のアルゴリズム(2分探索)もあるよう。step4で追加したい。
Copy link
Copy Markdown

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

https://discord.com/channels/1084280443945353267/1200089668901937312/1209534429593210932
このあたりから参照です。

このあたりの解法、お互いに移り変われるところがあり、解法を考えるときに局所的な変形などをしています。
https://discord.com/channels/1084280443945353267/1206101582861697046/1209027377397506109
https://discord.com/channels/1084280443945353267/1210494002277908491/1215698534855090207

```

【考えたこと】
- 計算量:O(N^2) 空間:O(N)
Copy link
Copy Markdown

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

C++ で時間計算量が O(N^2) のプログラムで N=2500 の入力データを入力して実行するとき、おおよそどれくらいの時間がかかるか推定できますか?

Copy link
Copy Markdown
Owner Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

C++の1秒間の実行ステップ数を1.010^8とすると、
計算にかかる時間=2500
2500/10^8〜0.0625(s)
と考えております。
以下を参考にしました。
hroc135/leetcode#9 (comment)

ちなみになのですが、C++の1秒間の実行ステップ数を、
ネットで調べてもなかなか見つけられないのは、調べる力の問題なのでしょうか。
それらしき値を見つけても、ブログだったり、知恵袋でしか、
見つけられず本当に合っているのか不安になることが多いです...

Copy link
Copy Markdown

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

正しいと思います。

ちなみになのですが、C++の1秒間の実行ステップ数を、
ネットで調べてもなかなか見つけられないのは、調べる力の問題なのでしょうか。

自分の場合は大学の先輩から教えてもらったように思います。書籍やネット上の確度の高い情報で見た記憶はありません。

Copy link
Copy Markdown

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

実際のところ、いろいろな事情があるので桁くらいしか合わないものです。
CPU のインストラクションごとにクロック数が異なり、最近はマイクロコードになって並列して実行できたりできなかったりするので精度良く見積もることは困難です。
https://discord.com/channels/1084280443945353267/1218823752243089408/1244470338562293882
https://discord.com/channels/1084280443945353267/1253694251271852095/1273238168170266686
https://discord.com/channels/1084280443945353267/1200089668901937312/1235490680592273410

@TORUS0818
Copy link
Copy Markdown

拝見しました。
良いと思います!

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

4 participants