Skip to content

【Arai60】26問目 102. Binary Tree Level Order Traversal#26

Merged
shining-ai merged 6 commits intomainfrom
review26
Jun 30, 2024
Merged

【Arai60】26問目 102. Binary Tree Level Order Traversal#26
shining-ai merged 6 commits intomainfrom
review26

Conversation

@shining-ai
Copy link
Copy Markdown
Owner

Copy link
Copy Markdown

@hayashi-ay hayashi-ay left a comment

Choose a reason for hiding this comment

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

良いと思います。個人的にはrootはlevel 1な気がしますが0でも良いかなと思います。

@shining-ai
Copy link
Copy Markdown
Owner Author

木構造のレベル(深さ)は0始まりなので、それに合わせました。
感覚的な部分は自分だけだとずれてしまいがちなので、コメント助かります。

@hayashi-ay
Copy link
Copy Markdown

木構造のレベル(深さ)は0始まりなので、それに合わせました。

これってどういうことですか?自分の方が違うかも??

https://www.baeldung.com/cs/tree-depth-height-difference

For each node in a tree, we can define two features: height and depth. A node’s height is the number of edges to its most distant leaf node. On the other hand, a node’s depth is the number of edges back up to the root. So, the root always has a depth of 0 while leaf nodes always have a height of 0. And if we look at the tree as a whole, its depth and height are both the root height.

@shining-ai
Copy link
Copy Markdown
Owner Author

ルートノードのdepthは0なので、純粋にそれをlevelに当てはめていました。
いただいたURLでもAのdepthは0なので。
levelとdepthは別物だったら変なこと言っちゃってるかもしれないです。

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.

2 participants