02Chapter 2: Binary trees and their special formsThis chapter assumes you know basic recursion, object references, Big-O notation, and the vocabulary from the previous chapter: root, parent, child, leaf, depth, height, level, and degree. Here we restrict to binary trees and name the shapes that GATE questions rely on.5 min read
03Chapter 3: Node, leaf, and height formulasThis chapter assumes you know the vocabulary from the first two chapters (root, leaf, depth, height, level, and the full, complete, perfect, and skewed forms) and can do basic exponent and logarithm arithmetic. The formulas here let you answer many GATE questions with a few lines of algebra. They in7 min read
04Chapter 4: Linked and array representationsThis chapter assumes you know the tree vocabulary (root, parent, child, leaf, height) and the difference between full, complete, perfect, and skewed binary trees. It also assumes you can read basic Python and follow recursion. Here we look at how a binary tree is stored in memory, which index and po6 min read
05Chapter 5: Preorder, inorder, postorder, and level orderThis chapter assumes you can read recursive Python, know what a queue and a stack are, and have the tree vocabulary from the earlier chapters (root, child, leaf, height). A traversal is a rule for visiting every node of a tree exactly once, in a fixed order. Traversals are the base for reconstructio6 min read
06Chapter 6: Rebuilding a tree from two traversalsThis chapter assumes you can write the four traversals (preorder, inorder, postorder, level order) and read a recursive function. It uses the Node class and the traversal functions from the previous chapter. Every key in the examples is distinct, and the chapter points out where that matters.8 min read
07Chapter 7: Expression trees and their traversalsThis chapter assumes you know the four standard traversals (preorder, inorder, postorder, level order), recursion, and the idea of a stack. An expression tree is a binary tree that stores an arithmetic expression. Preorder, inorder and postorder traversals of it give the prefix, infix and postfix fo6 min read
08Chapter 8: The binary search tree propertyThis chapter assumes you know basic tree vocabulary (root, child, leaf, height), how a binary tree is stored as linked nodes, and the three depth-first traversals. It also assumes you can read recursive Python and use Big-O notation. Search, insertion, and deletion come in later chapters. Here we pi6 min read
09Chapter 9: Searching a BSTThis chapter covers how to search a binary search tree (BST) for a key, and how to find its minimum, maximum, successor, and predecessor. It assumes you know recursion, object references, Big-O notation, and the BST property: for every node, all keys in the left subtree are smaller and all keys in t7 min read
10Chapter 10: Inserting into a BSTThis chapter assumes you know recursion, object references, and Big-O notation. It also assumes you have met the binary search tree (BST) property and BST search from the previous chapters. Insertion builds directly on search. It follows the same path and then attaches a new node where the search wo7 min read
11Chapter 11: Inorder traversal yields sorted keysThis chapter assumes you can read recursive Python and know the binary search tree (BST) property: every key in a node's left subtree is smaller than the node's key, and every key in its right subtree is larger. You should also know the three depth-first traversals from the traversals chapter. Here 6 min read
12Chapter 12: Deleting from a BSTThis chapter assumes you know the binary search tree (BST) property, how search and insertion work, and how to read recursive Python. Deletion is the hardest of the three basic BST operations because removing a node must leave the ordering property intact. The method depends on how many children the5 min read
13Chapter 13: Cost of BST operations and the role of heightThis chapter assumes you can read the BST search, insert and delete code from the previous chapters. It also assumes you know Big-O notation and the standard tree vocabulary. Height is measured in edges, so a single node has height 0 and an empty tree has height -1.6 min read
14Chapter 14: Counting BSTs with Catalan numbersThis chapter assumes you know the binary search tree (BST) property, how insertion works, and what a tree's shape is. It also assumes you can read a simple recurrence and use binomial coefficients. The goal is to answer "how many distinct BSTs exist on n keys?" and its common variants, which GATE te6 min read
15Chapter 15: Keeping a BST balanced: AVL treesThis chapter assumes you know the BST property, search, insertion, and deletion. It also assumes you can reason about tree height and read recursive Python. The previous chapter showed that every BST operation costs O(h), where h is the height. A BST built from sorted input has height n − 1 and degr6 min read