4.2.5.1 Trees Flashcards

1
Q

What is a tree?

A

A connected undirected graph with no cycles. Connected means that every node is connected to at least one other node. Undirected means there is no direction associated with an edge, i.e. lines are used, not arrows.

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

What is a rooted tree?

A

A tree in which one vertex has been designed as the root and every edge is directed away from the root.The edges are instead called branches and the nodes without any subnodes are called leaf nodes. Internal nodes are the ones in between

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

What is a binary tree?

A

Each node is the parent node of at maximum two other nodes. They can be split into left and right subtrees. They can represent the order that mathematical expressions are evaluated.

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

What is a rooted tree used for?

A

Representing hierarchical data
Storing data in a way that makes it efficiently searchable (see binary search tree and tree traversal)
Representing sorted lists of data

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

How does a binary search tree work?

A

can sort an unordered list of items into an order. A node is picked the nodes become it’s child nodes.The smaller number goes into the left subtree, the larger goes into the right. The tree can then be searched by starting at the root and if the number to search is larger it will be in the right subtree, like the binary search

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

Describe one example of the use of a Binary Search Tree.

A

List of elements inserted into tree;
To allow rapid/fast searching of the data;
To output sorted/ordered data;

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