Filters
Question type

Study Flashcards

Which of the following is described as a node's parent, its parent's parent, and so on up to the root?


A) descendant
B) path
C) depth
D) ancestor

E) None of the above
F) A) and B)

Correct Answer

verifed

verified

A parse tree describes the syntactic structure of a sentence in terms of its component parts.

A) True
B) False

Correct Answer

verifed

verified

In a tree, an interior node is a node that has no children.

A) True
B) False

Correct Answer

verifed

verified

False

Which of the following is the topmost node in a tree and does not have a parent?


A) root
B) child
C) leaf
D) interior node

E) All of the above
F) A) and D)

Correct Answer

verifed

verified

Which of the following is NOT a common application for a binary tree?


A) heap
B) expression tree
C) search tree
D) stack

E) A) and C)
F) C) and D)

Correct Answer

verifed

verified

The heap sort algorithm builds a heap from a set of data and then repeatedly removes the leaf item and adds it to the end of a list.

A) True
B) False

Correct Answer

verifed

verified

False

In the code for the add method in the implementation of a heap, what is the missing code? def add(self, item) : Self.size += 1 Self.heap.append(item) CurPos = len(self.heap) - 1 While curPos > 0: Parent = (curPos - 1) // 2 ParentItem = self.heap[parent] If parentItem <= item: < missing code > Else: Self.heap[curPos] = self.heap[parent] Self.heap[parent] = item CurPos = parent


A) curPos += 1
B) break
C) self.heap[ curPos ] = item
D) parent = curpos

E) A) and D)
F) B) and C)

Correct Answer

verifed

verified

Because the recursive search algorithm doesn't require a parameter for a tree node, you can define it as a top-level method.

A) True
B) False

Correct Answer

verifed

verified

In the replace method for a binary search tree interface, None is returned if the first argument cannot be found.

A) True
B) False

Correct Answer

verifed

verified

You should use a postorder iteration method for the tree's __iter__ method to enable the user to create a clone of the tree with the same shape as the original.

A) True
B) False

Correct Answer

verifed

verified

Which symbol type is NOT found in an EBNF?


A) terminal symbols
B) metasymbols
C) hypersymbols
D) nonterminal symbols

E) All of the above
F) B) and C)

Correct Answer

verifed

verified

C

Syntax rules specify how sentences in the language should be interpreted.

A) True
B) False

Correct Answer

verifed

verified

One of the types of symbols used by an EBNF is metasymbols.

A) True
B) False

Correct Answer

verifed

verified

The level order traversal guides the visits to items from left to right through the levels of the tree, much like reading lines of text in a document.

A) True
B) False

Correct Answer

verifed

verified

In the following code for the find method, what is the missing code? def find(self, item) : Def recurse(node) : If node is None: Return None Elif item == node.data: < missing code > Elif item < node.data: Return recurse(node.left) Else: Return recurse(node.right) Return recurse(self.root)


A) return node.data
B) return self.data
C) return recurse(node.root)
D) return node.root

E) A) and B)
F) A) and C)

Correct Answer

verifed

verified

In a tree, which of the following is true?


A) all items have a distinct predecessor and successor
B) each item can have multiple children
C) each item can have multiple parents
D) the root has exactly one parent

E) B) and C)
F) All of the above

Correct Answer

verifed

verified

A grammar in a programming language consists of a vocabulary, syntax rules, and a list of operators.

A) True
B) False

Correct Answer

verifed

verified

Two trees are considered equal if they contain the same items in the same positions.

A) True
B) False

Correct Answer

verifed

verified

In the code for the inorder method for a binary search tree, what is the missing code? def inorder(self) : Lyst = list() Def recurse(node) : If node != None: < missing code > Lyst.append(node.data) Recurse(node.right) Recurse(self.root) Return iter(lyst)


A) recurse(node.root)
B) return(node.data)
C) recurse(node.left)
D) return iter(self.root)

E) A) and B)
F) A) and C)

Correct Answer

verifed

verified

The height of an empty tree is -1.

A) True
B) False

Correct Answer

verifed

verified

Showing 1 - 20 of 50

Related Exams

Show Answer