Algorithms Flashcards

1
Q

In which data structure a Traversal usually happen?

A

A tree

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

What’s a node in the Tree data structure?

A

A node is a structure which may contain a value or condition, or represent a separate data structure.

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

What’s a Root in the Tree data structure?

A

The top node in a tree, the prime ancestor.

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

What’s a child in the Tree data structure?

A

A node directly connected to another node moving away from the root, an immediate descendant.

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

What’s a parent in the Tree data structure?

A

The inverse of a child, an immediate ancestor.

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

What is a leaf in the Tree data structure?

A

A node with no children

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

What is an Internal node in the Tree data structure?

A

A node with at least one child.

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

What is an edge in the Tree data structure?

A

The connection between one node and another

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

What is depth in the Tree data structure?

A

The distance between a node and the root

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

What is a level in the Tree data structure?

A

The number of edges between a node and the root + 1

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

What is the height of the Tree data structure?

A

The number of edges on the longest path between a node and a descendant leaf.

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

What is a breadth in the Tree data structure?

A

Is the number of leaves.

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

What is a subtree in the Tree data structure?

A

A tree T is a tree consisting of a node in T and all of its descendants in T.

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

What is a binary tree?

A

Is a tree data structure in which each node has at most two children, which are referred to as the left and right child.

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

What is a binary search tree? List 3 main properties of a binary search;

A

is a special type of binary tree which has the following properties.

The left subtree of a node contains only nodes with keys lesser than the node’s key.
The right subtree of a node contains only nodes with keys greater than the node’s key.
The left and right subtree each must also be a binary search tree.
How well did you know this?
1
Not at all
2
3
4
5
Perfectly
16
Q

What is a tree traversal?

A

In computer science, tree traversal (also known as tree search) is a form of graph traversal and refers to the process of visiting (checking and/or updating) each node in a tree data structure, exactly once. Such traversals are classified by the order in which the nodes are visited.

17
Q

What are the two main Tree Traversal algorithms?

A

Depth-First Search(DFS) and Breadth-First Search(BFS)

17
Q

What are the two main Tree Traversal algorithms?

A

Depth-First Search(DFS) and Breadth-First Search(BFS)

18
Q

How does the Depth-First Search(DFS) algorithm work?

A

t starts with the root node and first visits all nodes of one branch as deep as possible of the chosen Node and before backtracking, it visits all other branches in a similar fashion.

19
Q

How does the Breadth-First search (BFS) algorithm work?

A

It also starts from the root node and visits all nodes of current depth before moving to the next depth in the tree.

20
Q

What are the three main Depth-First Search(DFS) algorithms variants?

A
Preorder Traversal (current-left-right)— Visit the current node before visiting any nodes inside left or right subtrees.
    Inorder Traversal (left-current-right)— Visit the current node after visiting all nodes inside left subtree but before visiting any node within the right subtree.
    Postorder Traversal (left-right-current) — Visit the current node after visiting all the nodes of left and right subtrees.