1. Engineering
  2. Computer Science
  3. please help me on all the questions really need...

Question: please help me on all the questions really need...

Question details

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

True/False (11)

Chapter 13 - A List Implementation That Uses an Array

  1. The ADT list specifies the order of the entries.

  2. In the makeRoom method of the array-based implementation of the ADT list, it is possible that

    no items will be shifted.

  3. In an array-based implementation of the ADT list, the makeRoom method does the most work

    when newPosition is n.

  4. When you use an array to implement the ADT list, retrieving an entry at a given position is slow.

  5. When you use an array to implement the ADT list, adding an entry at a the end of the list is fast.

  6. When you use a vector to implement the ADT list, retrieving an entry at a given position is slow.

  7. When you use a vector to implement the ADT list, adding an entry at a the end of the list is fast.

  8. In an array-based implementation of the ADT list, entries must be ordered alphabetically.

  9. In an array-based implementation of the ADT list, entries must be ordered numerically.

  10. Methods in a vector based implementation of the ADT list are functionally similar to methods in

    an array based implementation of the ADT list.

  11. Methods in a vector based implementation of the ADT list have different specifications than

    methods in an array based implementation of the ADT list.

Short Answer (7)

  1. If colorList is an array-based ADT list and the front of the list is on the left, show the contents of the list after applying the following code?

    colorList.add(“red”) colorList.add(“purple”) colorList.add(“green”) colorList.add(3, “yellow”)
    my colorList List.add(1, “black”) colorList.add(4, “blue”)

  2. If colorList is an array-based ADT list and the front of the list is on the left, show the contents of the list after applying the following code?

    colorList.add(“red”) colorList.add(1, “purple”) colorList.add(1, “green”) colorList.add(1, “yellow”)

my colorList List.add(1, “black”) colorList.add(“blue”)

  1. If colorList is an array-based ADT list and the front of the list is on the left, show the contents of the list after applying the following code?

    colorList.add(“red”) colorList.add(2, “purple”) colorList.add(2, “green”) colorList.add(2, “yellow”)
    my colorList List.add(2, “black”) colorList.add(2, “blue”)

  2. Given the following array-based ADT list called colorList whose elements contain strings red, orange, yellow, blue, indigo, violet

    write the statement to insert the String element “pink” to the end of the list. Assume the front of the list is on the left.

  3. Given the following array-based ADT list called colorList whose elements contain strings red, orange, yellow, blue, indigo, violet

    write the statement to insert the String element “white” to the beginning of the list. Assume the front of the list is on the left.

  4. Given the following array-based ADT list called colorList whose elements contain strings red, orange, yellow, blue, indigo, violet

    write the statement to insert the String element “green” between “yellow” and “blue”. Assume the front of the list is on the left.

  5. Given the following array-based ADT list called colorList whose elements contain strings red, orange, yellow, blue, indigo, violet

    write the statement to take the String element “blue” out of the list. Assume the front of the list is on the left.

Multiple Choice (27)

1. A new entry is added to an array-based implementation of the ADT list

  1. immediately after the last occupied position

  2. immediately before the first occupied position

  3. in the last array position

  4. in the location returned by the new operator

2. When
a. no shift is necessary

adding an entry to an array-based implementation of the ADT list at the end of the list

  1. all of the previous elements must be shifted toward the front of the array

  2. only one element is shifted toward the end of the array to make room

  3. only one element is shifted toward the beginning of the array to make room

adding an entry to an array-based implementation of the ADT list at a specified location

3. When
before the end of the list

a. b. c. d.

4. In the a. b. c. d.

entries must be shifted to vacate a position for the new item
no shift is necessary
a new entry must be allocated and linked to attach the new item
the entry at the specified location will be overwritten by the new item

makeRoom method of an array-based implementation of the ADT list
entries are shifted toward the end of the array beginning with the last entry entries are shifted toward the beginning of the array beginning with the last entry entries are shifted toward the beginning of the array beginning with the first entry entries are shifted toward the end of the array beginning with the first entry

makeRoom method of an array-based implementation of the ADT list no shift is necessary

5. In the
if a new entry is to be placed at

a. b. c. d.

6. In the a. b. c. d.

numberOfEntries + 1 numberOfEntries – 1 numberOfEntries none of the above

