MIdterm Practice: Chapters 6 - 11

Réussis tes devoirs et examens dès maintenant avec Quizwiz!

Which of the following is the prefix form of the infix expression: (8 + 6) / (16 - 4)? + 8 6 / - 16 4 / 8 6 + - 16 4 / + - 8 6 16 4 / + 8 6 - 16 4

/ + 8 6 - 16 4

Which of the following is a prefix expression? / a + b c a b c + / a * b + c a / (b + c)

/ a + b c

To initialize a queue that is represented by a circular array, front is set to ______. 0 1 MAX_QUEUE MAX_QUEUE - 1

0

Write a recursive definition for the set of positive odd numbers.

1 is odd, and if n is odd, so is n+2.

What is the value of the prefix expression: - * 3 8 + 6 5? 11 23 13 21

13

A full binary tree with height 4 has ______ nodes. 7 8 15 31

15

What is the value of the infix expression: 8 * (5 - 2)? 16 24 38 40

24

The Towers of Hanoi problem makes exactly ______ moves when it starts with N disks. 2^N 2^N - 1 N^2 N^3 - 1

2^N - 1

Which of the following strings is NOT a palindrome? "madam" "" "adam" "deed"

"adam"

Which of the following strings is a palindrome? "bottle" "beep" "coco" "r"

"r"

The Java ______ operator is used to obtain the wraparound effect of a circular array-based queue. * + % /

%

Which of the following is a fully parenthesized expression? x * y + z (x * y) + z ((x * y) + z) (x) * (y) + (z)

((x * y) + z)

Which of the following is NOT a valid prefix expression? - + a b + c d / a + b c * + * a b c d * - a b c d

* - a b c d

______ is a problem-solving technique that involves guesses at a solution. Recursion Backtracking Iteration Induction

Backtracking

What is containment?

Containment is a relationship between classes whereby one class contains an instance of another class.

Operations on a queue can be carried out at ______. its front only its back only both its front and back any position in the queue

both its front and back

How can precedence and association rules be avoided in infix notation?

by using fully parenthesized expressions; that is, placing parentheses around each pair of operands together with their operator.

The Java ______ determines whether a given string is a syntactically correct Java program. applet editor compiler programmer

compiler

The symbol • means ______. separate concatenate multiply select

concatenate

A data element within a record is called a ______. field tree collection key

field

If the field modifier ______ is specified in a method definition, the method cannot be overridden by a subclass. public protected final abstract

final

Write the code fragment to remove the front item of a queue that contains more than one items and which is represented by a circular linked list. ;

firstNode = lastNode.getNext(); lastNode.setNext(firstNode.getNext())

Which of the following code fragments is used to delete the item at the front of a queue represented by a circular array? front = MAX_QUEUE - front; --count; front = front - back; --count; front = (front+1) % MAX_QUEUE; --count; front = (back+1) % MAX_QUEUE; --count;

front = (front+1) % MAX_QUEUE; --count;

An empty string ______. has a length of 0 has a length of 1 is not a valid string has a negative value for its length

has a length of 0

According to the following statement: JavaPrograms = {strings w : w is a syntactically correct Java program} when is a given string a member of the language JavaPrograms?

if it is a syntactically correct Java program.

The ADT ______ allows you to insert into, delete from, and inspect the item at any position of the ADT. stack queue list array

list

A queue can be used to preserve the order of occurrences.

true

If the string w is a palindrome, the first and last characters of w are the same.

true

In an event-driven simulation of a bank, the departure times of customers are determined by the simulation.

true

Induction can be used to prove that a recursive algorithm is correct.

true

Parentheses are not necessary in prefix expressions.

true

The addition of an item to an empty queue is a special case.

true

The empty string is a palindrome.

true

The first item to be added to a queue is the first item to be removed from the queue.

true

The stricter the definition of a language, the easier it is for a compiler to recognize a syntactically legal expression.

true

A reference-based implementation of a queue that uses a linear linked list would need at least ______ external references. one two three four

two

If the string w is a palindrome, which of the following is true? w minus its first character is a palindrome w minus its last character is a palindrome w minus its first and last characters is a palindrome the first half of w is a palindrome the second half of w is a palindrome

w minus its first and last characters is a palindrome

