Trees and Transversals Flashcards

1
Q

What is in order transversal

A

Left → Root → Right

How well did you know this?
1
Not at all
2
3
4
5
Perfectly
2
Q

What is Preorder transversal

A

Root → Left → Right

How well did you know this?
1
Not at all
2
3
4
5
Perfectly
3
Q

What is Postorder transversal

A

Left → Right → Root

How well did you know this?
1
Not at all
2
3
4
5
Perfectly
4
Q

Why are AVL trees used

A

They are self-balancing BSTs, maintaining O(log n) operations

How well did you know this?
1
Not at all
2
3
4
5
Perfectly
5
Q

What’s the height of a complete binary tree with 15 nodes?

A

3 (0-based), since 15 = 2⁴ - 1

How well did you know this?
1
Not at all
2
3
4
5
Perfectly
6
Q

What property defines a min-heap?

A

Every parent is less than or equal to its children.

How well did you know this?
1
Not at all
2
3
4
5
Perfectly
7
Q

What’s the minimum number of nodes in an AVL tree of height h

A

F(h+2) − 1, where F is the Fibonacci sequence

How well did you know this?
1
Not at all
2
3
4
5
Perfectly
8
Q

In an AVL tree, what balance factor range is valid

A

Must be -1, 0, or +1

How well did you know this?
1
Not at all
2
3
4
5
Perfectly
9
Q

What is the balance factor of a leaf node in an AVL tree

A

0 — both left and right heights are -1

How well did you know this?
1
Not at all
2
3
4
5
Perfectly
10
Q

What’s the result of deleting the root in a BST and replacing it with a value from the right subtree?

A

The smallest value from the right subtree replaces the root

How well did you know this?
1
Not at all
2
3
4
5
Perfectly
11
Q

Can a min-heap also be a binary search tree?

A

No — BSTs must satisfy in-order value rules, heaps only structural.

How well did you know this?
1
Not at all
2
3
4
5
Perfectly
12
Q

What is Dikstra’s algorihtm

A

an aglroithm used to find a shorted parth from a source vertex to all other vertex

How well did you know this?
1
Not at all
2
3
4
5
Perfectly
13
Q

What condition would dikstra’s algorithm not work

A

when the graph contains negative weight edges

How well did you know this?
1
Not at all
2
3
4
5
Perfectly
14
Q

how are binary search trees organised

A

all elements in the left subtree of a node are less than the node. While all subtrees right of the node are greater than the node.

How well did you know this?
1
Not at all
2
3
4
5
Perfectly
15
Q

what are the benefits of BST

A
  • printing out values in BST in sorted order
  • optimising search operations is the reason we have BSTs
How well did you know this?
1
Not at all
2
3
4
5
Perfectly
16
Q

when inserting a value into a BST what value should we compare against to decide whether to place left or right

A

the parent node ie. the middle one

17
Q

Why can’t you always just delete nodes in BST, and what should u dop instead

A

could disconnect tree which you can’t do. Thus you should re organise with on of the bottom nodes

18
Q

if a tree is balanced what time complexity can most operations be performed at

19
Q

How do you know if a binary search tree is unbalanced

A

A binary tree is considered height-balanced if the absolute difference in heights of the left and right subtrees is at most 1 for every node in the tree.

20
Q

what is one of the most important factors about an AVL tree

A

rebalancing can be achieved