CPSC 223 Midterm 2 Study Guide: TDD and BSTs

0.0(0)
studied byStudied by 0 people
learnLearn
examPractice Test
spaced repetitionSpaced Repetition
heart puzzleMatch
flashcardsFlashcards
Card Sorting

1/28

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.

29 Terms

1
New cards

six components of a specification in TDD

Purpose, Assumptions, Inputs, Outputs, State Changes, Cases and Expected Behavior

2
New cards

four phases of a test in TDD

Write test, run test (fail), write code, run test (pass)

3
New cards

five steps to the TDD cycle

1. Write test to spec, 2. Run and fail, 3. Write code, 4. Run and pass, 5. Refactor

4
New cards

definition of a tree

A connected undirected graph with exactly one path between any two vertices

5
New cards

definition of a forest

An undirected graph where between any two vertices there is at most one path

6
New cards

polytree

A connected directed graph with exactly one undirected path between any two vertices

7
New cards

polyforest

A directed graph where between any two vertices there is at most one undirected path

8
New cards

set-based notation for a graph

G = (V, E), where V is vertices and E is edges

9
New cards

degree of a node

The number of edges connected to it

10
New cards

parent and a child in a BST

A parent is a node with children; a child is a node linked below another

11
New cards

organizing structure of a BST

Left child < parent < right child

12
New cards

nodes with no children

Leaf nodes

13
New cards

node at the top of a tree

Root

14
New cards

nodes with children

Internal nodes

15
New cards

subtree

A tree structure rooted at a child of another node

16
New cards

path in a tree

A sequence from the root to a leaf

17
New cards

advantage of having two children

Better balance and faster searching (tree is more compact)

18
New cards

best-case BST vs. worst-case BST

Best-case: balanced; Worst-case: linear like a linked list

19
New cards

case tree results from inserting in order

Worst-case (linked list shape)

20
New cards

insertion order for the most efficient BST

In an order that balances the tree (e.g. median first)

21
New cards

cases for BST deletion

Node has no children, one child, or two children (use in-order successor)

22
New cards

three traversal methods of a BST

In-order, Pre-order, Post-order

23
New cards

perfect BST

All levels are completely filled

<p>All levels are completely filled</p>
24
New cards

complete BST

All levels are filled except possibly the last, which is filled left to right

<p>All levels are filled except possibly the last, which is filled left to right</p>
25
New cards

insertion order for a perfect BST with 7 nodes

4, 2, 1, 3, 6, 5, 7

26
New cards

in-order successor

The next node in in-order traversal (smallest in right subtree); used in deletion

27
New cards

balance factor in an AVL tree

Height(left subtree) - Height(right subtree)

28
New cards

four AVL rotation types

Left-Left, Right-Right, Left-Right, Right-Left

29
New cards

time complexity of rebalancing a tree via reinsertion

O(n) - because all nodes are visited and reinserted