CS2007Ch0_java
Download
Report
Transcript CS2007Ch0_java
CS2007 - Data Structures II
Review
Review
When you declare a variable that refers to
an object of a given class, you are
creating a(n) ______ to the object.
2
interface
reference
Method
ADT
Review
A reference variable whose sole purpose
is to locate the first node in a linked list is
called ______.
3
top
front
head
first
Review
A reference variable declared as a data
field within a class has the default value
______.
4
0
-1
null
empty
Review
If you attempt to use a reference variable
before it is instantiated, a(n) ______ will
be thrown.
5
IndexOutOfBoundsException
InstantiationException
IllegalAccessException
NullPointerException
Review
According to the principle of information
hiding, the data fields of a class must be
declared as ______.
6
public
protected
private
abstract
Review
The last node of a linear linked list
______.
7
has the value null
has a next reference whose value is null
has a next reference which references the
first node of the list
cannot store any data
Review
A reference variable whose sole purpose
is to locate the first node in a linked list is
called ______.
8
top
front
head
first
Review
An array-based implementation of an ADT
list ______.
9
requires less memory to store an item than a
reference-based implementation
is not a good choice for a small list
has a variable size
has items which explicitly reference the next
items
Review
In all circular linked lists, ______.
10
every node references a predecessor
every node references a successor
the next reference of the last node has the
value null
each node references both its predecessor
and its successor
Review
If the array: 6, 2, 7, 13, 5, 4 is added to a
stack, in the order given, which number
will be the first number to be removed
from the stack?
11
6
2
5
4
Review
The ______ method of the ADT stack
adds an item to the top of the stack.
12
createStack
push
pop
peek
Review
If a stack is used by an algorithm to check
for balanced braces, which of the following
is true once the end of the string is
reached?
13
the stack is empty
the stack has one “{”
the stack has one “}”
the stack has one “{” and one “}”
Review
The pop operation throws a
StackException when it tries to ______.
14
add an item to an empty stack
add an item to an array-based implementation
of a stack that is already full
delete an item from an array-based
implementation of a stack that is already full
delete an item from an empty stack
Review
The push operation throws a
StackException when it tries to ______.
15
add an item to an empty stack
add an item to an array-based implementation
of a stack that is already full
delete an item from an array-based
implementation of a stack that is already full
delete an item from an empty stack
Review
In the StackInterface class, the pop
method returns an item that is an instance
of ______.
16
Integer
Double
String
Object
Review
StackInterface provides the specifications
for ______.
17
only the array-based implementation of a
stack
only the reference-based implementation of a
stack
only an implementation of a stack that uses
the ADT list
all the implementations of a stack
Review
Which of the following ADTs is like a line
of people?
18
list
stack
queue
tree
Review
Operations on a queue can be carried out
at ______.
19
its front only
its back only
both its front and back
any position in the queue
Review
The ______ operation retrieves the item
that was added earliest to a queue, but
does not remove that item.
20
enqueue
dequeue
dequeueAll
peek
Review
A reference-based implementation of a
queue that uses a linear linked list would
need at least ______ external references.
21
one
two
three
four
Review
Which of the following methods of
QueueInterface does NOT throw a
QueueException?
22
enqueue
dequeue
dequeueAll
peek
Review
If a queue is implemented as the ADT list,
which of the following queue operations
can be implemented as list.get(1)?
23
enqueue()
dequeue()
isEmpty()
peek()
Review
The ADT ______ allows you to insert into,
delete from, and inspect the item at any
position of the ADT.
24
stack
queue
List
array
Review
The enqueue operation of the ADT queue
is similar to the ______ operation of the
ADT stack.
25
isEmpty
peek
push
pop
Review
Which of the following is an operation of
the ADT list?
26
pop
dequeue
peek
remove