In a grammar, the symbol x y means ______. x or y x followed by y x or y or both x multiplied by y

x followed by y

In a grammar, the symbol x | y means ______. x or y x followed by y x out of y x divided by y

x or y

The ______ is a position-oriented ADT that is not linear. sorted list queue binary tree list

binary tree

The ADT queue is value-oriented.

false

The expression: (a + b) / c is a fully parenthesized expression.

false

The following string is a valid prefix expression: + * a b c d

false

The root of a tree has one parent.

false

Which of the following is NOT an ADT queue operation? enqueue isEmpty pop peek

pop

What is the value of the postfix expression: 6 7 + 8 2 - *? -3 -10 48 78

78

The correct grammar for the following language L: L = {w: w is of the form SnDn for some n ≥ 0} is ______. <legal-word> = S | <legal-word> | D <legal-word> = empty string | S | <legal-word> | D <legal-word> = S <legal-word> D <legal-word> = empty string | S <legal-word> D

<legal-word> = empty string | S <legal-word> D

What is a closed-form formula?

A closed-form formula is a nonrecursive algebraic expression.

What is a deque?

A deque is an ADT that allows for insertions and deletions at both ends.

What is a fully parenthesized expression?

A fully parenthesized expression is one that has parentheses around each pair of operands together with their operator.

What is meant by a grammar?

A grammar states the rules for forming the strings in a language.

When is a method in a subclass said to override a method in the superclass?

A method in a subclass is said to override a method in the superclass if the two methods have the same declarations.

How can a package be created in Java?

A package can be created by placing a package statement at the top of each class file that is part of the package.

What is a postfix expression?

A postfix expression is an algebraic expression in which every binary operator follows its two operands.

What is a prefix expression?

A prefix expression is an algebraic expression in which every binary operator precedes its two operands.

What is a recognition algorithm?

A recognition algorithm is based on a language's grammar, and determines whether a given string is in the language.

What is an event-driven simulation?

A simulation that uses events generated by a mathematical model that is based on statistics and probability.

What is a subinterface?

A subinterface is an interface that is derived from an existing interface.

What is meant by the first-in, first-out property of a queue?

According to the first-in, first-out property of a queue, the first item inserted into a queue is the first item to leave the queue.

What is an abstract class?

An abstract class is a class without instances that forms the basis of other classes that descend from it.

What is an access modifier?

An access modifier is a keyword which is used to control the visibility of the members of a class.

What is an empty string?

An empty string is a string of length zero.

What is the difference between an external event and an internal event?

An external event is an event that is determined from the input data to an event-driven simulation. An internal event is an event that is determined by a computation within an event-driven simulation.

What is the advantage an implementation of a queue that uses the ADT list over an implementation that uses a linked list?

An implementation of a queue that uses the ADT list is much simpler to write and read than an implementation that uses a linked list.

What is an infix expression?

An infix expression is an algebraic expression in which every binary operator appears between its two operands.

What kind of relationship exists between a superclass and a subclass?

An is-a relationship exists between a superclass and a subclass.

What is meant by dynamic binding?

Dynamic binding is a situation in which the appropriate version of a method is decided at execution time.

What is the procedure for proving a statement by mathematical induction?

First, show that the base case(s) are correct. Then we make an inductive hypothesis, that the statement is true for some integer k. Finally, we show that if the statement is true for k, it follows that it is also true for k+1.

What is the goal of a simulation?

Generally, the goal of a simulation is to generate statistics that summarize the performance of an existing system or to predict the performance of a proposed system.

For defining palindromes, why is it not enough to use just the empty string as a base case?

If a string has an odd length, we will eventually get down to the case of a string of length 1, which should also be a base case because it is a trivial palindrome.

What is the main difference between a stack and a queue?

In a stack, all operations are performed at the top of the stack. As a result, the first item to enter the stack is the last item to leave the stack. In contract, operations are performed at both ends of a queue. In a queue, the first item to enter the queue is the first item to leave the queue.

______ can be used to prove properties about recursive algorithms. Prefix notations Postfix notations Induction Backtracking

Induction

What is meant by object type compatibility?

It is a characteristic of objects that enables you to use an instance of a subclass where an instance of the superclass is expected, but not the converse.

Give two examples of run-time errors or exceptions that may occur when we enqueue or dequeue.

