Trees Flashcards

(20 cards)

1
Q

What is a tree data structure?

A

A specialised form of undirected graph with exactly one path between two nodes used to model hierarchical relationships.

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

What are the features of a tree?

A
  • Undirected
  • Unweighted
  • Fully connected
  • Acyclical
How well did you know this?
1
Not at all
2
3
4
5
Perfectly
3
Q

What is a binary tree?

A

A type of rooted tree where each node can have at most two children.

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

What are the uses of trees?

A
  • Building efficient searching and sorting algorithms
  • Storing data that has a hierarchical structure
  • Processing syntax in natural and programming languages
  • Implementing probability and decision trees
How well did you know this?
1
Not at all
2
3
4
5
Perfectly
5
Q

Why are trees well suited for recursion?

A

They are a recursive data type such that each child node can be the root of a separate tree.

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

What is a rooted tree?

A

Tree where
- One node is designated as the root which has no parents
- All nodes can be described as a parent or child node
- Direction of hierarchy often shown by arrows

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

What are the features on a rooted tree?

A
  • Root node: has no parent
  • Child and Parent nodes
  • Edges/Branches
  • Leaf node: has no children
How well did you know this?
1
Not at all
2
3
4
5
Perfectly
8
Q

What is a binary search tree?

A

A type of binary tree where a particular method is used to insert new node in an optimal location for later search/retreival

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

What are Binary Search Trees used for?

A

Provide an efficient way of searching for items as well as providing an effective way of returning all items in the correct order.

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

What are the key operations of a tree?

A
  • Add nodes
  • Get child nodes
  • Getting a subtree
  • Searching for a node
  • Determining the height of the tree
How well did you know this?
1
Not at all
2
3
4
5
Perfectly
11
Q

What is the height of a tree?

A

The number of edges along the longest path from the root to the furthest leaf node.

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

What are the uses of a pre-order traversal?

A
  • Copying a tree
  • Evaluating mathematical expressions using prefix notation
How well did you know this?
1
Not at all
2
3
4
5
Perfectly
13
Q

What are the uses of an in-order traversal?

A
  • Outputting the contents of a binary tree in ascending order
How well did you know this?
1
Not at all
2
3
4
5
Perfectly
14
Q

What are the uses of a post-order traversal?

A
  • Converting mathematical expressions from infix to postfix notation (Reverse Polish)
  • Producing a postfix expression from an expression tree
  • Deleting a tree
  • Completing dependant processes in order
How well did you know this?
1
Not at all
2
3
4
5
Perfectly
15
Q

What is an expression tree?

A

A tree that represents a mathematical expressions evaluated using post-order traversals.

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

What it Reverse Polish Notation?

A

An alternate means of writing mathematical expressions using postfix notation

17
Q

What is infix notation?

A

The operator sits between the operands

18
Q

What is postfix notation?

A

Operator comes after operands

19
Q

What are the benefits of Reverse Polish Notation?

A
  • Simplifies mathematical expressions by eliminating the need for brackets as order is implied by notation
  • More easily evaluated by stack-based interpreters
20
Q

What are some properties of stack-based interpreters?

A
  • Translate and execute program code line-by-line
  • Invoke pre-complied subroutines to perform the line being translated