Thursday, June 1, 2017

Leetcode 230: Kth Smallest Element in a BST

June 1, 2017

Plan to work on the problem called "Kth Smallest Element in a BST". The problem statement link is here.

Plan to study the algorithm "Second largest element in BST". The link is here.

Introduction


One of most common algorithms is to find the largest value in a set. To solve the problem, Julia has to learn to step back, to find a value in the set first, and then compare to existing largest value when a new value is found.

Julia learned the lesson through the mock experience. The algorithm is to find largest smaller value than the given value in Binary Search Tree (BST). In other words, any number in the BST less than the given value can be added to the set, and the task is to find the maximum value.

The lesson learned is to find a smaller value first, and then save it as maximum value; continue to search and continue to compare with existing max value.

Algorithm study 



No comments:

Post a Comment