We use cookies to ensure you have the best browsing experience on our website. Please read our cookie policy for more information about how we use cookies.
Title: Why is my top view function returning incorrect results for a binary search tree?
Hi everyone,
I’m trying to implement the top view of a binary search tree in Java, but my output isn’t matching my expectations. After debugging my code, I suspect I may not fully understand the concept of the top view, and I’m getting an incorrect result.
Problem:
I’ve inserted nodes into a binary search tree in the following order:
Tree : Top View
You are viewing a single comment's thread. Return to all comments →
Title: Why is my top view function returning incorrect results for a binary search tree?
Hi everyone,
I’m trying to implement the top view of a binary search tree in Java, but my output isn’t matching my expectations. After debugging my code, I suspect I may not fully understand the concept of the top view, and I’m getting an incorrect result.
Problem:
I’ve inserted nodes into a binary search tree in the following order:
My Approach:
I’m using the following code to calculate the top view:
Issue:
When I run the program with the above input, I get the following output:
However, the expected output should be:
Thank you in advance for your help!
This version should make your issue and expectations clear to others, inviting them to help you debug the code further.