CSC 230 (4) - Binary Search Trees (BST)

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

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.

24 Terms

1
New cards

What is a Binary Search Tree (BST)?

A tree in which each node has at most two children, the left child and the right child.

2
New cards

What are the main parts of a BST?

Root, leaves, and internal nodes.

3
New cards

What properties of a BST should be understood?

Tree height, tree diameter, node level, node parent, node children, perfect tree, full tree, complete tree.

4
New cards

What is a perfect tree?

A tree where all internal nodes have two children and all leaves are at the same level

5
New cards

What is a full tree?

A tree where every node has either 0 or 2 children.

6
New cards

What is a complete tree?

A tree that is completely filled on all levels except possibly the last, which is filled from left to right.

7
New cards

How do you determine if a tree is a valid BST?

For any node, all left children are ordered to the left of the parent, and all right children are ordered to the right of the parent.

8
New cards

What is Level-order Traversal?

Traversing nodes level by level, from top to bottom; iterative version uses two queues

9
New cards

What is In-order Traversal?

Traverse left subtree, visit node, traverse right subtree; recursive version recurses left, visits node, recurses right; iterative version uses a stack.

10
New cards

What is Pre-order Traversal?

Visit node, traverse left subtree, traverse right subtree; usually recursive.

11
New cards

What is Post-order Traversal?

Traverse left subtree, traverse right subtree, visit node; usually recursive.

12
New cards

What algorithms are important for BSTs?

BST Search, BST Insert, BST Remove (Delete).

13
New cards

How do you perform insertion in a BST?

Compare the value to the current node; go left if smaller, right if larger; insert at the appropriate null child position.

14
New cards

How do you perform deletion from a BST?

There are three cases:

  • Node is a leaf → delete directly

  • Node has one child → delete node and move child up

  • Node has two children → replace node with in-order successor (or predecessor) and recursively remove successor (or predecessor)

15
New cards

What is an in-order successor in a BST?

The smallest node in the right subtree of the node being deleted.

16
New cards

What is an in-order predecessor in a BST?

The largest node in the left subtree of the node being deleted.

17
New cards

When deleting a node with two children, why do we use the in-order successor or predecessor?

To maintain the BST property that all left children are smaller and all right children are larger.

18
New cards

What data structures are used in iterative BST traversals?

Stack for in-order traversal; queues for level-order traversal.

19
New cards

Summary: recursive orders of traversal

  • In-order → left, node, right

  • Pre-order → node, left, right

  • Post-order → left, right, node

20
New cards

Next, do problem set 08 and then do quiz 09

21
New cards

22
New cards
23
New cards
24
New cards