Answered step by step
Verified Expert Solution
Link Copied!

Question

1 Approved Answer

11. A collection that remembers the order of items, and allows items to be added and removed only at one end is called a ____.

11. A collection that remembers the order of items, and allows items to be added and removed only at one end is called a ____.

list

stack

set

queue

QUESTION 12

You need to write a program to manage a waiting list of patrons at a restaurant. Which data structure would be most appropriate to model this situation?

map

stack

queue

linked list

QUESTION 13

Assume you have created a linked list name myList that currently holds some number of String objects. Which of the following statements correctly removes an element from the end of myList?

myList.remove();

myList.removeLast();

myList.getLast();

myList.pop();

QUESTION 14

Which nodes need to be updated when we insert a new node to become the fourth node from the beginning of a doubly-linked list?

The current third node.

The current third and fourth nodes.

The current first node.

The current fourth and fifth nodes.

QUESTION 15

Assume that you have declared a map named myMap to hold String elements with Integer keys. Which of the following statements will correctly insert an element into myMap?

myMap.insert(3, "apple");

myMap.put(3, "apple");

myMap.push(3, "apple");

myMap.add(3, "apple");

QUESTION 16

You intend to use a hash set with your own object class. Which of the following statements is NOT correct?

You do not have to do anything additional. You can use the hashCode function of the Object class.

You can create your own function to compute a hashCode value.

You can override the hashCode method in the Object class to provide your own hashCode method.

Your class's hashCode method does not need to be compatible with its equals method.

QUESTION 17

Suppose we create a deque (double-ended queue) data structure. It is basically a queue, with its addLast and removeFirstoperations, but we also add the addFirst and removeLast operations. Which of the following is best modeled by the deque data structure?

A toll booth on a highway.

A cross country race.

A computer keyboard typing buffer.

A Memorial Day parade.

QUESTION 18

Which of the following statements about the LinkedList class is correct?

When you use the add method, the new element is inserted before the iterator, and the iterator position is advanced by one position.

When you use the add method, the new element is inserted after the iterator, and the iterator position is advanced by one position.

When you use the add method, the new element is inserted before the iterator, and the iterator position is not moved

When you use the add method, the new element is inserted after the iterator, and the iterator position is not moved.

QUESTION 19

Rather than storing values in an array, a linked list uses a sequence of ____.

indexes

nodes

elements

accessors

QUESTION 20

Complete the following code snippet, which is intended to determine if a specific value in a variable named targetWordappears in a set of String values named mySet:

for (String aWord : mySet) 
{ 
 _______________________ 
 { 
 System.out.println ("The word " + targetWord + " was found."); 
 } 
) 

if (mySet.equalsIgnoreCase(targetWord))

if (mySet == targetWord)

if (mySet.contains(targetWord))

if (mySet.get(targetWord))

Step by Step Solution

There are 3 Steps involved in it

Step: 1

blur-text-image

Get Instant Access to Expert-Tailored Solutions

See step-by-step solutions with expert insights and AI powered tools for academic success

Step: 2

blur-text-image

Step: 3

blur-text-image

Ace Your Homework with AI

Get the answers you need in no time with our AI-driven, step-by-step assistance

Get Started

Recommended Textbook for

Database Concepts

Authors: David Kroenke, David J. Auer

3rd Edition

0131986252, 978-0131986251

More Books

Students also viewed these Databases questions