Academic Integrity: tutoring, explanations, and feedback — we don’t complete graded work or submit on a student’s behalf.

Data Structures QUESTION 1 An abstract data type is not necessarily a collection

ID: 2247638 • Letter: D

Question

Data Structures

QUESTION 1

An abstract data type is not necessarily a collection.

True

False

1 points   

QUESTION 2

A collection is not necessarily an abstract data type.

True

False

1 points   

QUESTION 3

Entries of a bag can belong to classes related by inheritance.

True

False

1 points   

QUESTION 4

All entries of a bag must have the same data type or a subtype of that data type.

True

False

1 points   

QUESTION 5

By declaring a data type to be a BagInterface, we can replace the bag class with another class that implements the BagInterface.

True

False

1 points   

QUESTION 6

A method can change the state of an object passed to it as an argument.

True

False

1 points   

QUESTION 7

A set is a special kind of bag.

True

False

1 points   

QUESTION 8

A language-independent specification for a group of values and operations on those values is called a/an:

abstract data type

data structure

collection

primitive

1 points   

QUESTION 9

An implementation of an ADT with a programming language is called a/an:

data structure

abstract data type

collection

primitive

1 points   

QUESTION 10

An object that groups other objects and provides services to its clients is called a/an:

collection

abstract data type

data structure

primitive

1 points   

QUESTION 11

Which of the following is not true with regard to bags?

objects are in a specific order

can contain duplicate items

is an abstract data type

is a kind of collection in Java

1 points   

QUESTION 12

Which behavior is not represented in a bag?

reorder the bag

report the number of items in the bag

report if the bag is empty

add an item to the bag

1 points   

QUESTION 13

Why would the add method return false?

when the addition of a new item was not successful

when there was a duplicate of the entry already in the bag

when there was not a duplicate of the entry already in the bag

when addition of a new item was successful

1 points   

QUESTION 14

Which behaviors do not change the contents of a bag?

add()

clear()

remove()

none of the above

1 points   

QUESTION 15

Which behaviors change the contents of a bag?

clear()

remove()

add()

all of the above

1 points   

QUESTION 16

When using abstraction as a design principle you should focus on:

what you want to do with the data

how the data is stored

how the data is manipulated

all of the above

1 points   

QUESTION 17

Which of the following is a special kind of bag that does not allow duplicate entries?

set

collection

extended bag

super bag

1 points   

QUESTION 18

When adding an item to a bag, which of the following statements are true?

You cannot specify the position of the item in the bag.

You can specify the item will be placed as the first in the bag.

You can specify the item will be placed as the last in the bag.

None of the above.

1 points   

QUESTION 19

To accommodate entries of any class, the bag methods use ______ .

a generic type

an inherited type

a sub class

all of the above

1 points   

QUESTION 20

Which behavior(s) change the contents of a bag?

remove()

getCurrentSize()

isEmpty()

getFrequencyOf()

1 points   

QUESTION 21

Which behavior(s) change the contents of a bag?

add()

getFrequencyOf()

contains()

toArray()

1 points   

QUESTION 22

Which behaviors leave the contents of a bag unaltered?

contains()

remove()

clear()

add()

1 points   

QUESTION 23

Which behavior(s) leave the contents of a bag unaltered?

toArray()

getFrequencyOf()

isEmpty()

all of the above

1 points   

QUESTION 24

Which of the following are good reasons to write Java statements that use your bag ADT before the implementation is done?

it helps confirm the design

it helps check the suitability of the specification

it helps check your understanding of the specification

all of the above

1 points   

QUESTION 25

Which of the following would be suitable items to store in a bag?

marbles

coins

student roster

all of the above

1 points   

QUESTION 26

You wish to keep track of the distribution of words in a document, for example, how many times the word apple appears. You store each word in the document in a bag. Why is a bag a potentially good solution?

the order of the words is unimportant

the words in the document are not unique

getFrequencyOf() is a useful behavior for determining the word distribution

all of the above

1 points   

QUESTION 27

For which of the following would a bag implementation be suitable?

a shopping cart

a vending machine

a postage stamp collection

all of the above

1 points   

QUESTION 28

Which behavior is not specified in the bag ADT?

sort()

contains()

clear()

remove()

1 points   

QUESTION 29

Which bag behavior is not useful or relevant for a set?

getFrequencyOf()

add()

remove()

contains()

1 points   

QUESTION 30

Which bag behaviors would need modified when implementing a set?

add()

clear()

contains()

toArray()

abstract data type

data structure

collection

primitive

Explanation / Answer

Question 1:

True, an abstract data type is a user defined data type which possesses certain characteristics of its own like, what type of data it can hold or what operations can be performed on it.

Question 2:

True, all collections are not ADTs say, for example, an array of integers.

Question 3:

True, they can belong to classes related by inheritance.

Question 4:

True. A bag is homogeneous in nature.

Question 5:

True.

Question 6:

True.

Question 7:

True, a bag with unique elements and a number of operations.

Question 8:

Data Structure.

Question 9:

Data Structure.

Question 10:

Abstract data type.

Question 11:

Objects are in specific order is not true with regard to bags.

Question 12:

Reorder the bag is not available for bag ADT.

Question 13:

When the addition of a new item was not successful.

Question 14:

None of the above.

Question 15:

All of the above.

Question 16:

All of the above.

Question 17:

Set is a special kind of bag with unique entries.

Question 18:

You cannot specify the position of the item in the bag.

You can specify the item will be placed as the last in the bag.

Question 19:

A generic type.

Question 20:

remove()

Question 21:

add()

Question 22:

contains()

Question 23:

All of the above.

Question 24:

All of the above.

Question 25:

All of the above.

Question 26:

getFrequencyOf() is a useful behavior for determining the word distribution.

Question 27:

All of the above.

Question 28:

sort() is not specified in bag ADT.

Question 29:

getFrequencyOf(), because in a set, an element occurs only once.

Question 30:

add() would need to be modified when implementing a set because we have to check if the new item is already present or not.