Binary Tree

Binary Tree is a #202112101956 where every node could have at most 2 children.

Analysis

  • The average depth of one binary tree is \(O(\sqrt[]{N})\)

Attention

  • Many of the rules apply to 202110191729 will apply to this data structure as well
  • Avoid sorted input

Implementation

typedef struct TreeNode *PtrToNode;
typedef strcut PtrToNode Tree;

struct TreeNode {
  ElementType Element;
  Tree        Left;
  Tree        Right;
};
Links to this page
  • Tree
  • K-way Merge

    Unlike 202203102127, it could use more than two, \(k\), drives or tapes as input or output. \(k\) parts will then be grouped into a run which will be stored into \(k\) drives or tapes. It is ill-advised to use comparison to obtain the smallest element among the parts since it could result in \(O(N^2)\) which is bad. We could take advantage of some #data-structure peculiarly 202202062259 or 202112102110. We will then obtain a sorted run by repeating the process recursively. The same steps will be performed for the next run.

  • Binary Search Tree

    Binary Search Tree is a #202112102110 that is dedicated for searching.

#data-structure #tree