IMC Trading Interview Question: Given a binary tree, a node i... | Glassdoor

Interview Question

Java Software Developer Interview

Given a binary tree, a node is visible if the value it

  holds is no greater than all the values along the path from the root. Write pseudo-code for an efficient algorithm to find the number of visible nodes in this tree.
Answer

Interview Answer

1 Answer

1

A simple recursive algorithm can be used. For the recursion, pass in the current max value along the path, and the subtree.

Interview Candidate on Apr 18, 2015

Add Answers or Comments

To comment on this, Sign In or Sign Up.