Faisal
Faisal

Reputation: 45

How to return the key of the deepest node in a binary search tree ? (Recursive)

The key is an int value in a BST.

I've solved a question before that asked for the deepest node size; which wasn't too difficult. But I'm not sure how to return the depth to compare for the deepest node and at the same time retrieve the value of the key of that node. I mean how many return values do you have?

Upvotes: 0

Views: 154

Answers (2)

Andy with a S
Andy with a S

Reputation: 3

As Notrius posted, having a POJO should be simple enough to solve the problem. Just for your knowledge, some languages do support the concept of tuples, triplets etc. Java in itself doesn't support this, but there are some simpler libraries to supplement this. For example, Introduction to Javatuples

Upvotes: 0

dgkr
dgkr

Reputation: 345

According to this link, you need to declare an object that holds a key value and a depth value. Then, you need to return this object.

Upvotes: 0

Related Questions