Trees & Hierarchical Structures

0.0(0)
studied byStudied by 0 people
0.0(0)
full-widthCall Kai
learnLearn
examPractice Test
spaced repetitionSpaced Repetition
heart puzzleMatch
flashcardsFlashcards
GameKnowt Play
Card Sorting

1/32

encourage image

There's no tags or description

Looks like no tags are added yet.

Study Analytics
Name
Mastery
Learn
Test
Matching
Spaced

No study sessions yet.

33 Terms

1
New cards

What is a Binary Tree?

A tree structure where each parent can have at most two children, allowing hierarchical organization of data.

2
New cards

What are the roles of nodes in a Binary Tree?

Nodes can be parent or child; the root is the topmost node; parents can have left and right children.

3
New cards

What are the three fields of a Binary Tree node?

Data element, pointer to left child, pointer to right child.

4
New cards

What are leaf nodes?

Nodes with no children; both child pointers are NULL.

5
New cards

Give an application of Binary Trees.

Used in databases to organize files into folders for easy searching.

6
New cards

What is Tree Traversal?

Visiting every node once in a specific order to access or process data.

7
New cards

How does tree traversal differ from linear structures?

Linear structures read data one way; trees can be traversed in multiple ways.

8
New cards

What are the two primary categories of tree traversal?

Breadth-First Traversal (BFT) and Depth-First Traversal (DFT).

9
New cards

What is Breadth-First Traversal?

Visits nodes level by level using a queue; useful in scheduling and shortest paths.

10
New cards

What is Depth-First Traversal?

Explores a branch as deeply as possible before backtracking.

11
New cards

What is Inorder Traversal?

Left → Root → Right; retrieves values in sorted order in BSTs.

12
New cards

What is Preorder Traversal?

Root → Left → Right; useful for copying trees or prefix expressions.

13
New cards

What is Postorder Traversal?

Left → Right → Root; useful for deleting trees or postfix expressions.

14
New cards

What is a Binary Search Tree (BST)?

An ordered binary tree where left < root < right, no duplicates, all keys unique.

15
New cards

What is the BST property of the right subtree?

All nodes in the right subtree must be greater than the parent.

16
New cards

What is the BST property of the left subtree?

All nodes in the left subtree must be less than the parent.

17
New cards

Does a BST allow duplicate nodes?

No, every key must be unique.

18
New cards

Why must every BST node have a unique key?

To keep search, insert, and delete operations efficient (O(log n)).

19
New cards

What is an AVL Tree?

A self-balancing BST where each node has a balance factor of -1, 0, or +1.

20
New cards

What is the balance factor in AVL Trees?

Difference in height between left and right subtrees.

21
New cards

What does a balance factor of +1, 0, -1 mean?

+1 = left taller, 0 = equal height, -1 = right taller.

22
New cards

What happens if AVL balance factor goes beyond -1 or +1?

The tree rebalances itself using rotations.

23
New cards

What is an LL Rotation?

Right rotation when insertion makes the left subtree of the left child too heavy.

24
New cards

What is an RR Rotation?

Left rotation when insertion makes the right subtree of the right child too heavy.

25
New cards

What is an LR Rotation?

Double rotation: Left rotate child, then Right rotate parent (zig-zag imbalance).

26
New cards

What is an RL Rotation?

Double rotation: Right rotate child, then Left rotate parent (zig-zag imbalance).

27
New cards

What is the application of trees in Hierarchical Data Representation?

Used in file systems, organizational charts, and DOM structures.

28
New cards

What is the application of trees in Searching and Sorting?

BSTs, AVL, and Red-Black Trees allow fast searching, inserting, and deleting.

29
New cards

What is the application of trees in Databases?

B-Trees/B+ Trees for indexing; Tries for autocomplete, dictionary, and IP routing.

30
New cards

What is the application of trees in Artificial Intelligence?

Decision Trees for ML, Minimax Trees for games, Behavior Trees for NPCs.

31
New cards

What is the application of trees in Compiler Design?

ASTs represent program structure; Parse Trees show grammatical structure.

32
New cards

What is the application of trees in Cryptography and Security?

Merkle Trees for blockchain verification; trees also for credential checks.

33
New cards

What is the application of trees in Networking?

Tries for fast IP lookups; MSTs optimize network designs by minimizing costs.

Explore top flashcards