Advertisement
Guest User

Untitled

a guest
Nov 19th, 2017
75
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
text 0.84 KB | None | 0 0
  1. Programming Challenge Description:
  2. 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:
  3. 30
  4. |
  5. --+--
  6. | |
  7. 8 52
  8. |
  9. --+--
  10. | |
  11. 3 20
  12. |
  13. --+--
  14. | |
  15. 10 29
  16.  
  17. Input:
  18. 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.
  19.  
  20. Output:
  21. Print to standard output the least common ancestor of the two nodes.
  22.  
  23. Test 1
  24. Test Input Download Test Input8 52
  25. Expected Output Download Test Output30
  26. Test 2
  27. Test Input Download Test Input3 29
  28. Expected Output Download Test Output8
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement