Lesson 6: Trees Flashcards

1
Q

Tree is a __________ data structure. (choices: linear, non-linear)

A

non-linear

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

Tree imposes a __________ structure, on a collection of items

A

Hierarchial

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

collection of nodes

A

Tree

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

If not empty, a tree consists of: (clue: RSE)

A

node R (the ROOT)
zero or more non-empty SUBTREES
each subtree is connected by a directed EDGE from R

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

[Tree Terminologies]
—mother node of a tree structure
—does not have parent
—first node in hierarchical arrangement

A

Root

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

[Tree Terminologies]
—stores the data and its role is the same as in the linked list
—connected by the means of links with other nodes

A

Node

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

[Tree Terminologies] immediate predecessor of a node

A

Parent

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

[Tree Terminologies] When a predecessor of a node is parent then all successor nodes are called __________ nodes.

A

Child

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

[Tree Terminologies]
—connects the two nodes
—pointer to node in a tree structure

A

Link/Edge

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

[Tree Terminologies]
—locates at the end of the tree
—does not have any child

A

Leaf

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

[Tree Terminologies] The highest number of nodes that is possible in a way starting from the first node (ROOT) to a leaf node

A

Height

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

[Tree Terminologies] rank of tree hierarchy

A

Level

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

[Tree Terminologies] the level of the root node

A

Level 0

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

[Tree Terminologies] The child node of same parent

A

Sibling

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

[Tree Terminologies] Another term for sibling nodes

A

Brother nodes

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

[Tree Terminologies] The maximum number of children that exists for a node

A

Degree of a Node

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

[Tree Terminologies] The node with degree zero

A

Terminal node

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

[Tree Terminologies] number of successive edges from source node to destination node

A

Path length

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

[Tree Terminologies] maximum level of any leaf of a tree

A

Depth

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

[Tree Terminologies] group of disjoint trees

A

Forest

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

any node that has at least one non-empty child

A

internal node

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

Simplest form of tree

A

Binary Tree

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

A binary tree consists of: (clue: NS)

A

NODE (root node)
SUBTREES (left and right)

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

A tree is binary if each node has a maximum of __________ branches.

A

Two

How well did you know this?
1
Not at all
2
3
4
5
Perfectly
25
When every non-leaf node in binary tree is filled with left and right sub-trees, the tree is called ____________
Strictly binary tree
26
A tree in which each level of the tree is completely filled, except the bottom level
Complete binary tree
27
Operations on Binary Tree (clue: CELRPSIDSCT)
Create Empty Lchild Rchild Parent/Father Sibling Insert Deletion Search Copy Tree Traversal
28
[Operations on Binary Tree] create an empty binary tree
Create
29
[Operations on Binary Tree] return true when binary tree is empty, else return false
Empty
30
[Operations on Binary Tree] A pointer is returned to left child of a node, when a node is without left child, NULL pointer is returned
Lchild
31
[Operations on Binary Tree] A pointer is returned to right child of a node, when a node is without left child, NULL pointer is returned
Rchild
32
[Operations on Binary Tree] a pointer to father of a node is returned
Father/parent
33
[Operations on Binary Tree] A pointer to brother of the node is returned or else NULL pointer is returned
Sibling
34
[Operations on Binary Tree] to insert a node
Insert
35
[Operations on Binary Tree] to delete a node
Deletion
36
[Operations on Binary Tree] to search a given node
Search
37
[Operations on Binary Tree] copy one tree to another
Copy
38
Used to display/access the data in a tree in a certain order
Traversal of a Binary Tree
39
In traversing, _____ sub-tree is always traversed after _____ sub-tree
right, left
40
Three methods of traversing (clue: PIP)
Preorder Traversing Inorder Traversing Postorder Traversing
41
[Methods of Traversing] ---Root-Left-Right ---Prefix expression
Preorder Traversing
42
[Methods of Traversing] ---Left-Root-Right ---Infix expression
Inorder Traversing
43
[Methods of Traversing] ---Left-Right-Root ---Postfix expression
Postorder Traversing
44
Stores keys in the nodes in a way so that searching, insertion and deletion can be done efficiently
Binary Search Tree
45
Left child should be _______ than the value of the root. (choices: greater than, less than, equal to)
Less than
46
Right child should be _______ than the value of the root. (choices: greater than, less than, equal to)
Greater than or equal to
47
balanced binary search tree in which balance factor of every node is either -1, 0 or +1
AVL Tree
48
difference between the heights of the left and right subtrees of that node
Balance factor
49
When was the AVL tree introduced and who introduced it?
1962 G.M. Adelson-Velsky, E.M. Landis.
50
process of moving nodes either to left or to right to make the tree balanced
Rotation
51
Two types of rotations (clue: SD)
Single Rotation Double Rotation
52
Rotations under Single Rotation
Single Left Rotation (LL Rotation) Single Right Rotation (RR Rotation)
53
Rotations under Double Rotation
Left Right Rotation (LR Rotation) Right Left Rotation (RL Rotation)
54
[Rotations] Every node moves one position to left from the current position
Single Left Rotation (LL Rotation)
55
[Rotation] Every node moves one position to right from the current position
Single Right Rotation (RR Rotation)
56
[Rotation] A sequence of single left rotation followed by a single right rotation
Left Right Rotation (LR Rotation)
57
[Rotation] A sequence of single right rotation followed by a single left rotation
Right Left Rotation (RL Rotation)
58
AVL Tree Operations (clue: SID)
Search Insertion Deletion
59
A special tree-based data structure and is considered as a complete binary tree
Heap Tree
60
Two types of heap (clue: MM)
Min-heap Max-heap
61
[Types of heap] the smallest element is the root of the tree and each node is greater than or equal to its parent
Min-heap
62
[Types of heap] the largest element is the root of the tree and each node is less than or equal to its parent
Max-heap
63
The common implementation of a heap data structure
Binary Heap
64
Properties of binary heap
---A complete binary tree when all the levels are completely filled except possibly the last level and the last level has its keys as much left as possible ---Can be a min-heap or max-heap
65
A binary heap is a complete _____ tree and can best be represented as an _____
binary, array
66
Operations on Binary Heap (minimum heap) (clue: IDDEG)
Insert() Delete() decreasekey() extractMin() getMin() Note: For maximum heap, the operations reverse accordingly.
67
[Operations on Binary Heap (minimum heap)] Inserts a new key at the end of the tree. Depending on the value of the key inserted, the heap can be adjusted, without violating the heap property.
Insert() Note: For maximum heap, the operations reverse accordingly.
68
[Operations on Binary Heap (minimum heap)] Deletes a key.
Delete() Note: For maximum heap, the operations reverse accordingly.
69
[Operations on Binary Heap (minimum heap)] Decreases the value of the key. There might have the need to maintain the heap property when this operation takes place.
decreasekey() Note: For maximum heap, the operations reverse accordingly.
70
[Operations on Binary Heap (minimum heap)] Removes the minimum element from the min-heap. It needs to maintain the heap property after removing the minimum element.
extractMin() Note: For maximum heap, the operations reverse accordingly.
71
[Operations on Binary Heap (minimum heap)] Returns the root element of the min-heap.
getMin() Note: For maximum heap, the operations reverse accordingly.
72
Applications of Heaps (clue: HPGW)
Heapsort Priority Queues Graph algorithms Worst-case complexity of quicksort algorithm can be overcome by using heap sort
73
[Applications of Heaps] binary heap supports all the operations required for successfully implementing the priority queues in O(log n) time
Priority Queues
74
An application of binary trees and priority queues
Huffman Coding