Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- Programming Challenge Description:
- Write a program to determine the lowest common ancestor of two nodes in the following binary search tree, which you may hard code in your program:
- 30
- |
- --+--
- | |
- 8 52
- |
- --+--
- | |
- 3 20
- |
- --+--
- | |
- 10 29
- Input:
- Your program should read one line of text from standard input. The line will contain two integers, separated by a space, which represent two nodes within the pictured binary search tree.
- Output:
- Print to standard output the least common ancestor of the two nodes.
- Test 1
- Test Input Download Test Input8 52
- Expected Output Download Test Output30
- Test 2
- Test Input Download Test Input3 29
- Expected Output Download Test Output8
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement