Data Abstraction and Problem Solving with C++ Walls and Mirrors 7th
Edition Carrano
Full download at: Solution Manual:
https://testbankpack.com/p/solution-manual-for-data-abstraction-and-problem-solving-with-cwalls-and-mirrors-7th-edition-by-carrano-henry-isbn-0134463978-9780134463971/
Test bank:
https://testbankpack.com/p/test-bank-for-data-abstraction-and-problem-solving-with-c-wallsand-mirrors-7th-edition-by-carrano-henry-isbn-0134463978-9780134463971/
Multiple Choice Questions
1. How is the order of the entries of an ADT list determined?
a) by the list itself
b) by the client
c) by the operating system
d) the order doesn’t matter
Answer: B.
2. Which element of the list does not have a unique predecessor?
a) the head of the list
b) the tail of the list
c) the middle element of the list
d) all have unique predecessors
Answer: A.
3. Changing the value of an entry at a given position on the list would probably be the task of which of these methods?
a) replace
b) get
c) push
d) insert
Answer: A.
e) What type would the getLength method for a list return?
f) boolean
g) ItemType
h) integer
i) void
Answer: C
4. Which of the following list methods would have only one parameter?
a) isEmpty
b) setEntry
c) insert
d) remove
Answer: D
5. Which of the following methods from list would have no parameters and void for the return type?
a) setEntry
b) getEntry
c) insert
d) clear
Answer: D.
6. Given bList: snibble, nibble, tribble, wibble, quibble. The command bList.insert(3, Bob) is executed. What is the appearance of the list?
a) snibble, nibble, tribble, Bob, wibble, quibble
b) snibble, nibble, Bob, tribble, wibble, quibble
c) snibble, nibble, tribble, wibble, quibble, Bob, Bob, Bob
d) Bob, Bob, Bob, snibble, nibble, tribble, wibble, quibble
Answer: B.
7. Given bList: bob, slob, snob, cob, hob, rob and the operation bList.remove(4) is executed. What does the list become?
a) bob, slob, snob, hob, rob
b) bob, slob, snob, cob, rob
c) bob, slob
d) hob, rob
Answer: A.
8. Given cList: bip, snip, pip, rip, dip, clip. What value would be returned by the call to method cList.getEntry(3)?
a) bip
b) snip
c) pip
d) rip
Answer: C.
9. Given cList: bip, snip, pip, rip, dip, clip. What value would be returned by the call to method cList.insert(9, sip)?
a) true
b) false
c) it throws an exception
d) sip
Answer: B.
10. What should be returned by the list operation (aList.insert(2,x)).getEntry(2) ?
a) false
b) 2
c) x
d) an exception is thrown
Answer: C.
11. What would be returned by the list operation (bList.insert(3,x)).remove(3)? a) 2
b) x
c) false
d) bList
Answer: D.
12. Consider nameList of size 12. For the operation nameList.insert(Clyde,x), which of the following would be an invalid value for x?
12
© 2017 Pearson Education, Inc., Hoboken, NJ. All rights reserved.
Answer: A
13. Given the commands below, what do they do?
n = 0 for (position = 1 through intList.getLength())
n+= intList.getEntry(position)
a) insert integers into the list
b) sum the values found in list
c) sum the numbers 0 through n
d) calculate n!
Answer: B.
14. Given the commands below, what do they do? for (position = 1 through aList.getLength()/2)
{
a = aList.getEntry(aList.getLength()-position+1)
aList.setEntry(aList.getEntry(aList.getLength()-position+1))
aList.setEntry(a,position)
}
a) randomize the entries
b) sort the entries
c) reverse the order of the entries
d) count how many entries there are
Answer: C.
True/False Questions
1. The ADT list can have an arbitrary length. Answer: True.
2. Insertion at the end of a linear linked list is a special case. Answer: False.
3. Lists contain items of the same type. Answer: True
4. Items in a list may be referenced by number.
Answer: True
5. When you specify the behavior of list operations, always take into consideration how you might implement them.
Answer: False
6. An axiom that describes the behavior of our ADT list is that a newly created list is empty.
Answer: True
7. (newList()).isEmpty()
Answer: True
8. The task of displaying all the items in a list is not an ADT list operation.
Answer: True
9. In the ADT list, each entry in the list is identified by its position which is an integer beginning with 0.
Answer: False
10. Inserting a new entry into a list renumbers any existing entries that follow the new one in the list.
Answer: True
Short Answer Questions
1. What two characteristics are important for the entries in an ADT list? Answer: The entries have position and they are ordered
2. Describe what happens when we insert a new item into the middle of the list. Answer: All items that had position numbers greater or equal to the position to which we insert it must have their position numbers increased by 1 after the insertion. In effect they must be shifted one step higher in the list.
3. Give the definition of the ADT List
Answer: A finite number of objects, not necessarily distinct, having the same data type and ordered by their positions as determined by the client.
4. What is needed besides a set of axioms in order to define the behavior of an ADT’s operations completely? Answer: a set of preconditions and post conditions.
5. What would we expect this for loop to do? for (position = 1 through aList.getLength())
{
}
dataItem = aList.getEntry(position) print(dataItem)
Answer: display all the items of the list
6. What is the range of entry numbers for which it is legal to insert a new entry? Answer: from 1 through 1 greater than the current size of the list.
7. When an entry is removed from a list, what is an additional consequence of that removal? Answer: any existing entries that follow the deleted one are renumbered.