It's an error to attempt to dequeue from an empty queue. Also, if the queue is represented as an array and we try to enqueue, we may run up against the maximum size of the queue.

To initialize a queue that is represented by a circular array, back is set to ______. 0 1 MAX_QUEUE MAX_QUEUE - 1

MAX_QUEUE - 1

Name two things that an abstract class may include that an interface would not.

Method implementations, and data members.

What is method overloading?

Method overloading is when a method is created that has the same name as another method, but a different set of parameters.

What are some of the advantages of using an object-oriented approach to the development of a software?

Previously implemented classes can be reused in future programs. Program maintenance is easier. Program verification is easier.

Define the problem of rightward drift in an array-based implementation of a queue.

Rightward drift is the problem of the front of the queue moving toward the end of the array.

What is meant by static binding?

Static binding is a situation in which the appropriate version of a method is determined at compilation time.

When is the base case of the Eight Queens problem reached?

The base case of the Eight Queens problem is reached when there are no more columns to consider.

What is the action performed by the dequeue operation?

The dequeue operation retrieves and removes the front of a queue - the item that was added earliest. It throws a QueueException if the operation is not successful.

What is the action performed by the dequeueAll operation?

The dequeueAll operation removes all items from a queue.

What is the action performed by the enqueue operation?

The enqueue operation adds a new item at the back of a queue. It throws a QueueException if the operation is not successful.

What is the main benefit of using a grammar that is recursive?

The main benefit of a grammar that is recursive is that, based on the grammar, it is very easy to write a recognition algorithm for the language.

What is the action performed by the peek operation?

The peek operation retrieves the front of a queue, but does not change the queue. That is, it retrieves the item that was added earliest. It throws a QueueException if the retrieval is not successful.

What does the reference super represent?

The reference super represents the object reference for the superclass.

Define the root of a tree.

The root of a tree is the only node in the tree with no parent.

Describe in your own words the language defined by this recursive definition: < S > = @ | < W > | @ < S > < W > = aab | aa < W > b

The set of words containing: an arbitrary number of @ symbols, followed by instances of the letter a, followed by instances of the letter b: where there are twice as many a's as b's.

What are the three methods that a class that implements the Iterator interface must provide?

The three methods are next(), hasNext(), and remove().

What are the two base cases in a recursive description of a palindrome?

The two base cases in a recursive description of a palindrome are strings of length 0 and strings of length 1.

What are the two basic kinds of relationships among classes?

The two kinds of relationships are: is-a relationship and has-a relationship.

What kind of methods are appropriate to implement in an abstract class?

Those that provide access to private data fields, or that express functionality common to all of its subclasses.

What are three examples of position-oriented ADT?

Three position-oriented ADTs are the list, the stack and the queue.

Explain how you would design a method, returning boolean, that determines if a string passed as a parameter satisfies this recursive definition. < S > = < W > < W > < W > = a | b | a < W > | b < W >

We are basically looking to see if the string is the same substring repeated twice, such as "abcdabcd". First, return false if the string length is less than 2 or odd. Next, find the midpoint of the string, and create two substrings, s1 and s2. Then, check to see if s1 matches s2.

If an object is inserted into a queue, how soon can it be removed? Answer: We have to wait for all of the other elements to be dequeued first, because of the inherent FIFO policy of queues.

We have to wait for all of the other elements to be dequeued first, because of the inherent FIFO policy of queues.

If you wanted to write a program to simulate queues in front a bank teller, on what basis would you decide on a maximum size of your queue?

We would first consider how many people could realistically be waiting on line at the same time.

What is an advantage to defining an ADT that uses a generic data type? .

When retrieving an item from the ADT, it won't be necessary to cast the return value from Object, and we can thus avoid class cast exceptions if the type of the data in the collection was inappropriate

Is it legal for a subclass of an abstract class not to implement all of the methods it inherits? Briefly explain.

Yes, but it would then have to declare those unimplemented methods as abstract.

Can the object type of an argument in the call to a method be difference from the object type of the corresponding formal parameter? Explain.

Yes, the two object types can be different. The object type of an argument in a call to a method can be a subclass of the corresponding formal parameter's object type.

Which of the following is an infix expression? / a + b c a b c + / a b / + c a / (b + c)

