Trees Flashcards

You may prefer our related Brainscape-certified flashcards:
1
Q

Define a tree

A

A connected undirected graph with no cycles

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

Define a cycle

A

A path which starts and ends at the same node

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

Define connected in the frame of trees

A

There’s a path from any node to another node and there’s no node disconnected from others

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

Define undirected in the frame of trees

A

There is no direction associated with an edge

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

What’s the root of a tree?

A

The start node for traversals

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

What is a tree called if it has a root?

A

A rooted tree

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

What is a branch?

A

A path from the root to an end point

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

What is the end point of a branch called?

A

A leaf

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

What does the height of a tree describe?

A

The number of edges that connect the root node to the leaf node that is furthest away

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

What is the E, N equation?

A

E (number of edges) = N (number of nodes) -1

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

How are nodes connected in a rooted tree?

A

By parent-child relationships

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

What is a binary tree?

A

A rooted tree where every node has at most 2 child nodes

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

Why is a binary search tree different from a rooted tree?

A

It’s ordered to optimise searching

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

Describe a binary search tree

A

A rooted tree where the nodes of a tree are ordered

If the orders ascending the left nodes have values lower than the root and the right higher

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

How does an expression tree work?

A

Leaf nodes contain operands and other nodes contain operators

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

What are binary trees used for?

A

Used in compilers to build syntax trees
Used in routers to store routing tables
Speed up searching

17
Q

What are expression trees used for?

A

Representing algebraic and Boolean expressions

18
Q

What 2 ways can all trees be implemented?

A

As an adjacency matrix or adjacency list

19
Q

What other way can a binary tree be implemented?

A

An array of records

20
Q

Define the term Pre-order in traversals

A

Specifies the point in the traversal at which the node content is processed

21
Q

How does a pre-order traversal work?

A

Each node is visited before the algorithm traverses either of the nodes subtrees

22
Q

What is the simplified recursive algorithm for left-right pre-order traversal?

A

Visit the node
Do a pre-order traversal of the nodes left subtree
Do a pre-order traversal of the node’s right subtree