Yahoo India Web Search

Search results

  1. Given a Binary Search Tree. Your task is to complete the function which will return the Kth largest element without doing any modification in Binary Search Tree. Example 1: Input:   4   / \\ 2 9 k = 2 Output: 4 Example 2: In

  2. Mar 26, 2024 · We will create a function to perform an in-order traversal of a BST, storing elements in ascending order. Then, another function, kthLargestAndSmallest, will use this traversal to find the kth smallest and largest elements in the tree.

  3. Jun 18, 2021 · Given a BST, the task is to find the sum of all elements greater than and equal to kth largest element.

  4. Jul 20, 2020 · klargest(root.left,k,count); return -1; But the issue is that when count = k, the code does not return the answer to the caller function but instead to a sub-call. Due to this, the answer is lost. In other words, the recursion does not stop there and it keeps on going until all the nodes are visited. In the end, I get the answer -1.

  5. Dec 11, 2019 · Problem Description : Given a Binary Search Tree, find the Kth Largest element in the given tree. Input : We are given 27 as root of this binary search tree and 2 as a value of K. Output and Explanation: In this case, the output should be 30 as it is the second largest element in the given BST. Similarly, if the value of K is 3, the output ...

  6. Sep 29, 2020 · Find kth smallest and kth largest element in bst (binary search tree) without using any extra and with in-order traversal.

  7. K-th largest Number BST. You are given a binary search tree of integers with 'N' nodes. Your task is to return the K-th largest element of this BST. ...

  1. People also search for