Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
Original file line number Diff line number Diff line change
Expand Up @@ -4,6 +4,12 @@ sidebar_position: 2

# Binary Tree

:::tip[Status]

This note is complete, reviewed, and considered stable.

:::

A **Binary Tree** is a hierarchical data structure where each node has at most **two children**, referred to as the **left child** and **right child**.

## Key Properties
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -4,7 +4,11 @@ sidebar_position: 9

# Common Tree Algorithms

<!-- markdownlint-disable MD024 -->
:::tip[Status]

This note is complete, reviewed, and considered stable.

:::

## Generating Binary Tree from In-order and Post-order Traversals

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -4,7 +4,11 @@ sidebar_position: 6

# Full vs Complete Binary Tree

<!-- markdownlint-disable MD024 -->
:::tip[Status]

This note is complete, reviewed, and considered stable.

:::

## Full Binary Tree

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -4,6 +4,12 @@ sidebar_position: 1

# Introduction

:::tip[Status]

This note is complete, reviewed, and considered stable.

:::

A **tree** is a widely used abstract data structure that simulates a hierarchical tree structure, with a root value and subtrees of children, represented as a set of linked nodes. Trees are fundamental in computer science and are used in various applications such as databases, file systems, compilers, and more.

## Tree Terminology
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -4,6 +4,12 @@ sidebar_position: 4

# N-ary Tree

:::tip[Status]

This note is complete, reviewed, and considered stable.

:::

An **n-ary tree** is a rooted tree in which each node can have at most `n` children. This generalizes the binary tree concept to any number of children.

- If `n = 2`, it’s a binary tree.
Expand Down
Original file line number Diff line number Diff line change
@@ -0,0 +1,4 @@
{
"label": "Search Tree",
"position": 10
}
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
{
"label": "Binary Search Tree",
"position": 8
}
"position": 2
}
Original file line number Diff line number Diff line change
Expand Up @@ -4,6 +4,12 @@ sidebar_position: 1

# Introduction

:::tip[Status]

This note is complete, reviewed, and considered stable.

:::

A **Binary Search Tree (BST)** is a type of binary tree where each node satisfies the **BST property**:

- **Left Subtree**: All values in the left subtree are **less than** the node’s value.
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -4,6 +4,12 @@ sidebar_position: 2

# Common BST Algorithms

:::tip[Status]

This note is complete, reviewed, and considered stable.

:::

A **Binary Search Tree** supports a variety of operations to insert, find, delete, construct the tree from traversal data, validate properties, and perform traversals while maintaining the BST property.

## Search in BST
Expand Down
Original file line number Diff line number Diff line change
@@ -0,0 +1,41 @@
---
sidebar_position: 1
---

# Introduction

:::tip[Status]

This note is complete, reviewed, and considered stable.

:::

A search tree is a tree data structure that organizes data in a way that allows efficient searching, insertion, and deletion of elements.

Unlike a general tree, a search tree follows specific rules that determine where elements are stored. These rules enable algorithms to eliminate large portions of the tree during a search, making operations significantly faster than scanning every node.

For example, in a well-structured search tree, finding an element may require visiting only a small fraction of the nodes, resulting in a time complexity of **O(log n)** instead of **O(n)**.

Search trees are widely used in databases, file systems, compilers, search engines, caches, and many other software systems.

## Why Do We Need Search Trees?

Consider searching for a value in an unsorted collection of data:

```text
10, 50, 20, 70, 30, 40
```

In the worst case, every element must be examined.

```text
Search Complexity = O(n)
```

Search trees organize data according to defined rules, allowing searches to discard large portions of the structure at each step.

```text
Search Complexity = O(log n) (for balanced search trees)
```

As the amount of data grows, this difference becomes significant.
Original file line number Diff line number Diff line change
@@ -0,0 +1,4 @@
{
"label": "Prefix Search Tree",
"position": 4
}
Original file line number Diff line number Diff line change
@@ -0,0 +1,34 @@
---
sidebar_position: 1
---

# Introduction

:::tip[Status]

This note is complete, reviewed, and considered stable.

:::

A Prefix Search Tree is a tree data structure designed for storing and searching strings based on their prefixes.

Unlike Binary Search Trees, which organize data using value comparisons, Prefix Search Trees organize data character by character. This allows strings that share a common prefix to share the same path in the tree.

For example, the words:

```text
cat
car
can
```

share the prefix `"ca"` and therefore share part of the same path in the tree.

Prefix Search Trees are commonly used in:

- Autocomplete systems
- Spell checkers
- Dictionaries
- Prefix-based searches

The most common Prefix Search Tree is the **Trie**.
Loading
Loading