Filters
Question type

Study Flashcards

A list supports manipulation of items at only the head and tail within a linear collection.

A) True
B) False

Correct Answer

verifed

verified

What is the missing code in the contains method for a Lisp-like list? def contains(item, lyst) : If isEmpty(lyst) : Return False Elif item == first(lyst) : < missing code > Else: Return contains(item, rest(lyst) )


A) return True
B) return contains(item-1)
C) return False
D) return first(lyst)

E) B) and D)
F) B) and C)

Correct Answer

verifed

verified

How do a list iterator and a for loop differ?


A) a list iterator allows movement directly to the last position
B) a for loop allows movement directly to the first position
C) a for loop allows movement to previous positions
D) a list iterator only allows sequential movement through the list

E) None of the above
F) A) and C)

Correct Answer

verifed

verified

The head of a list is at index 1 and the tail is at index n which is the length of the list.

A) True
B) False

Correct Answer

verifed

verified

A Lisp list is a recursive data structure.

A) True
B) False

Correct Answer

verifed

verified

Which of the following is NOT one of the three broad categories of list operations discussed in Chapter 9?


A) index-based
B) content-based
C) position-based
D) hash-based

E) A) and B)
F) None of the above

Correct Answer

verifed

verified

Which of the following is an area of memory from which the Python virtual machine allocates segments of various sizes for all new data objects.


A) call stack
B) virtual memory
C) object heap
D) memory partition

E) B) and C)
F) A) and D)

Correct Answer

verifed

verified

Which of the following list operations is a mutator that works at the currently established position in the list iterator?


A) previous
B) first
C) remove
D) hasPrevious

E) C) and D)
F) B) and C)

Correct Answer

verifed

verified

What is the typical argument to a content-based list operation?


A) an index
B) an item
C) a list instance
D) an array

E) B) and D)
F) A) and B)

Correct Answer

verifed

verified

What is each numeric position in a list called?


A) index
B) pointer
C) tail
D) vector

E) B) and D)
F) None of the above

Correct Answer

verifed

verified

Which of the following is NOT a type of precondition when implementing a list iterator?


A) the next operation cannot be run if hasNext returns False
B) consecutive mutator methods are required
C) a next operation must be run before each mutation
D) mutations cannot be run on the list itself

E) B) and C)
F) A) and B)

Correct Answer

verifed

verified

For a linked implementation of a list, a singly linked structure allows movement to the next node or the previous node.

A) True
B) False

Correct Answer

verifed

verified

If a list contains the items x y z and the cursor is currently undefined, what happens when hasNext() is executed?


A) a value of True is returned
B) a value of False is returned
C) a value of False is returned and the cursor is positioned before the first item
D) a value of True is returned and the cursor is positioned after the last item

E) A) and B)
F) A) and C)

Correct Answer

verifed

verified

The items in a list are logically contiguous, but need not be physically contiguous in memory.

A) True
B) False

Correct Answer

verifed

verified

In the __init__ method for the ArrayListIterator class, what is the missing code? def __init__(self, backingStore) : Self.backingStore = backingStore Self.modCount = backingStore.getModCount() < missing code >


A) self.first()
B) self.last()
C) self.next()
D) self.previous()

E) B) and C)
F) None of the above

Correct Answer

verifed

verified

Where is the cursor positioned when a list iterator is opened on a non-empty list?


A) at the position of the length of the list minus 1
B) immediately after the first item
C) it is undefined
D) immediately before the first item

E) C) and D)
F) A) and B)

Correct Answer

verifed

verified

Which of the following is NOT an example of a list?


A) a recipe
B) a jar of marbles
C) words on a document
D) a file on a disk

E) B) and C)
F) A) and B)

Correct Answer

verifed

verified

List positions are usually counted from 0 to the length of the list plus 1.

A) True
B) False

Correct Answer

verifed

verified

In the following code for the __iter__ method in the ArrayList class, what is the missing code? def __iter__(self) : Cursor = 0 While cursor < len(self) : Yield self.items[cursor] < missing code >


A) self.items[ cursor ] = self.item[ cursor-1 ]
B) cursor += 1
C) cursor -= 1
D) self.items[ cursor+1 ] = self.item[ cursor ]

E) A) and B)
F) None of the above

Correct Answer

verifed

verified

What does the rest function do on a Lisp-like list?


A) returns the list cursor to the head position
B) returns all the data items in the list
C) returns a list of items after the first one
D) returns the list cursor to its previous position

E) None of the above
F) A) and D)

Correct Answer

verifed

verified

Showing 21 - 40 of 50

Related Exams

Show Answer