array-based implementation of the ADT list, the removeGap method moves each entry to its next lower position
moves each entry to its next higher position
swaps the first entry with the specified entry to remove

swaps the last entry with the specified entry to remove

  1. When deleting an entry from an array-based implementation of the ADT list at the end of the list a. no shift is necessary

    b. all of the previous elements must be shifted toward the front of the array
    c. only one element is shifted toward the end of the array to close the gap
    d. only one element is shifted toward the beginning of the array to close the gap

  2. In an array-based implementation of the ADT list, what is the performance of adding an entry at

the end of the list when the array is not resized?

  1. O(1)

  2. O(log n)

  3. O(n)

  4. O(n2)

9. In an array-based implementation of the ADT list, what is the performance of adding an entry at the end of the list when the array is resized?

  1. O(n)

  2. O(n2)

  3. O(log n)

  4. O(1)

10. In an array-based implementation of the ADT list, what is the performance of adding an entry at the end of the list if you amortize the cost of resizing the array over all additions to the list?

  1. O(1)

  2. O(log n)

  3. O(n)

  4. O(n2)

  1. In an array-based implementation of the ADT list, the getEntry method locates the entry by

    1. going directly to the appropriate array element

    2. searching for the entry starting at the beginning of the array working to the end

    3. searching for the entry starting at the end of the array working to the beginning

    4. none of the above

  2. In an array-based implementation of the ADT list, the contains method locates the entry by

    1. searching for the entry starting at the beginning of the array working to the end

    2. searching for the entry starting at the end of the array working to the beginning

    3. going directly to the appropriate array element

    4. none of the above

  3. In an array-based implementation of the ADT list, the makeRoom method does the most work when

a. newPosition is 1

  1. newPosition is n

  2. newPosition is n/2

  3. newPosition is n-1

  1. In an array-based implementation of the ADT list, what is the best case performance of the makeRoom method?

    1. O(1)

    2. O(log n)

    3. O(n)

    4. O(n2)

  2. In an array-based implementation of the ADT list, what is the worst case performance of the makeRoom method?

    1. O(n)

    2. O(n2)

    3. O(log n)

    4. O(1)

  3. In an array-based implementation of the ADT list, what is the best case performance of the ensureCapacity method?

    1. O(1)

    2. O(log n)

    3. O(n)

    4. O(n2)

  4. In an array-based implementation of the ADT list, what is the worst case performance of the ensureCapacity method?

    1. O(n)

    2. O(n2)

    3. O(log n)

    4. O(1)

  5. In an array-based implementation of the ADT list, what is the best case performance of the remove method?

    a. O(1)
    b. O(log n) c. O(n)
    d. O(n2)

  1. In an array-based implementation of the ADT list, what is the worst case performance of the remove method?

    a. O(n)
    b. O(n2)
    c. O(log n) d. O(1)

  2. In an array-based implementation of the ADT list, what is the best case performance of the replace method?

    1. O(1)

    2. O(log n)

    3. O(n)

    4. O(n2)

  3. In an array-based implementation of the ADT list, what is the worst case performance of the replace method?

    1. O(1)

    2. O(log n)

    3. O(n)

    4. O(n2)

  4. In an array-based implementation of the ADT list, what is the best case performance of the getEntry?

    1. O(1)

    2. O(log n)

    3. O(n)

    4. O(n2)

  5. In an array-based implementation of the ADT list, what is the worst case performance of the getEntry method?

    1. O(1)

    2. O(log n)

    3. O(n)

    4. O(n2)

  6. In an array-based implementation of the ADT list, what is the best case performance of the contains method?

    1. O(1)

    2. O(log n)

    3. O(n)

    4. O(n2)

25. In an array-based implementation of the ADT list, what is the worst case performance of the contains method?

  1. O(n)

  2. O(n2)

  3. O(log n)

  4. O(1)

26. In an array-based implementation of the ADT list, what is the performance of the contains method when the entry is not in the list?

  1. O(n)

  2. O(n2)

  3. O(log n)

  4. O(1)

27. An array provides _______ access to its elements.

  1. direct

  2. random

  3. sequential

  4. none of the above

Solution by an expert tutor
Blurred Solution
This question has been solved
Subscribe to see this solution