Answered step by step
Verified Expert Solution
Link Copied!

Question

1 Approved Answer

Please help me on all the questions !!!!!!!! Really need help! Will give a thumb up for helping. True/False (11) Chapter 12 - Lists The

Please help me on all the questions !!!!!!!! Really need help! Will give a thumb up for helping.

True/False (11)

Chapter 12 - Lists

  1. The ADT list only works for entries that are strings.

  2. The ADT list is more general than common lists and has entries that are objects of the same

    type.

  3. Adding entries to the end of a list does not change the positions of entries already in the list.

  4. The first entry is a list is at position 0.

  5. The entries of a list are numbered from 0 to n.

  6. When a programmer implements an ADT list, clients can use the ADTs operations in a program

    without knowing how the programmer implemented the list to be able to use it.

  7. The Java Class Library contains an implementation of the ADT list that uses a resizable array

    instead of a linked chain.

  8. The Java Class Library implementation of the interface list return null when an index is out of

    range.

  9. A list is an object whose data consists of unordered entries.

  10. Each entry is a list ADT is uniquely identified by its position within the list.

  11. You may replace an entry at any given position in a list.

Short Answer (7)

  1. If myList is a declared ADT list and the front of the list is on the left, show the contents of the list after applying the following pseudo code?

    myList.add(Tom) myList.add(Hank) myList.add(3, Ryan) myList.add(1, Sally) myList.add(Helen)

  2. If myList is a declared ADT list and the front of the list is on the left, show the contents of the list after applying the following pseudo code?

    myList.add(Tom) myList.add(1, Hank) myList.add(2, Ryan) myList.add(Sally) myList.add(3, Helen)

  1. Make a case for the designer of an interface to determine what behavior is appropriate when a collection such as a list is empty.

  2. If myList is a declared ADT list and the front of the list is on the left, show the contents of the list after applying the following pseudo code?

    myList.add(horse) myList.add(goat) myList.add(1, fish) myList.add(cat) myList.remove(1) myList.add(2, dog)

  3. If myList is a declared ADT list and the front of the list is on the left, show the contents of the list after applying the following pseudo code?

    myList.add(horse) myList.add(goat) myList.add(1, fish) myList.add(cat) myList.remove(2) myList.add(3, dog) myList.replace(2, frog)

  4. Given treeList is a declared ADT list that is initially empty, write a serious of list operations to generate the following list step by step.

    a. maple b. maple, oak c. maple, elm, oak d. palm, elm, oak

  5. Given treeList is a declared ADT list that is initially empty, write a serious of list operations to generate the following list step by step.

    1. maple

    2. oak, maple

    3. oak, elm, maple

    4. elm, maple

Multiple Choice (17)

1. In the ADT list, new entries are typically added

  1. at the end of the list

  2. at the beginning of the list in the list

  3. at a computed place in the list depending on the number of elements

  1. You can add a new entry in a list

    1. at the beginning

    2. at the end

    3. in between items

    4. all of the above

  2. If myList is a declared ADT list and the front of the list is on the left, what does the list look like after applying the following pseudo code?

    myList.add(cat) myList.add(dog) mylist.add(fish)

    1. cat, dog, fish

    2. fish, dog, cat

    3. cat, fish, dog

    4. dog, fish, cat

  3. If myList is a declared ADT list and the front of the list is on the left, what does the list look like after applying the following pseudo code?

    myList.add(horse) myList.add(goat) myList.add(3, fish) myList.add(1, dog) myList.add(cat)

    a. dog, horse, goat, fish, cat b. horse, goat, fish, dog, cat c. cat, horse, goat, fish, dog d. cat, fish, goat, dog, horse

  4. Given an ADT list called myList that contains 4 items entries in it, which statement will remove

the first item on the list?

a. myList.remove(1) b. myList.remove() c. myList.removeFront() d. myList.removeFirst()

6. Given an ADT list called myList that contains 4 items entries in it, which statement will add a new item called x on the front of the list?

  1. myList.add(1, x)

  2. myList.add(x)

  3. myList.addFirst(x)

  4. myList.addFront(x)

  1. Which method is not meaningful for use on an empty list?

    1. remove

    2. replace

    3. getEntry

    4. all of the above

  2. Which method is well behaved when the given position is valid for the current list? a. add

    b. remove c. replace d. all of the above

  3. In the interface ListInterface, the method public void add(T newEntry);

    describes which of the following behaviors? a. adds a new entry to the end of the list b. increases the list size by 1 c. does not affect any other entries on the list d. all of the above

  4. In the interface ListInterface, the method public void add(int newPosition, T newEntry);

    describes which of the following behaviors? a. adds a new entry at the specified position in the list b. increases the list size by 1 c. moves entries originally at or above the specified position one position higher d. all of the above

  5. In the interface ListInterface, the method public void remove(int givenPosition);

    describes which of the following behaviors?

    1. remove the entry at a given position from the list

    2. increases the list size by 1

    3. does not affect any other entries on the list

    4. all of the above

  6. If myList is a declared ADT list and the front of the list is on the left, what does the method getEntry(3) return after applying the following pseudo code?

    myList.add(horse) myList.add(goat) myList.add(3, fish)

myList.add(1, dog)

myList.add(cat)

  1. goat

  2. fish

  3. cat

  4. horse

  1. If myList is a declared ADT list and the front of the list is on the left, what does the method getEntry(3) return after applying the following pseudo code?

    myList.add(horse) myList.add(goat) myList.add(1, fish) myList.add(cat) myList.add(2, dog) myList.remove(4)

    1. horse

    2. goat

    3. dog

    4. cat

  2. If myList is a declared ADT list and the front of the list is on the left, what does the method getEntry(4) return after applying the following pseudo code?

    myList.add(horse) myList.add(goat) myList.add(1, fish) myList.add(cat) myList.remove(1) myList.add(2, dog)

    1. cat

    2. dog

    3. goat

    4. fish

  3. The public ArrayList() constructor in the Java Class Library ArrayList creates an empty list with an initial capacity of

    a. 10 b. 0 c. 100 d. 1

16. What does the Java Class Library implementation of the interface list do when an index is out of range.

  1. throw an exception

  2. return null

  3. return false

  4. crash the program

17. If myList is a declared ADT list and the front of the list is on the left, what does the method getEntry(3) return after applying the following pseudo code?

myList.add(horse) myList.add(goat) myList.add(1, fish) myList.replace(3, sheep) myList.add(cat) myList.remove(1) myList.add(2, dog)

  1. sheep

  2. dog

  3. horse

  4. cat

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

Modern Database Management

Authors: Fred R. McFadden, Jeffrey Slater, Mary B. Prescott

5th Edition

0805360549, 978-0805360547

Students also viewed these Databases questions