a / (b + c)

Which of the following is the postfix form of the infix expression: a * b - (c + d)? a b c d + - * a b * c d + - a b c - * d + a b c - d + *

a b * c d + -

Which of the following is the postfix form of the prefix expression: * + a b c? a + b * c a + b c * a b + c * a b * c +

a b + c *

Which of the following is a postfix expression? / a + b c a b c + / * a b c / + a / (b + c)

a b c + /

Which of the following is NOT a valid postfix expression? a b c - d * a b - c d + - a b c + / a b * c + d *

a b c - d *

A subtree of node n is a subtree rooted at ______. node n the parent of node n a child of node n a sibling of node n

a child of node n

What is backtracking? .

a strategy for guessing at a solution and backing up when an impasse is reached

An event list for an event-driven simulation of a bank contains ______. all arrival events all arrival events that will occur but have not occurred yet all departure events all departure events that will occur but have not occurred yet all arrival and departure events that will occur but have not occurred yet

all arrival and departure events that will occur but have not occurred yet

The statement: JavaPrograms = {strings w : w is a syntactically correct Java program} signifies that ______. all strings are syntactically correct Java programs all syntactically correct Java programs are strings the JavaPrograms language consists of all the possible strings a string is a language

all syntactically correct Java programs are strings

A node on the path from the root to node n is a(n) ______ of node n. ancestor descendant subtree leaf

ancestor

In the ADT list, items can be added ______. only at the front of the list only at the back of the list either at the front or at the back of the list at any position in the list

at any position in the list

Write the code fragment to insert the item newItem into a queue that is represented by a circular array.

back = (back+1) % MAX_QUEUE; items[back] = newItem; ++count;

Which of the following is true about a time-driven simulation of a bank? arrival times are obtained from an input file transaction times are obtained from an input file currentTime is incremented by 1 to simulate the ticking of a clock no action is required between events

currentTime is incremented by 1 to simulate the ticking of a clock

The ______ operation retrieves and removes the front of a queue. isEmpty enqueue dequeue peek

dequeue

The pop operation of the ADT stack is similar to the ______ operation of the ADT queue. isEmpty enqueue dequeue peek

dequeue

If a queue is implemented as the ADT list, which of the following queue operations can be implemented as list.remove(1)? enqueue() dequeue() isEmpty() peek()

dequeue()

Which of the following methods of QueueInterface does NOT throw a QueueException? enqueue dequeue dequeueAll peek

dequeueAll

A subclass is said to be a ______ of its superclass. descendant relative leaf mirror

descendant

The ______ operation adds a new item to a queue. enqueue dequeue push peek

enqueue

In the Eight Queens problem, each column can contain ______. exactly one queen exactly two queens at most two queens at most three queens

exactly one queen

A string of length 1 is not a palindrome.

false

According to the following statement: JavaPrograms = {strings w : w is a syntactically correct Java program} all strings are Java programs.

false

If a string is added to a stack, characters removed from the stack will occur in the order in which they appear in the original string.

false

In a time-driven simulation, no action is required between events.

false

In an event-driven simulation of a bank, the arrival of a customer is an internal event.

false

Infix expressions do not need precedence rules.

false

New items enter a queue at its front.

false

Operations of the ADT stack can be viewed as general versions of the list and queue operations.

false

Rightward drift is a problem that is encountered in a reference-based implementation of a queue.

false

In an implementation of a queue uses the ADT list, which of the following can be used to implement the operation enqueue(newItem)? list.add(list.size(), newItem) list.add(list.size()+1, newItem) list.add(newItem.size(), newItem) list.add(newItem.size()+1, newItem)

list.add(list.size()+1, newItem)

The symbol AnBn is standard notation for the string that consists of ______. an A, followed by an n, followed by a B, followed by an n an equal number of A's and B's, arranged in a random order n consecutive A's, followed by n consecutive B's a pair of an A and a B, followed another pair of an A and a B

n consecutive A's, followed by n consecutive B's

Write the code fragment to insert a new node, referenced by newNode, into a nonempty queue represented by a circular linked list.

newNode.setNext(lastNode.getNext()); lastNode.setNext(newNode); lastNode = newNode;

