cs2007 - data structures ii

26
CS2007 - Data Structures II Review

Upload: penelope-morrow

Post on 04-Jan-2016

62 views

Category:

Documents


1 download

DESCRIPTION

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. interface reference Method ADT. Review. - PowerPoint PPT Presentation

TRANSCRIPT

Page 1: CS2007 - Data Structures II

CS2007 - Data Structures II

Review

Page 2: CS2007 - Data Structures II

2

Review When you declare a variable that refers to

an object of a given class, you are creating a(n) ______ to the object. interface reference Method ADT

Page 3: CS2007 - Data Structures II

3

Review A reference variable whose sole purpose

is to locate the first node in a linked list is called ______. top front head first

Page 4: CS2007 - Data Structures II

4

Review A reference variable declared as a data

field within a class has the default value ______. 0 -1 null empty

Page 5: CS2007 - Data Structures II

5

Review If you attempt to use a reference variable

before it is instantiated, a(n) ______ will be thrown. IndexOutOfBoundsException InstantiationException IllegalAccessException NullPointerException

Page 6: CS2007 - Data Structures II

6

Review According to the principle of information

hiding, the data fields of a class must be declared as ______. public protected private abstract

Page 7: CS2007 - Data Structures II

7

Review The last node of a linear linked list

______. 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

Page 8: CS2007 - Data Structures II

8

Review A reference variable whose sole purpose

is to locate the first node in a linked list is called ______. top front head first

Page 9: CS2007 - Data Structures II

9

Review An array-based implementation of an ADT

list ______. 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

Page 10: CS2007 - Data Structures II

10

Review In all circular linked lists, ______.

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

Page 11: CS2007 - Data Structures II

11

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? 6 2 5 4

Page 12: CS2007 - Data Structures II

12

Review The ______ method of the ADT stack

adds an item to the top of the stack. createStack push pop peek

Page 13: CS2007 - Data Structures II

13

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? the stack is empty the stack has one “{” the stack has one “}” the stack has one “{” and one “}”

Page 14: CS2007 - Data Structures II

14

Review The pop operation throws a

StackException when it tries to ______. 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

Page 15: CS2007 - Data Structures II

15

Review The push operation throws a

StackException when it tries to ______. 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

Page 16: CS2007 - Data Structures II

16

Review In the StackInterface class, the pop

method returns an item that is an instance of ______. Integer Double String Object

Page 17: CS2007 - Data Structures II

17

Review StackInterface provides the specifications

for ______. 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

Page 18: CS2007 - Data Structures II

18

Review Which of the following ADTs is like a line

of people? list stack queue tree

Page 19: CS2007 - Data Structures II

19

Review 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

Page 20: CS2007 - Data Structures II

20

Review The ______ operation retrieves the item

that was added earliest to a queue, but does not remove that item. enqueue dequeue dequeueAll peek

Page 21: CS2007 - Data Structures II

21

Review A reference-based implementation of a

queue that uses a linear linked list would need at least ______ external references. one two three four

Page 22: CS2007 - Data Structures II

22

Review Which of the following methods of

QueueInterface does NOT throw a QueueException? enqueue dequeue dequeueAll peek

Page 23: CS2007 - Data Structures II

23

Review 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()

Page 24: CS2007 - Data Structures II

24

Review The ADT ______ allows you to insert into,

delete from, and inspect the item at any position of the ADT. stack queue List array

Page 25: CS2007 - Data Structures II

25

Review The enqueue operation of the ADT queue

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

Page 26: CS2007 - Data Structures II

26

Review Which of the following is an operation of

the ADT list? pop dequeue peek remove