Find Node in Binary Tree

Описание к видео Find Node in Binary Tree

In this video, we will see how to find the node with a given key in a binary tree, using a recursive solution. The idea is to start at the root of the binary tree, and check if the key of root is equal to the key we're looking for. If that's the case, root is the node we're looking for, so we return it. Else we try to find the key in the left subtree. If we don't find it, we then try to find the key in the right subtree. If we again fail to find it, this means that there is no node with the key we're searching in our binary tree, so we return null.

Video timeline:
00:26 - Description of the algorithm
02:40 - Writing code (c++)
04:35 - Stepping through the code
10:16 - Analyzing the time complexity
11:28 - Analyzing the space complexity

C++ code for find Node function: cs.phyley.com/binary-tree/find-node

Комментарии

Информация по комментариям в разработке