john smith
john smith

Reputation: 1

Binary Search Trees queries

I have these couple of questions:

  1. Given a BST of floats, find the highest number just below a given float value
  2. Implement a binary search tree for floating-point values

My ideas: I thought a greedy on the given location would give us the right answer for 1) and 2) would be by basically just considering subtrees of depth = precision of the value. This would give us a standard BST but with subtrees to access floating point data points.

Let me know if these are correct.

Upvotes: 0

Views: 456

Answers (1)

Hardy Feng
Hardy Feng

Reputation: 479

I don't think there is significant difference between BST for integer node and floating point node, and answer for 1) and 2) are straightforward. By BST in-order traversal, find the highest number below given float value until encounter a value that is greater than give value or traversal done.

Upvotes: 2

Related Questions