# How to find Second largest element in BST ?

## How to find Second largest element in BST ?

- In an N-ary tree, the second largest value in the given tree to find and return the node. Return NULL if no node with required value is present.

- For example, in the given tree

Second largest element in a BST

Second largest node is 20.

- A simple solution is to traverse the array twice. In the first traversal the maximum value node to be find.
- In the second traversal find the greatest element node less than the element obtained in first traversal.
- This solution O(n) is the time complexity.
- To find the second largest element in a single traversal to be efficient solution.

## Algorithm

## Sample Code in Java

## Output

## Time Complexity

- Time Complexity: The above solution is O(h) where h is height of BST.