Update 2024-03-27: Greatly expanded the "Samples" page and renamed it to "Glossary".
Update 2024-04-04: Added 5 million mid-2011 posts from the k47 post dump. Browse (mostly) them here.
Update 2024-04-07: Added ~400 October 2003 posts from 4chan.net. Browse them here.

Welcome to Oldfriend Archive, the official 4chan archive of the NSA. Hosting ~170M text-only 2003-2014 4chan posts (mostly 2006-2008).
[7 / 1 / ?]

BST Depth

No.2984074 View ViewReplyOriginalReport
Hi /sci/,

I want to give an algorithm wich gives me the depth of a node in a BinarySearch Tree (depth of the node is the number of edges on the path from the root to the node)

So first of all the root has a depth 0. So here is my question, Should I just each time go, from the root till the node, return the depth, check if it has a left child, return the depth, check the right child, return the depth and so one.
And will this be in O(n) running time?

Thanks in advance!