Part 7 Flashcards

1
Q

when is a binary tree balanced?

A

If for every non-leaf node the number of nodes in its left child and right child differ by no more than 1

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

What is the average and worst case time complexities for binary search tree operations?

A

Average O(logn)

Worst O(n)

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

The depth of a balanced binary tree containing n nodes is exactly

A

floor(log2n) + 1

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

When would it make sense to ensure a binary tree stays balanced?

A

If it will be searched frequently but not inserted or removed frequently

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

Rebalancing a tree takes at least ___________ time in the worst case

A

O(n)

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

What is another term for dept-balanced?

A

AVL-Balanced

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

What does depth balanced mean?

A

for every non-leaf node the depth of its left child and the depth of its right child differ by no more than one

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

The depth of any AVL-Balanced tree containing n nodes is no more than

_________

as long as n > 1

A

2log2n

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

What is an AVL tree?

A

A depth balanced binary search tree

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

The rebalancing of an AVL tree can be performed in __________ time

A

constant

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

The time taken to deduce whether an AVL tree needs rebalancing is proportional to

A

its depth

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

Searching, insertion and deletion for AVL trees can be performed in _________ time

A

O(logn)

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

What is the most efficient way of storing information in AVL tree nodes?

A

Simply store details of which child is deeper

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

Functions that are computable using the Church-Turing definitions can be implemented in which programming language?

A

Any

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

What is the halting problem?

A

The question of whether a program will terminate when run with specific data, specifically:

can we write a program taking source code and input as strings that will determine whether the program in the source will terminate with the data

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

Write the source code to prove the halting problem is non computable:

A

public static void main(String args[]) {

String s; // read input into s

try {

if (halts(s, s)) { while(true) {} }

catch (Exception e) {}

}