Which of the following is the code to insert a new node, referenced by newNode, into an empty queue represented by a circular linked list? newNode.setNext(lastNode); lastNode.setNext(lastNode); lastNode = newNode; newNode.setNext(lastNode); newNode = lastNode; newNode.setNext(newNode); lastNode = newNode;

newNode.setNext(newNode); lastNode = newNode;

Name 3 important operations that an iterator object can perform.

next( ) hasNext( ) remove( )

A reference-based implementation of a queue that uses a circular linked list would need at least ______ external references. one two three four

one

In the recursive solution to the Eight Queens problem, the problem size decreases by ______ at each recursive step. one square two squares one column two columns

one column

In a queue, items can be added ______. only at the front of the queue only at the back of the queue either at the front or at the back of the queue at any position in the queue

only at the back of the queue

If a queue is implemented as the ADT list, which of the following queue operations can be implemented as list.get(1)? enqueue() dequeue() isEmpty() peek()

peek

The ______ operation retrieves the item that was added earliest to a queue, but does not remove that item. enqueue dequeue dequeueAll peek

peek

Which of the following operations leaves a queue unchanged? enqueue dequeue dequeueAll peek

peek

Which of the following is true about algebraic expressions? parentheses are needed in all algebraic expressions infix expressions do not require precedence rules postfix expressions do not require association rules fully parenthesized expressions are difficult to recognize and evaluate

postfix expressions do not require association rules

The enqueue operation of the ADT queue is similar to the ______ operation of the ADT stack. isEmpty peek push pop

push

Which of the following is an operation of the ADT stack? enqueue push add get

push

The line of customers in a bank can be represented as a(n) ______. list queue stack array

queue

Which of the following ADTs is like a line of people? list stack queue tree

queue

Which of the following is an operation of the ADT list? pop dequeue peek remove

remove

A language is a set of strings of ______. numbers letters alphabets symbols

symbols

In an event-driven simulation of a bank, which of the following is an internal event? the arrival at the bank of a new customer the start of the transaction of a customer the end of the transaction of a customer the departure from the bank of a customer

the departure from the bank of a customer

What is the advantage of using prefix or postfix expressions instead of infix expressions? .

these expressions do not need precedence rules, association rules, or parentheses. Therefore, the grammars for prefix and postfix expressions are quite simple. In addition, the algorithms that recognize and evaluate these expressions are relatively straightforward

In an event-driven simulation of a bank, which of the following equations can be used to determine the time of a customer's departure? time of next departure = current time - arrival time time of next departure = time service begins + length of transaction time of next departure = arrival time + length of transaction time of next departure = current time - (arrival time + time service begins)

time of next departure = time service begins + length of transaction

Suppose we insert these values into a binary search tree: 1, 7, 2, 5, 8, 3, 6. Give a postorder traversal of this tree.

3 6 5 2 8 7 1

What are the characteristics of a binary tree?

A binary tree is a set of nodes that is either empty or partitioned into a root node and one or two subsets that are binary subtrees of the root. Each node has at most two children, the left child and the right child.

In an array-based representation of a binary tree, what kind of information is stored in a free list?

A free list keeps track of the available nodes

Define a leaf of a tree.

A leaf of a tree is a node in the tree that has no children.

What is a search key?

A search key is the part of a record that identifies it within a collection of records. A search algorithm uses a search key to locate a record within a collection of records.

What is a subtree?

A subtree is any node in a tree together with all of its descendants.

Define an n-ary tree.

An n-ary tree is a generalization of a binary tree whose nodes each can have no more than n children.

In a binary tree, if a node does not have a parent, can it have any children?

Answer: Yes, the root is the only node that does not have a parent, and it certainly may have children.

______ enables the reuse of existing classes. Encapsulation Inheritance Polymorphism Simulation

Inheritance

______ is the ability of a class to derive properties from a previously defined class. Encapsulation Simulation Inheritance Polymorphism

Inheritance

Suppose a binary tree has 3 nodes. The root node is A, and A has a left child B. B has a right child C. Write the inorder, preorder and postorder traversals of this tree.

Inorder = B C A; Preorder = A B C; Postorder = C B A

In inorder traversal, what is the order of visiting a node and its subtrees?

Inorder traversal traverses a node's left subtree, then visits the node, and then traverses the node's right subtree.

The traversal of a binary tree is ______. O(n) O(1) O(n2) O(log2n)

