Deck 6: Trees

ملء الشاشة (f)
exit full mode
سؤال
The node at the top of a tree is called its ____________________.
استخدم زر المسافة أو
up arrow
down arrow
لقلب البطاقة.
سؤال
The links from a node to its successors care called ____________________.
سؤال
The predessor of a node is called its ____________________.
سؤال
Nodes that have the same parent are ____________________.
سؤال
You declare that an object is serializable by adding the declaration ____________________.
سؤال
Leaf nodes are also known as ____________________ nodes.
سؤال
The ____________________ is the number of nodes in the longest path from the root node to a leaf node.
سؤال
The ____________________ is used to implement a priority queue.
سؤال
A(n) ____________________ is a data structure in which only the highest-priority item is accessible.
سؤال
The ____________________ of a node is a measure of its distance from the root.
سؤال
Removal from a heap is always from the bottom.
سؤال
If node A is the parent of node B, which is the parent of node C, node A is node C's ancestor, and node C is node A's descendant.
سؤال
If node n is not the root of tree T, its level is 1 + the level of its parent.
سؤال
Parentheses are not stored in a binary tree, because the tree structure dictates the order of operator evaluation.
سؤال
Using Huffman codes to encode text files should give you files with more bits than you would get using other codes.
سؤال
A set of nodes T is a binary search tree ____.

A) if T is not empty, its root node has two subtrees, TL and TR, such that TL and TR are binary search trees and the value in the root node of T is greater than all values in TL and is less than all values in TR.
B) if T is not empty, its root node has two subtrees, TL and TR, such that TL and TR are binary trees.
C) if T is empty and its height is 0
D) if T is not empty, its height height is the maximum depth of its nodes.
سؤال
Searching a binary search tree is a(n) ____ process.

A) O(n)
B) O(log n)
C) O(1)
D) O(log2n)
سؤال
Which of the following is the preorder traversal of a binary tree?

A) Traverse TL, visit root node, traverse TR.
B) Visit root node, traverse TL, traverse TR.
C) Traverse TL, traverse TR, visit root node.
D) Visit root node, traverse TR, traverse TL.
سؤال
Which of the following is the postorder traversal of of a binary tree?

A) Traverse TL, visit root node, visit root node.
B) Visit root node, traverse TL, traverse TR.
C) Traverse TL, traverse TR, visit root node.
D) Visit root node, traverse TR, traverse TL.
سؤال
In a priority queue, the poll method first saves the item at the top of the heap.
سؤال
Complete the following algorithm which recursively inserts an item into a binary search tree.
If the root is null
Replace empty tree with a new tree with the item at the root and return true.
Else if the item is equal to root.data
____
Else if the item is less than root.data
Recursively insert the item in the left subtree.
Else
Recursively insert the item in the right subtree.

A) The item is not in the tree; return false.
B) The item is already in the tree; return false.
C) The item is not in the tree; return true.
D) The item is already in the tree; return true.
سؤال
Which of the following is the algorithm for insertion in a heap?

A) Insert the new item in the next position at the bottom of the heap.
while new item is not at the root and new item is smaller that its parent
Swap the new item with its parent, moving the item up the heap.
B) Insert the new item in the next position at the top of the heap.
while new item is at the root and new item is smaller that its parent
Swap the new item with its parent, moving the item up the heap.
C) Insert the new item in the next position at the bottom of the heap.
while new item is at the root and new item is larger that its parent
Swap the new item with its parent, moving the item up the heap.
D) Insert the new item in the next position at the bottom of the heap.
while new item is at the root and new item is smaller that its parent
Swap the new item with its parent, moving the item down the heap.
سؤال
Insertion into and removal from a heap is ____.

A) O(n)
B) O(n2)
C) O(log n)
D) O(log2n)
سؤال
The following algorithm is a(n) ____ .
If the tree is empty
Return null (target is not found).
Else if the target matches the root node's data
Return the data stored at the root node.
Else if the target is less than the root node's data
Return the result of searching the left subtree of the root.
Else
Return the result of searching the right subtree of the root.

