BST का न्यूनतम node खोजना
इस अभ्यास में, आप एक BST पर अभ्यास करेंगे ताकि न्यूनतम node ढूँढ सकें.
अपने कोड को टेस्ट करने के लिए, आप निम्न tree का उपयोग कर सकते हैं:

इसे bst वैरिएबल (लाइन 14) में preload किया गया है:
bst = CreateTree()
आप find_min() मेथड जो परिणाम लौटाता है, उसे इस कोड (लाइन 15) से प्रिंट कर सकते हैं:
print(bst.find_min())
यह अभ्यास पाठ्यक्रम का हिस्सा है
Python में Data Structures और Algorithms
अभ्यास निर्देश
current_nodeको root के रूप में सेट करें.- उपयुक्त subtree के nodes पर iterate करें.
current_nodeके मान को अपडेट करें.
इंटरैक्टिव व्यावहारिक अभ्यास
इस अभ्यास को इस नमूना कोड को पूरा करके आज़माएँ।
class BinarySearchTree:
def __init__(self):
self.root = None
def find_min(self):
# Set current_node as the root
current_node = ____
# Iterate over the nodes of the appropriate subtree
while current_node.____:
# Update current_node
current_node = current_node.____
return current_node.data
bst = CreateTree()
print(bst.find_min())