O(n)

______ is the ability of a variable name to represent, during program execution, instances of different but related classes that descend from a common superclass. Inheritance Containment Polymorphism Encapsulation

Polymorphism

In postorder traversal, what is the order of visiting a node and its subtrees?

Postorder traversal traverses a node's left subtree, then traverses the node's right subtree, and then visits the node.

In preorder traversal, what is the order of visiting a node and its subtrees?

Preorder traversal visits a node, then traverses the node's left subtree, and then traverses the node's right subtree.

Briefly describe an algorithm for finding the largest key value in a binary search tree.

Start at the root, and follow the right child reference as far as you can. Once you reach a node whose right child is null, you have found the node with the largest key value.

Define the left child of node n in a binary tree.

The left child of node n in a binary tree is the node directly below and to the left of node n.

What are the three properties of each node n in a binary search tree?

The three properties of each node n in a binary search tree are: n's value is greater than all values in its left subtree TL n's value is less than all values in its right subtree TR both TL and TR are binary search trees

A descendant of node n is a node on a path from node n to ______. the root a leaf a sibling of node n a child of node n

a leaf

A subclass that fails to implement all of the abstract methods of its superclass must be declared as a(n) ______ class. abstract static final private

abstract

If a method definition in a superclass has the field modifier ______, a subclass is required to override the method. static protected final abstract

abstract

Which of the following is NOT true about packages? a package can contain other packages a package's name must be the same as the directory that contains all of the classes in the package a Java source file that is part of a named package must contain a statement at the top of the file that contains the keyword package and the name of the package all classes in a package are available to clients of the package

all classes in a package are available to clients of the package

Which of the following is NOT a property of a complete binary tree of height h? all nodes at level h - 2 and above have two children each when a node at level h - 1 has children, all nodes to its left at the same level have two children each when a node at level h - 1 has one child, it is a left child all leaves are at level h

all leaves are at level h

Each node in a tree has ______. exactly one parent at most one parent exactly two parents at most two parents

at most one parent

Each node in a binary tree has ______. exactly one child at most one child exactly two children at most two children

at most two children

In ______, the left and right subtrees of any node have heights that differ by at most 1. all trees all binary tress n-ary trees balanced binary trees

balanced binary trees

The class from which another class is derived is known as the ______. base class subclass child class final class

base class

Which of the following ADT is position-oriented? binary tree sorted list table priority queue

binary tree

A node directly below node n in a tree is called a ______ of node n. root leaf parent child

child

Java packages provide a way to group related ______ together. objects data structures variables classes

classes

A ______ of height h is full down to level h - 1, with level h filled in from left to right. full binary tree complete binary tree balanced binary tree general tree

complete binary tree

A subclass inherits all of the following members of its superclass EXCEPT ______. public methods data fields constructors protected methods

constructors

The class which inherits the members of another class is known as the ______. superclass derived class base class abstract class

derived class

Static binding is also known as ______. early binding late binding package binding inheritance binding

early binding

The lines between the nodes of a tree are called ______. branches edges arches subtrees

edges

The keyword ______ is used in the class declaration of a subclass to indicate its superclass. inherits extends implements super

extends

A base class is a class that inherits the members of another class.

false

A binary tree cannot be empty.

false

A package cannot contain other packages

false

A subclass cannot add new members to those it inherits from the superclass.

false

A superclass's private data fields can be revised by one of its subclasses.

false

An instance of a superclass can be used anywhere an instance of its subclass is expected.

false

Clients of a class can directly access the protected members of that class.

false

Inorder traversal visits a node before it traverses either of its subtrees.

false

The root of a tree is at level 0.

false

Methods declared as ______ use static binding. protected final public abstract

final

In a ______ of height h, all nodes that are at a level less than h have two children each. general tree binary tree full binary tree complete binary tree

full binary tree

Containment is another name for a(n) ______ relationship. is-a has-a has-many similar-to

has-a

The ______ of a tree is the number of nodes on the longest path from the root to a leaf. height length width age

height

The maximum number of comparisons for a retrieval operation in a binary search tree is the ______. length of the tree height of the tree number of nodes in the tree number of leaves in the tree

height of the tree

A Java ______ specifies behaviors that are common to a group of classes. package final class interface subclass