A) algorithm for removal from a heap
B) algorithm for insertion into a heap
C) algoithm for insertion intoa a binary tree
D) recursive algorithm for searching a binary tree
سؤال
Expanding and contracting arrays are ____ operations.

A) O(n).
B) O(log n)
C) O(n)
D) O(n2)
فتح الحزمة
قم بالتسجيل لفتح البطاقات في هذه المجموعة!
Unlock Deck
Unlock Deck
1/25
auto play flashcards
العب
simple tutorial
ملء الشاشة (f)
exit full mode
Deck 6: Trees
1
The node at the top of a tree is called its ____________________.
root
2
The links from a node to its successors care called ____________________.
branches
3
The predessor of a node is called its ____________________.
parent
4
Nodes that have the same parent are ____________________.
فتح الحزمة
افتح القفل للوصول البطاقات البالغ عددها 25 في هذه المجموعة.
فتح الحزمة
k this deck
5
You declare that an object is serializable by adding the declaration ____________________.
فتح الحزمة
افتح القفل للوصول البطاقات البالغ عددها 25 في هذه المجموعة.
فتح الحزمة
k this deck
6
Leaf nodes are also known as ____________________ nodes.
فتح الحزمة
افتح القفل للوصول البطاقات البالغ عددها 25 في هذه المجموعة.
فتح الحزمة
k this deck
7
The ____________________ is the number of nodes in the longest path from the root node to a leaf node.
فتح الحزمة
افتح القفل للوصول البطاقات البالغ عددها 25 في هذه المجموعة.
فتح الحزمة
k this deck
8
The ____________________ is used to implement a priority queue.
فتح الحزمة
افتح القفل للوصول البطاقات البالغ عددها 25 في هذه المجموعة.
فتح الحزمة
k this deck
9
A(n) ____________________ is a data structure in which only the highest-priority item is accessible.
فتح الحزمة
افتح القفل للوصول البطاقات البالغ عددها 25 في هذه المجموعة.
فتح الحزمة
k this deck
10
The ____________________ of a node is a measure of its distance from the root.
فتح الحزمة
افتح القفل للوصول البطاقات البالغ عددها 25 في هذه المجموعة.
فتح الحزمة
k this deck
11
Removal from a heap is always from the bottom.
فتح الحزمة
افتح القفل للوصول البطاقات البالغ عددها 25 في هذه المجموعة.
فتح الحزمة
k this deck
12
If node A is the parent of node B, which is the parent of node C, node A is node C's ancestor, and node C is node A's descendant.
فتح الحزمة
افتح القفل للوصول البطاقات البالغ عددها 25 في هذه المجموعة.
فتح الحزمة
k this deck
13
If node n is not the root of tree T, its level is 1 + the level of its parent.
فتح الحزمة
افتح القفل للوصول البطاقات البالغ عددها 25 في هذه المجموعة.
فتح الحزمة
k this deck
14
Parentheses are not stored in a binary tree, because the tree structure dictates the order of operator evaluation.
فتح الحزمة
افتح القفل للوصول البطاقات البالغ عددها 25 في هذه المجموعة.
فتح الحزمة
k this deck
15
Using Huffman codes to encode text files should give you files with more bits than you would get using other codes.
فتح الحزمة
افتح القفل للوصول البطاقات البالغ عددها 25 في هذه المجموعة.
فتح الحزمة
k this deck
16
A set of nodes T is a binary search tree ____.

A) if T is not empty, its root node has two subtrees, TL and TR, such that TL and TR are binary search trees and the value in the root node of T is greater than all values in TL and is less than all values in TR.
B) if T is not empty, its root node has two subtrees, TL and TR, such that TL and TR are binary trees.
C) if T is empty and its height is 0
D) if T is not empty, its height height is the maximum depth of its nodes.
فتح الحزمة
افتح القفل للوصول البطاقات البالغ عددها 25 في هذه المجموعة.
فتح الحزمة
k this deck
17
Searching a binary search tree is a(n) ____ process.

