(b) Binary Search Tree

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

1/15

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.

16 Terms

1
New cards

What is a graph?

an a data structure/tree made up of nodes connected via edges/arc representing RS between diff nodes

2
New cards

What is a tree?

a dynamic data structure - a graph with no cycles

3
New cards

What are the three types of trees?

  • binary tree

  • binary search tree

  • rooted tree

4
New cards

What is the difference between a binary tree and binary search tree?

  • binary tree = rooted tree where each node can have max. 2 child nodes

  • binary search tree = binary tree where if child node is less than root node, it is put to the left, if child node is more than root node, it is put to the right

5
New cards

What do we call nodes at the bottom of the tree?

leaf nodes

6
New cards

What are the uses of rooted trees?

  • storing + managing file & folder structures

  • implementations of A* pathfinding algorithm

  • storing + manipulating hierarchical data

7
New cards

What are the maximum amount of child nodes a binary tree can have?

2

8
New cards

What are the two ways a binary tree can be implemented?

  • using a dictionary

  • using an array

9
New cards
<p>How would these tree by implemented using a dictionary?</p>

How would these tree by implemented using a dictionary?

knowt flashcard image
10
New cards
<p>How would these tree by implemented using an array?</p>

How would these tree by implemented using an array?

knowt flashcard image
11
New cards

What are the uses of a binary tree?

  • database applications (efficient searching + sorting)

  • wireless networking & router tables

  • OS scheduling processes

12
New cards

How do you add an item to a binary tree?

13
New cards

How do you delete an item from a binary tree?

14
New cards

How do you search a binary tree for an item?

  • check if root node is equal to search value - if so return found

  • if value is less than root node take left subtree

  • if value is greater than root node take right subtree

  • repeat process w/ subtree

  • until search value is found

  • until no more branches can be travelled

15
New cards

How do you perform a depth-first (post-order) travels on a binary search tree?

  • start at the root node - go all the way down the branch to the leaf node

  • pushes visited nodes onto stack

  • continues to backtrack until node is reach w/ univisited children - checks down that branch (backtracks to previous node & explore all those branches)

16
New cards

How do you perform a breadth-first (pre-order) travels on a binary search tree?