. But could not find a proper solution. Thank you. This has cleared some concepts on BST.
This is not uncommon with recursion, especially with unbalanced trees of significant depth.
Mary Rani wrote:I have written a program [ Inputs: Number of pages in the book, Page number to be searched ] to store book pages [ starting from page number '1' on the right side ] in a binary tree having the following structure:
The program computes the number of pages [ nodes ] to be turned, to get the suggested page number, from front[top-bottom] and back[bottom-top]. Return the minimum number of pages to be turned over, to reach the suggested page number. this works fine for small values. However it is throwing StackOverFlow Error while entering large values like NumberOfPages: 37455, PageNumberToBeFound: 29835.
What code changes can I make to avoid this error? I understand the above tree is not a balanced tree but the insertion/page order also should remain intact. Please suggest accordingly.