Question
Which of the following techniques is most efficient for
finding the kth smallest element in a Binary Search Tree (BST)?Solution
In a Binary Search Tree (BST), an Inorder Traversal retrieves elements in sorted order. To find the kth smallest element, an efficient approach is to perform an Inorder Traversal and stop after visiting the kth element. This method is efficient because it directly leverages the BST's inherent properties without extra data structures. Steps:
- Perform a recursive Inorder Traversal.
- Maintain a counter to track the number of visited nodes.
- When the counter equals k , return the current node's value.
- An item is listed at 50% above its cost price and sold at 10% discount. What is the seller’s profit percentage?
A person bought an article and sold it at a loss of 15%. If he had bought it for 20% less and sold it for Rs114 more he would have had profit of 30%. F...
By selling a Mobile for Rs. 3720 a shopkeeper gains 24%. If the profit reduced to 14%, then the selling price will be
A person buys 5 tables and 9 chairs for Rs15,400. He sells the tables at 10% profit and chairs at 20% profit. If his total profit on selling all the tab...
A shopkeeper marks the price of an article 25% higher than its cost price. The marked price is Rs. 12,000. He offers two successive discounts of 10% and...
A trader bought an article for Rs. 2000 and marked it 25% above of its cost price. If he sold it after giving a discount of Rs. 160 then find the profit...
A Shopkeeper gives 2 articles free on the purchase of every 10 articles. He also allows a discount of 20% to customer and still earn 25% profit. Find th...
The ratio of cost price to the marked price of an article is 5:8. The article had been marked above its cost price by Rs. 240. If the article was sold a...
A tradesman gives a 4% discount on the marked price and gives an article free for buying every 15 articles and thus gains 35%. Find out by what percenta...
A seller marked the price of an item at Rs. 2,800. The seller gave successive discounts of (a + 3)% and (a - 3)% to a customer. If the customer paid Rs....