CICS 210 Trees

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/62

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.

63 Terms

1
New cards

Tree definition

"A non-sequential data structure made up of nodes connected by arcs and organized hierarchically without cycles."

2
New cards

Root

"The single distinct node from which all other nodes descend."

3
New cards

Parent

"Any node that has one or more child nodes."

4
New cards

Child

"A node that descends directly from another node (its parent)."

5
New cards

Sister

"Two nodes that share the same parent."

6
New cards

Ancestor

"A node that appears on the path from the root to another node."

7
New cards

Grandchild

"A node that is the child of another node’s child."

8
New cards

Internal node

"A node with at least one child."

9
New cards

External node (Leaf)

"A node with no children."

10
New cards

Path

"A sequence of nodes connected by arcs."

11
New cards

Branch

"A path connecting the root to a leaf."

12
New cards

Importance of trees

"Trees are widely used in computer science for file systems

13
New cards

Binary tree definition

"A tree in which each node has at most two children (left and right)."

14
New cards

Formal definition of binary tree

"B = ∅ (empty tree) or B = <O

15
New cards

Left child

"The root of the left subtree."

16
New cards

Right child

"The root of the right subtree."

17
New cards

Left arc / Right arc

"An arc connecting a node to its left or right child."

18
New cards

Degree of binary tree

"The maximum number of children a node can have (2)."

19
New cards

Volume of binary tree

"The total number of nodes in the tree: Vol(EmptyTree)=0; Vol(<O

20
New cards

Height of node

"The number of arcs from the node to the root (root has height 0)."

21
New cards

Height of tree (H(B))

"The maximum height among all nodes."

22
New cards

Width of tree (W(B))

"The maximum number of nodes at any level."

23
New cards

Traversal distances

"LC(B) = total traversal distance; LCI(B) = internal traversal distance; LCE(B) = external traversal distance."

24
New cards

Linear binary tree

"A binary tree where each node has at most one child."

25
New cards

Complete binary tree

"A binary tree where all levels are fully filled with 2^k nodes at level k; total nodes = 2^(h+1)-1."

26
New cards

Perfect binary tree

"A binary tree where all levels are filled except possibly the last

27
New cards

Full binary tree

"A binary tree where each internal node has either two or no children; left and right subtree heights differ by at most 1."

28
New cards

Skewed binary tree

"A binary tree dominated entirely by either left or right children (left-skewed or right-skewed)."

29
New cards

Theorem 1 relation between height and nodes

"For any BT of volume n and height H: ⌊log₂ n⌋ ≤ H ≤ n − 1."

30
New cards

Corollary on leaves and height

"For a BT with f leaves: H ≥ ⌈log₂ f⌉."

31
New cards

Traversal distance theorem

"The traversal distance satisfies n·log₂ n ≤ LC(B) ≤ n²."

32
New cards

Mean height of leaves

"The average height of leaves ≤ log₂(f)."

33
New cards

Pointer representation of a binary tree

"Each node stores its value and two pointers (left and right subtrees)."

34
New cards

Table/array representation of a binary tree

"Each row stores: node value

35
New cards

Tree traversal purpose

"To visit all nodes of the tree in a specific order for processing."

36
New cards

General traversal rule

"Go deep and turn left whenever possible."

37
New cards

Preorder traversal

"Order: Node → Left → Right."

38
New cards

Inorder traversal

"Order: Left → Node → Right."

39
New cards

Postorder traversal

"Order: Left → Right → Node."

40
New cards

Generalized tree definition

"A tree where each node can have multiple children."

41
New cards

Representation using pointer tables

"Each node has a table of pointers to its children; maximum number = degree of the GT."

42
New cards

Representation using linked lists

"Each node has two pointers: first child and next sibling. Efficient and flexible structure."

43
New cards

Modified linked list representation

"Last child points to parent; includes a field to indicate whether pointer leads to sibling or parent."

44
New cards

Binary search tree definition

"A binary tree where for every node V: all elements in the left subtree ≤ V’s element

45
New cards

Inorder property of BST

"Traversing a BST in inorder gives the elements in ascending order."

46
New cards

Multiple BSTs

"Multiple BSTs can represent the same dataset depending on insertion order."

47
New cards

BST search process

"Compare target x with current node value s. If x = s

48
New cards

Search algorithm complexity

"Depends on height of the tree; tail-recursive and can be implemented iteratively."

49
New cards

Insertion at leaves

"The new element is added as a leaf after searching for the correct position."

50
New cards

Insertion at root

"The tree is split into L (≤ x) and R (> x)

51
New cards

Split algorithm

"Recursively divides the BST into two subtrees L and R based on whether node values are ≤ or > x."

52
New cards

Add_root algorithm

"Creates a new node as root

53
New cards

Deletion case 1

"Node is a leaf → delete directly."

54
New cards

Deletion case 2

"Node has one child → replace node with its child."

55
New cards

Deletion case 3

"Node has two children → replace node with its predecessor (max in left subtree)."

56
New cards

Delete_max procedure

"Finds and deletes the largest node in a BST and returns its value."

57
New cards

Delete_node procedure

"Recursively searches for the node to delete and reorganizes the BST using delete_max if needed."

58
New cards

BST search complexity

"If element found at node v: ≈ 2·H(v) comparisons; if not found: ≈ 2·(H(v)+1) comparisons."

59
New cards

BST insertion complexity

"Same as search; proportional to tree height."

60
New cards

BST deletion complexity

"Also proportional to height."

61
New cards

BST time complexities

"Best case (balanced tree): O(log n); worst case (skewed tree): O(n)."

62
New cards

Applications of trees

"Trees are used in databases

63
New cards

Importance of tree structures

"Provide efficient hierarchical data organization and enable fast searching