IST 13-14

¡Supera tus tareas y exámenes ahora con Quizwiz!

Consider a stack represented by an array and top the instance variable representing the index of the top of the stack; when the stack is empty, the value of top is _________________

-1

In a circular array of 5 elements, the element after the element at index 4 is the element at index _________________ .

0

When deleting an element in the middle of a doubly linked list, how many pointers need to be reset?

2

A node (of a linked list) typically has _________________ .

2 attributes: data and the location of the next node

Consider a stack represented by an array of 5 elements and top the instance variable representing the index of the top of the stack; when the stack is full, the value of top is _________________

4

When inserting an element in the middle of a doubly linked list, how many pointers need to be reset?

4

When using an identifier, for example T, to represent a class that uses generics, what characters surround that identifier?

< and >

A queue uses _________________ .

FIFO

TorF: A queue is never empty

False

TorF: A stack is never empty

False

TorF: All things being equal, recursive solutions are faster than their iterative equivalents.

False

TorF: Assuming the number of items is an instance variable of a linked list class, it is good practice to provide a mutator for it.

False

TorF: Data stored in a linked list must be of the primitive data types.

False

TorF: In a queue represented by a linked list, we delete, or dequeue, at the end of the list

False

TorF: In a queue represented by a linked list, we delete, or dequeue, based on the value of the item stored in a node

False

TorF: In a queue represented by a linked list, we insert, or enqueue, at the beginning of the list

False

TorF: In a sorted linked list, it is possible that the linked list may not be sorted after a deletion.

False

TorF: In a sorted linked list, we always insert in the middle of the list.

False

TorF: In a stack represented by a linked list, we delete, or pop, at the end of the list

False

TorF: It is good practice to provide an accessor to the head of a linked list.

False

TorF: Recursive methods never have return values.

False

TorF: Using recursion, the size of a problem is always reduced by 1, i.e. from n to n - 1.

False

TorF: Using recursion, we can only have one base case.

False

TorF: We can only have a sorted linked list of basic data types.

False

TorF: We cannot use recursion in linked lists.

False

TorF: When a base case is reached, only one more recursive call is required.

False

TorF: When we delete the first node in a list, we always set head to null.

False

Which exception will you receive if you have an "infinite" recursion (i.e., one where the base case is never encountered)?

StackOverflowError

TorF: If we know in advance the maximum number of items we will ever have in a queue, then we can use an array to represent the queue.

True

TorF: If we know in advance the maximum number of items we will ever have in a stack, then we can use an array to represent the stack.

True

TorF: In a sorted linked list, we insert in such a way that the list is still sorted after the insertion.

True

TorF: In a stack represented by a linked list, we insert, or push, at the beginning of the list

True

TorF: In an empty list, head is null

True

TorF: It is possible that a method does nothing in the base case.

True

TorF: Some problems are more easily solved using recursion than iteration.

True

TorF: The base case should be the easiest instance of the problem to solve.

True

TorF: The main difficulty in recursive solutions in the problem-solving before the implementation.

True

TorF: Typically, recursion uses selection and iteration uses looping

True

TorF: Unless we run out of memory, we can always insert in a linked list.

True

TorF: Usually, not coding the base case will result in a runtime exception due to the infinite number of recursive calls.

True

TorF: When we attempt to delete an item in a list, it is possible that we do not find that item in the list, in which case we cannot delete it.

True

TorF: When we successfully delete an item from a list, the number of items in a list decreases by 1.

True

The idea of recursion is to ______ the size of the problem at each step so that we eventually reach an easy-to-solve problem.

reduce

A recursive algorithm where the same value is always returned is called _________

tail recursive

When testing the delete method of a linked list, what scenarios do we want to test?

Attempt to delete an item not in the list, Delete the first item in the list, Delete an item in the middle of a list

A linked list _________________ .

Can grow and shrink as items are added or deleted

When testing the insert method of a linked list (one that inserts at the beginning of the list), what scenarios do we want to test?

Insert in an empty list and a non-empty list

Consider a queue represented by an array of 10 elements and front and back the two instance variables representing the indexes of the front and the back of the queue, respectively. If the value of front is 0 and the value of back is 9, what can you tell about the queue?

It is either empty or full

Consider a queue represented by an array of 10 elements and front and back the two instance variables representing the indexes of the front and the back of the queue, respectively. If the value of front is 8 and the value of back is 7, what can you tell about the queue?

It is either empty or full

A stack uses _________________ .

LIFO

When coding a method of a recursively defined linked list, not testing for all base case scenarios could result in a _________________ at runtime.

NullPointerException

TorF: Assuming a linked list is properly coded, attempting to delete from an empty list should not result in a NullPointerException

True

TorF: A doubly linked list allows us to go either forward or backwards from a given node.

True

TorF: A recursive method can be a value-returning method.

True

Binary search (recursive or iterative) applies to _________________ .

a sorted array

That easy-to-solve problem is called the ______ case.

base

When using an array to represent a queue, we should deal with the array as if it were ________

circular

When defining a recursive solution for a problem, we need to do which things

define the base case and the rule for the general case

Visiting each node in a list by following the links is called ______________

traversing


Conjuntos de estudio relacionados

Exam 2 Chapter 13.4 Osteoarthritis

View Set

California Real Estate Chapter 16

View Set

Sociology of Substance Abuse Final

View Set

TAX : Midterm -- Chapter questions and quiz questions

View Set

MS2- EXAM 3- Possible Test Blue Print Questions

View Set

Physical Science Student Bonus Questions

View Set