Question
A recursive function calculate_height(node) is designed
to find the height of a binary tree (where a single node has height 0). The function is implemented as: def calculate_height(node):   if node is None:     return -1 # Base case   left_height = calculate_height(node.left)   right_height = calculate_height(node.right)   return 1 + max(left_height, right_height) When tested with a single-node tree (e.g., Node(10)), it returns 0. However, when tested with an empty tree (None), it returns -1. If the desired output for an empty tree is also -1 and for a single node tree is 0, the current implementation is correct. But if the definition of height for a single node tree is 1, what change would be needed in the base case?Solution
(If a single node has height 1, then an empty tree should be 0, and 1 + max(0,0) would give 1 for a single node.)
Which of the following Indian Accounting Standard (Ind AS), deals with the reporting and disclosure of contingent liabilities and contingent assets? �...
Annual Return is to be filed by every company within ________ days of its Annual general meeting.
In an IT environment, auditing differs from manual auditing because:Â
Under the EPF Act, 1952, which Section empowers the Central Government to frame the Employees’ Provident Fund Scheme?
According to section 63 of Companies Act 2013, which of the following cannot be used for issue of bonus shares?
Which of the following is true?
Revenue should be recognized at the point of sale. Which principle is applied here?Â
A software company enters into a ₹10 lakh contract including installation and training. Installation is ₹8 lakh and training ₹2 lakh. Installation...
The GST on used car sales is ____ as per the 55th GST council meeting decisions taken in December 2024.
As per RBI norms on agricultural advances, a loan granted for long duration crops will be classified as a Non-Performing Asset (NPA) if the instalment o...