270 likes | 539 Views
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.
E N D
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 • A reference variable whose sole purpose is to locate the first node in a linked list is called ______. • top • front • head • first
Review • A reference variable declared as a data field within a class has the default value ______. • 0 • -1 • null • empty
Review • If you attempt to use a reference variable before it is instantiated, a(n) ______ will be thrown. • IndexOutOfBoundsException • InstantiationException • IllegalAccessException • NullPointerException
Review • According to the principle of information hiding, the data fields of a class must be declared as ______. • public • protected • private • abstract
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
Review • A reference variable whose sole purpose is to locate the first node in a linked list is called ______. • top • front • head • first
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
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
Review • If the array:6, 2, 7, 13, 5, 4is 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
Review • The ______ method of the ADT stack adds an item to the top of the stack. • 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? • 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 ______. • 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 ______. • 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 ______. • Integer • Double • String • Object
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
Review • Which of the following ADTs is like a line of people? • list • stack • queue • tree
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
Review • The ______ operation retrieves the item that was added earliest to a queue, but does not remove that item. • enqueue • dequeue • dequeueAll • peek
Review • A reference-based implementation of a queue that uses a linear linked list would need at least ______ external references. • one • two • three • four
Review • Which of the following methods of QueueInterface does NOT throw a QueueException? • 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)? • enqueue() • dequeue() • isEmpty() • peek()
Review • The ADT ______ allows you to insert into, delete from, and inspect the item at any position of the ADT. • stack • queue • List • array
Review • The enqueue operation of the ADT queue is similar to the ______ operation of the ADT stack. • isEmpty • peek • push • pop
Review • Which of the following is an operation of the ADT list? • pop • dequeue • peek • remove