trees Flashcards

1
Q

what do trees show

A

hiearachy

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

Linear data structure

A

Array, list, stack queues
Elements are structured in one linear order

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

Non linear(hierarchal) data structure

A

No natural order for elements
Tree and graph

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

how many edges in tree

A

Tree has N nodes and N-1 edges because edge connects to its parent

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

External node(leaf)

A

No children

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

Internal node

A

At least one child

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

path

A

sequence of nodes such that n1 is parent of n1+1 and so on

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

path length

A

number of edges on path

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

what does each node have

A

has a data element, parent node pointer and pointers to children nodes

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

BST operations

A

Initize new tree
Bool is empty
search(private)- return pointer to node in which key is found, other wise return null ptr
search(public)-return true is key is found
Find min
Find maz
Insert - done at leaf
Remove
display

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

BST array implemantation pro and con

A

Pro - easy implementation and fast access
Con - mostly suitable for complete trees

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

tree preorder traversal

A

node is visited before its descendants
List the node the first time its passed

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

what pass does tree in preorder listing list a node

A

second pass

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

what pass does tree in postorder listing list a node

A

last pass

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

five possible situations for BST deletiong

A

-ittem not found
-removing leaf
-removing node with one chilg - left
-removing node with one child - right
-

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

removing node with one child

A

nodes parent next is nodes child
if root, root = nodes child

17
Q

removing node with two chidren

A

Successor- replace node information with smallest value larger than value to remove
Predecessor - replace node information with largest value smaller than value to remove