interface

nheritance should only be used when a(n) ______ relationship exists between the superclass and the subclass. is-a has-a has-many similar-to

is-a

Which of the following is true about an abstract class? it can be instantiated it can contain zero or more abstract methods it cannot be inherited by other classes it cannot contain data fields

it can contain zero or more abstract methods

A(n) ______ is a class that is used to provide access to another class that contains many objects. interface abstract class package iterator

iterator

Dynamic binding is also known as ______. early binding late binding package binding inheritance binding

late binding

The minimum height of a binary tree of n nodes is ______. n n / 2 (n / 2) - 2 log2(n + 1)

log2(n + 1)

In a binary tree, what is the maximum number of siblings a node may have? What is the minimum?

maximum = 1 minimum = 0

The maximum height of a binary tree of n nodes is ______. n n / 2 (n / 2) - 2 log2(n + 1)

n

In a general tree, the leftmost child of a node is called the ______. left child oldest child youngest child binary child

oldest child

What are the three general categories of data management operations?

operations that insert data into a data collection operations that delete data from a data collection operations that ask questions about the data in a data collection

A method that has the same name but a different set of parameters as an existing method is said to ______ the original method. bind cancel override overload

overload

A method in a subclass is said to ______ an inherited method if it has the same method declarations as the inherited method. copy override overload cancel

override

The node that is directly above node n in a tree is called the ______ of node n. root leaf parent child

parent

The ADT stack manages an association between data items and the ______ of the data items. names values sizes positions

positions

A class's ______ members can only be used by its own methods. public protected private package access

private

In general, a class's data fields should be declared as ______. public protected private package access

private

The ______ access modifier hides the members of a class from the class's clients but makes them available to a subclass and to another class within the same package. public protected private package access

protected

A class's ______ members are available to instances of all classes. public protected private package access

public

In a class within a package, the keyword ______ must appear in front of the class keyword to make the class available to clients of the package. open public protected package

public

In a tree, the children of the same parent are called ______. leafs siblings roots contemporaries

siblings

Which of the following ADT is value-oriented? list sorted list stack queue binary tree

sorted list

A superclass method can be accessed by a subclass, even though it has been overridden by the subclass, by using the ______ reference. super final static new

super

The constructor of a subclass can call the constructor of the superclass by using the ______ reference. extends new super import

super

List three position-oriented ADTs.

the ADT list the ADT queue the ADT stack the ADT binary tree.

In an array based representation of a complete binary tree, which of the following represents the parent of node tree[i]? tree[i-2] tree[(i-1)/2] tree[2*i-1] tree[2*i-2]

tree[(i-1)/2]

In an array based representation of a complete binary tree, which of the following represents the left child of node tree[i]? tree[i+2] tree[i-2] tree[2*i+1] tree[2*i+2]

tree[2*i+1]

In an array based representation of a complete binary tree, which of the following represents the right child of node tree[i]? tree[i+2] tree[i-2] tree[2*i+1] tree[2*i+2]

tree[2*i+2]

A complete binary tree of n nodes has a height of log2(n + 1).

true

A package and the directory that contains all the classes in the package must have the same name.

true

A subclass can contain its own version of an inherited method.

true

All trees are hierarchical in nature.

true

An instance of a subclass can access the protected members of the superclass.

true

Inheritance should not be used to implement a has-a relationship.

true

The ADT binary search tree is value-oriented.

true

The ADT binary tree is position-oriented.

true

The array based representation of a binary tree requires a complete binary tree.

true

The operations of the ADT sorted list are based upon the ______ of data items. names values sizes positions

values

A node of a tree is called a(n) ______. edge root branch vertex

vertex


Ensembles d'études connexes

Business Law: Chapter 35 - Employment Discrimination

View Set

The Scientific Method and Descriptive Research Methods// Chapter 1

View Set

Finance 427 Exam 1 (End of Chapter Questions)

View Set

Overview of Personality Disorders (Sherpath)

View Set

Version 21 exam/24 (50 questions) (level: EASY) *extra*

View Set

Nutrition Chapter 2 LearningCurve

View Set

(1.1b) Ancient Indian Scientists Part 1- Astronomers and Mathematicians

View Set

Nursing Care of Adults -> Exam #3

View Set