Computer >> บทช่วยสอนคอมพิวเตอร์ >  >> การเขียนโปรแกรม >> JavaScript

Binary Search Tree ใน JavaScript


Binary Search Tree มีพฤติกรรมพิเศษ: left child ของ node ต้องมีค่าน้อยกว่า parent และ right child ต้องมีค่ามากกว่า parent

Binary Search Tree ใน JavaScript

เราจะเน้นที่ต้นไม้แบบนี้ใน section นี้

Operations on Binary Search Trees

เราจะกำหนด operations ต่อไปนี้บน BST:

  • Inserting a key into a tree
  • In-order traversal in a tree
  • Pre-order traversal in a tree
  • Post-order traversal in a tree
  • Searching for values in a tree
  • Searching for minimum value in a tree
  • Searching for maximum value in a tree
  • Removing a leaf node in a tree