A) O(n)
B) O(log n)
C) O(1)
D) O(log2n)
فتح الحزمة
افتح القفل للوصول البطاقات البالغ عددها 25 في هذه المجموعة.
فتح الحزمة
k this deck
18
Which of the following is the preorder traversal of a binary tree?

A) Traverse TL, visit root node, traverse TR.
B) Visit root node, traverse TL, traverse TR.
C) Traverse TL, traverse TR, visit root node.
D) Visit root node, traverse TR, traverse TL.
فتح الحزمة
افتح القفل للوصول البطاقات البالغ عددها 25 في هذه المجموعة.
فتح الحزمة
k this deck
19
Which of the following is the postorder traversal of of a binary tree?

A) Traverse TL, visit root node, visit root node.
B) Visit root node, traverse TL, traverse TR.
C) Traverse TL, traverse TR, visit root node.
D) Visit root node, traverse TR, traverse TL.
فتح الحزمة
افتح القفل للوصول البطاقات البالغ عددها 25 في هذه المجموعة.
فتح الحزمة
k this deck
20
In a priority queue, the poll method first saves the item at the top of the heap.
فتح الحزمة
افتح القفل للوصول البطاقات البالغ عددها 25 في هذه المجموعة.
فتح الحزمة
k this deck
21
Complete the following algorithm which recursively inserts an item into a binary search tree.
If the root is null
Replace empty tree with a new tree with the item at the root and return true.
Else if the item is equal to root.data
____
Else if the item is less than root.data
Recursively insert the item in the left subtree.
Else
Recursively insert the item in the right subtree.

A) The item is not in the tree; return false.
B) The item is already in the tree; return false.
C) The item is not in the tree; return true.
D) The item is already in the tree; return true.
فتح الحزمة
افتح القفل للوصول البطاقات البالغ عددها 25 في هذه المجموعة.
فتح الحزمة
k this deck
22
Which of the following is the algorithm for insertion in a heap?

A) Insert the new item in the next position at the bottom of the heap.
while new item is not at the root and new item is smaller that its parent
Swap the new item with its parent, moving the item up the heap.
B) Insert the new item in the next position at the top of the heap.
while new item is at the root and new item is smaller that its parent
Swap the new item with its parent, moving the item up the heap.
C) Insert the new item in the next position at the bottom of the heap.
while new item is at the root and new item is larger that its parent
Swap the new item with its parent, moving the item up the heap.
D) Insert the new item in the next position at the bottom of the heap.
while new item is at the root and new item is smaller that its parent
Swap the new item with its parent, moving the item down the heap.
فتح الحزمة
افتح القفل للوصول البطاقات البالغ عددها 25 في هذه المجموعة.
فتح الحزمة
k this deck
23
Insertion into and removal from a heap is ____.

A) O(n)
B) O(n2)
C) O(log n)
D) O(log2n)
فتح الحزمة
افتح القفل للوصول البطاقات البالغ عددها 25 في هذه المجموعة.
فتح الحزمة
k this deck
24
The following algorithm is a(n) ____ .
If the tree is empty
Return null (target is not found).
Else if the target matches the root node's data
Return the data stored at the root node.
Else if the target is less than the root node's data
Return the result of searching the left subtree of the root.
Else
Return the result of searching the right subtree of the root.

A) algorithm for removal from a heap
B) algorithm for insertion into a heap
C) algoithm for insertion intoa a binary tree
D) recursive algorithm for searching a binary tree
فتح الحزمة
افتح القفل للوصول البطاقات البالغ عددها 25 في هذه المجموعة.
فتح الحزمة
k this deck
25
Expanding and contracting arrays are ____ operations.

A) O(n).
B) O(log n)
C) O(n)
D) O(n2)
فتح الحزمة
افتح القفل للوصول البطاقات البالغ عددها 25 في هذه المجموعة.
فتح الحزمة
k this deck
locked card icon
فتح الحزمة
افتح القفل للوصول البطاقات البالغ عددها 25 في هذه المجموعة.