+
+ );
+};
+
+export default TreePropertiesVisualizer;
diff --git a/app/visualizer/trees/binaryTree/properties/code.js b/app/visualizer/trees/binaryTree/properties/code.js
new file mode 100755
index 0000000..83e8468
--- /dev/null
+++ b/app/visualizer/trees/binaryTree/properties/code.js
@@ -0,0 +1,168 @@
+const codeExamples = {
+ javascript: `// Binary Tree node
+class TreeNode {
+ constructor(value) {
+ this.value = value;
+ this.left = null;
+ this.right = null;
+ }
+}
+
+// Height: number of edges on the longest root-to-leaf path
+function height(node) {
+ if (node === null) return -1;
+ return 1 + Math.max(height(node.left), height(node.right));
+}
+
+// Total node count
+function countNodes(node) {
+ if (node === null) return 0;
+ return 1 + countNodes(node.left) + countNodes(node.right);
+}
+
+// Leaf node count
+function countLeaves(node) {
+ if (node === null) return 0;
+ if (node.left === null && node.right === null) return 1;
+ return countLeaves(node.left) + countLeaves(node.right);
+}
+
+// Usage example
+const root = new TreeNode('A');
+root.left = new TreeNode('B');
+root.right = new TreeNode('C');
+root.left.left = new TreeNode('D');
+
+console.log('Height:', height(root));
+console.log('Total nodes:', countNodes(root));
+console.log('Leaf nodes:', countLeaves(root));`,
+
+ python: `# Binary Tree node
+class TreeNode:
+ def __init__(self, value):
+ self.value = value
+ self.left = None
+ self.right = None
+
+# Height: number of edges on the longest root-to-leaf path
+def height(node):
+ if node is None:
+ return -1
+ return 1 + max(height(node.left), height(node.right))
+
+# Total node count
+def count_nodes(node):
+ if node is None:
+ return 0
+ return 1 + count_nodes(node.left) + count_nodes(node.right)
+
+# Leaf node count
+def count_leaves(node):
+ if node is None:
+ return 0
+ if node.left is None and node.right is None:
+ return 1
+ return count_leaves(node.left) + count_leaves(node.right)
+
+# Usage example
+root = TreeNode('A')
+root.left = TreeNode('B')
+root.right = TreeNode('C')
+root.left.left = TreeNode('D')
+
+print('Height:', height(root))
+print('Total nodes:', count_nodes(root))
+print('Leaf nodes:', count_leaves(root))`,
+
+ c: `#include
+#include
+
+typedef struct TreeNode {
+ char value;
+ struct TreeNode *left, *right;
+} TreeNode;
+
+TreeNode* newNode(char value) {
+ TreeNode* node = (TreeNode*)malloc(sizeof(TreeNode));
+ node->value = value;
+ node->left = node->right = NULL;
+ return node;
+}
+
+// Height: number of edges on the longest root-to-leaf path
+int height(TreeNode* node) {
+ if (node == NULL) return -1;
+ int leftHeight = height(node->left);
+ int rightHeight = height(node->right);
+ return 1 + (leftHeight > rightHeight ? leftHeight : rightHeight);
+}
+
+// Total node count
+int countNodes(TreeNode* node) {
+ if (node == NULL) return 0;
+ return 1 + countNodes(node->left) + countNodes(node->right);
+}
+
+// Leaf node count
+int countLeaves(TreeNode* node) {
+ if (node == NULL) return 0;
+ if (node->left == NULL && node->right == NULL) return 1;
+ return countLeaves(node->left) + countLeaves(node->right);
+}
+
+int main() {
+ TreeNode* root = newNode('A');
+ root->left = newNode('B');
+ root->right = newNode('C');
+ root->left->left = newNode('D');
+
+ printf("Height: %d\\n", height(root));
+ printf("Total nodes: %d\\n", countNodes(root));
+ printf("Leaf nodes: %d\\n", countLeaves(root));
+ return 0;
+}`,
+
+ java: `class TreeNode {
+ char value;
+ TreeNode left, right;
+
+ TreeNode(char value) {
+ this.value = value;
+ }
+}
+
+public class BinaryTreeProperties {
+
+ // Height: number of edges on the longest root-to-leaf path
+ static int height(TreeNode node) {
+ if (node == null) return -1;
+ return 1 + Math.max(height(node.left), height(node.right));
+ }
+
+ // Total node count
+ static int countNodes(TreeNode node) {
+ if (node == null) return 0;
+ return 1 + countNodes(node.left) + countNodes(node.right);
+ }
+
+ // Leaf node count
+ static int countLeaves(TreeNode node) {
+ if (node == null) return 0;
+ if (node.left == null && node.right == null) return 1;
+ return countLeaves(node.left) + countLeaves(node.right);
+ }
+
+ public static void main(String[] args) {
+ TreeNode root = new TreeNode('A');
+ root.left = new TreeNode('B');
+ root.right = new TreeNode('C');
+ root.left.left = new TreeNode('D');
+
+ System.out.println("Height: " + height(root));
+ System.out.println("Total nodes: " + countNodes(root));
+ System.out.println("Leaf nodes: " + countLeaves(root));
+ }
+}`,
+};
+
+export default codeExamples;
diff --git a/app/visualizer/trees/binaryTree/properties/content.jsx b/app/visualizer/trees/binaryTree/properties/content.jsx
new file mode 100755
index 0000000..5a9ebdc
--- /dev/null
+++ b/app/visualizer/trees/binaryTree/properties/content.jsx
@@ -0,0 +1,323 @@
+"use client";
+import ComplexityGraph from "@/app/components/ui/graph";
+import { useTheme } from "@/app/contexts/ThemeContext";
+import DailyDSAEmbed from "@/app/components/ui/DailyDSAEmbed";
+import NewsletterEmbed from "@/app/components/ui/NewsletterEmbed";
+import InContentAd from "@/app/components/ads/InContentAd";
+import { motion } from "framer-motion";
+
+const LabeledTreeDiagram = () => {
+ const nodes = [
+ { id: "A", x: 110, y: 30, depth: 0, leaf: false },
+ { id: "B", x: 80, y: 80, depth: 1, leaf: false },
+ { id: "C", x: 140, y: 80, depth: 1, leaf: false },
+ { id: "D", x: 65, y: 130, depth: 2, leaf: true },
+ { id: "E", x: 95, y: 130, depth: 2, leaf: true },
+ { id: "F", x: 125, y: 130, depth: 2, leaf: true },
+ { id: "G", x: 155, y: 130, depth: 2, leaf: true },
+ ];
+ const edges = [
+ ["A", "B"],
+ ["A", "C"],
+ ["B", "D"],
+ ["B", "E"],
+ ["C", "F"],
+ ["C", "G"],
+ ];
+ const byId = Object.fromEntries(nodes.map((n) => [n.id, n]));
+ const levelRows = [
+ { y: 30, label: "Depth 0" },
+ { y: 80, label: "Depth 1" },
+ { y: 130, label: "Depth 2" },
+ ];
+
+ return (
+
+ );
+};
+
+const Content = () => {
+ const { theme } = useTheme();
+
+ const paragraphs = [
+ `A Binary Tree is a hierarchical structure built from nodes, where every node has at most two children, conventionally called the left and right child. That two-child limit is what separates it from a general tree, and it's what makes every property below meaningful and calculable.`,
+ `Height and depth are the two measurements that come up constantly when reasoning about a tree's performance — most tree operations run in time proportional to the height, not the number of nodes, which is exactly why keeping a tree balanced matters so much.`,
+ `Space Complexity for storing a binary tree with n nodes is O(n), since each node needs a fixed amount of memory (its value plus two child pointers) regardless of the tree's shape.`,
+ `These structural properties aren't just theory — they're what a balancing algorithm (like in AVL or Red-Black trees) is actively trying to protect. A tree that's allowed to grow unchecked can degrade to the same O(n) worst case as a linked list.`,
+ ];
+
+ const terminology = [
+ { term: "Root", def: "The single node at the top of the tree with no parent." },
+ { term: "Parent / Child", def: "A node directly connected one level above/below another." },
+ { term: "Sibling", def: "Nodes that share the same parent." },
+ { term: "Leaf", def: "A node with no children (both left and right are null)." },
+ { term: "Internal Node", def: "Any node with at least one child (includes the root)." },
+ { term: "Edge", def: "The connection/link between a parent and its child." },
+ { term: "Depth of a node", def: "Number of edges from the root down to that node." },
+ { term: "Height of a node", def: "Number of edges on the longest path from that node down to a leaf." },
+ { term: "Height of the tree", def: "The height of the root node — the longest root-to-leaf path." },
+ ];
+
+ const nodeCountFormulas = [
+ { label: "Max nodes at depth d", formula: "2^d" },
+ { label: "Max total nodes for height h", formula: "2^(h+1) − 1" },
+ { label: "Min total nodes for height h", formula: "h + 1" },
+ { label: "Min possible height for n nodes", formula: "⌊log₂ n⌋" },
+ ];
+
+ const balanceComparison = [
+ { points: "Balanced tree, n = 7 nodes → height = 2 (as close to log₂ 7 as possible)" },
+ { points: "Skewed tree, n = 7 nodes → height = 6 (every node has exactly one child)" },
+ { points: "Same node count, wildly different performance — height is what actually matters" },
+ ];
+
+ return (
+
+
+
+
+
+
+ {/* What is a Binary Tree */}
+
+
+
+ What is a Binary Tree?
+
+
+
+ {paragraphs[0]}
+
+
+
+
+ {/* Terminology */}
+
+
+
+ Key Terminology
+
+
+ {terminology.map((item) => (
+
+
+ {item.term}:
+ {" "}
+
+ {item.def}
+
+
+ ))}
+
+
+
+ {/* Height, Depth & Level */}
+
+
+
+ Height, Depth & Level
+
+
+
+ {paragraphs[1]}
+
+
+
+
+
+
+
+
+ Internal node
+
+
+
+ Leaf node
+
+
+
+
+ In this tree, node A sits at depth 0 (the root), B and C sit at depth 1, and
+ D, E, F, G all sit at depth 2. Since the deepest node is at depth 2, the
+ tree's height is 2.
+
+
+
+ {/* Node Count Formulas */}
+
+
+
+ Node Count Formulas
+
+
+
+
+
+
+ Property
+
+
+ Formula
+
+
+
+
+ {nodeCountFormulas.map((row, index) => (
+
+
+ {row.label}
+
+
+ {row.formula}
+
+
+ ))}
+
+
+
+
+
+ {/* Balanced vs Skewed */}
+
+
+
+ Why Balance Matters
+
+
+
+ {balanceComparison.map((item, index) => (
+
+ {item.points}
+
+ ))}
+
+
+
+
+ {/* Complexity */}
+
+
+
+ Complexity Implications
+
+
+
+ Since most tree operations (search, insert, delete) walk from the root
+ down to a leaf, their time complexity is O(height) — O(log n) for a
+ balanced tree, degrading to O(n) for a skewed one.
+