Deck 9: Lists

Full screen (f)
exit full mode
Question
The items in a list are logically contiguous, but need not be physically contiguous in memory.
Use Space or
up arrow
down arrow
to flip the card.
Question
Items in a list must be sorted to make sense.
Question
For a linked implementation of a list, a singly linked structure allows movement to the next node or the previous node.
Question
There are two broad categories of list operations discussed in most textbooks on data structures: index-based and content-based.
Question
A traversal with a list iterator begins by moving the cursor to the first position or to the last position.
Question
The object heap is an area of the disk drive from which the Python virtual machine allocates segments of various sizes for all new data objects.
Question
In the array implementation of a list, the index-based operation __getitem__ uses the subscript operator on the array variable.
Question
List positions are usually counted from 0 to the length of the list plus 1.
Question
Unlike a simple iterator, a list iterator supports movement to previous positions, directly to the first position, and directly to the last position.
Question
A disk's surface is divided into concentric tracks, and each track is further subdivided into sectors.
Question
The sentinel node points to the first data node and the last data node.
Question
The __init__ method of a doubly linked list creates a node with no data.
Question
Linked implementations of lists use physical positions in an array to represent logical order.
Question
A list is a concrete data structure with a specific and unvarying implementation based on a single block of physical memory.
Question
Because a list is ordered linearly, you can refer unambiguously to an item in a list via its relative position from the head of the list.
Question
The list method remove(item) is an example of a content-based operation.
Question
The head of a list is at index 1 and the tail is at index n which is the length of the list.
Question
Initially, when a list iterator is opened on a non-empty list, the cursor's position is immediately after the first item in the list.
Question
The basic building block of a doubly linked structure is a node with two pointers: head, which points left; and tail, which points right.
Question
A list supports manipulation of items at only the head and tail within a linear collection.
Question
A Lisp list is a recursive data structure.
Question
How does position-based operations allow the programmer to navigate through a list?

A) by incrementing the head pointer
B) by decrementing the tail pointer
C) by moving the cursor
D) by changing the backing store
Question
What is the typical argument to a content-based list operation?

A) an index
B) an item
C) a list instance
D) an array
Question
What is each numeric position in a list called?

A) index
B) pointer
C) tail
D) vector
Question
What are the values of a list index at the head and tail of the list, respectively?

A) 0, n-1
B) 1, n
C) 0, n
D) n-1, 1
Question
Recursive list processing became one of the building blocks of a movement in software development called abstract programming.
Question
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
Question
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
Question
The index-based function get returns the i th element of a given list.
Question
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
Question
Why can you refer to an item in a list via its relative position from the head of the list using an index?

A) because it has a circular structure
B) because it uses round-robin
C) because it is ordered linearly
D) because it's arranged in a hierarchy
Question
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
Question
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
Question
With respect to memory, what happens when an object is no longer needed?

A) the garbage collector returns the object's space to the free list
B) the disk block is marked as unused
C) the size of the array holding the object is reduced by 1
D) the data block is marked as deleted and is unavailable to other objects
Question
A list iterator is an object attached to a list that provides positional operations on that list.
Question
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
Question
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
Question
What is true about how lists are indexed?

A) indices increase in both movement directions
B) indices decrease to the left and increase to the right
C) indices decrease in both movement directions
D) indices decrease to the right and increase to the left
Question
Which of the following is true about lists?

A) items must be sorted
B) items must be physically contiguous
C) the order of items is unimportant
D) items are logically contiguous
Question
In the implementation of the lister iterator on a doubly linked list, the method hasNext returns False if the cursor is less than the backing store's length.
Question
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
Question
Which of the following is NOT true about a file system's directory?

A) it occupies the first few tracks on the disk
B) it contains an entry for each file
C) each file entry holds the address of the sector containing file data
D) the directory is organized as a linear structure
Question
When the first method is run on the list iterator, what happens?

A) the cursor is reset to 0
B) the list is cleared
C) the cursor is set to -1
D) the list is instantiated
Question
In what type of programming did recursive list processing become an important building block?

A) procedural programming
B) object-oriented programming
C) sequential programming
D) functional programming
Question
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 ]
Question
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()
Question
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)
Question
What is the extra node needed to easily manipulate a doubly linked structure?

A) mid
B) next
C) tail
D) sentinel
Question
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
Question
Which structure is the ideal one to support a list iterator?

A) array
B) circular array
C) doubly linked
D) singly linked
Unlock Deck
Sign up to unlock the cards in this deck!
Unlock Deck
Unlock Deck
1/50
auto play flashcards
Play
simple tutorial
Full screen (f)
exit full mode
Deck 9: Lists
1
The items in a list are logically contiguous, but need not be physically contiguous in memory.
True
2
Items in a list must be sorted to make sense.
False
3
For a linked implementation of a list, a singly linked structure allows movement to the next node or the previous node.
False
4
There are two broad categories of list operations discussed in most textbooks on data structures: index-based and content-based.
Unlock Deck
Unlock for access to all 50 flashcards in this deck.
Unlock Deck
k this deck
5
A traversal with a list iterator begins by moving the cursor to the first position or to the last position.
Unlock Deck
Unlock for access to all 50 flashcards in this deck.
Unlock Deck
k this deck
6
The object heap is an area of the disk drive from which the Python virtual machine allocates segments of various sizes for all new data objects.
Unlock Deck
Unlock for access to all 50 flashcards in this deck.
Unlock Deck
k this deck
7
In the array implementation of a list, the index-based operation __getitem__ uses the subscript operator on the array variable.
Unlock Deck
Unlock for access to all 50 flashcards in this deck.
Unlock Deck
k this deck
8
List positions are usually counted from 0 to the length of the list plus 1.
Unlock Deck
Unlock for access to all 50 flashcards in this deck.
Unlock Deck
k this deck
9
Unlike a simple iterator, a list iterator supports movement to previous positions, directly to the first position, and directly to the last position.
Unlock Deck
Unlock for access to all 50 flashcards in this deck.
Unlock Deck
k this deck
10
A disk's surface is divided into concentric tracks, and each track is further subdivided into sectors.
Unlock Deck
Unlock for access to all 50 flashcards in this deck.
Unlock Deck
k this deck
11
The sentinel node points to the first data node and the last data node.
Unlock Deck
Unlock for access to all 50 flashcards in this deck.
Unlock Deck
k this deck
12
The __init__ method of a doubly linked list creates a node with no data.
Unlock Deck
Unlock for access to all 50 flashcards in this deck.
Unlock Deck
k this deck
13
Linked implementations of lists use physical positions in an array to represent logical order.
Unlock Deck
Unlock for access to all 50 flashcards in this deck.
Unlock Deck
k this deck
14
A list is a concrete data structure with a specific and unvarying implementation based on a single block of physical memory.
Unlock Deck
Unlock for access to all 50 flashcards in this deck.
Unlock Deck
k this deck
15
Because a list is ordered linearly, you can refer unambiguously to an item in a list via its relative position from the head of the list.
Unlock Deck
Unlock for access to all 50 flashcards in this deck.
Unlock Deck
k this deck
16
The list method remove(item) is an example of a content-based operation.
Unlock Deck
Unlock for access to all 50 flashcards in this deck.
Unlock Deck
k this deck
17
The head of a list is at index 1 and the tail is at index n which is the length of the list.
Unlock Deck
Unlock for access to all 50 flashcards in this deck.
Unlock Deck
k this deck
18
Initially, when a list iterator is opened on a non-empty list, the cursor's position is immediately after the first item in the list.
Unlock Deck
Unlock for access to all 50 flashcards in this deck.
Unlock Deck
k this deck
19
The basic building block of a doubly linked structure is a node with two pointers: head, which points left; and tail, which points right.
Unlock Deck
Unlock for access to all 50 flashcards in this deck.
Unlock Deck
k this deck
20
A list supports manipulation of items at only the head and tail within a linear collection.
Unlock Deck
Unlock for access to all 50 flashcards in this deck.
Unlock Deck
k this deck
21
A Lisp list is a recursive data structure.
Unlock Deck
Unlock for access to all 50 flashcards in this deck.
Unlock Deck
k this deck
22
How does position-based operations allow the programmer to navigate through a list?

A) by incrementing the head pointer
B) by decrementing the tail pointer
C) by moving the cursor
D) by changing the backing store
Unlock Deck
Unlock for access to all 50 flashcards in this deck.
Unlock Deck
k this deck
23
What is the typical argument to a content-based list operation?

A) an index
B) an item
C) a list instance
D) an array
Unlock Deck
Unlock for access to all 50 flashcards in this deck.
Unlock Deck
k this deck
24
What is each numeric position in a list called?

A) index
B) pointer
C) tail
D) vector
Unlock Deck
Unlock for access to all 50 flashcards in this deck.
Unlock Deck
k this deck
25
What are the values of a list index at the head and tail of the list, respectively?

A) 0, n-1
B) 1, n
C) 0, n
D) n-1, 1
Unlock Deck
Unlock for access to all 50 flashcards in this deck.
Unlock Deck
k this deck
26
Recursive list processing became one of the building blocks of a movement in software development called abstract programming.
Unlock Deck
Unlock for access to all 50 flashcards in this deck.
Unlock Deck
k this deck
27
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
Unlock Deck
Unlock for access to all 50 flashcards in this deck.
Unlock Deck
k this deck
28
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
Unlock Deck
Unlock for access to all 50 flashcards in this deck.
Unlock Deck
k this deck
29
The index-based function get returns the i th element of a given list.
Unlock Deck
Unlock for access to all 50 flashcards in this deck.
Unlock Deck
k this deck
30
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
Unlock Deck
Unlock for access to all 50 flashcards in this deck.
Unlock Deck
k this deck
31
Why can you refer to an item in a list via its relative position from the head of the list using an index?

A) because it has a circular structure
B) because it uses round-robin
C) because it is ordered linearly
D) because it's arranged in a hierarchy
Unlock Deck
Unlock for access to all 50 flashcards in this deck.
Unlock Deck
k this deck
32
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
Unlock Deck
Unlock for access to all 50 flashcards in this deck.
Unlock Deck
k this deck
33
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
Unlock Deck
Unlock for access to all 50 flashcards in this deck.
Unlock Deck
k this deck
34
With respect to memory, what happens when an object is no longer needed?

A) the garbage collector returns the object's space to the free list
B) the disk block is marked as unused
C) the size of the array holding the object is reduced by 1
D) the data block is marked as deleted and is unavailable to other objects
Unlock Deck
Unlock for access to all 50 flashcards in this deck.
Unlock Deck
k this deck
35
A list iterator is an object attached to a list that provides positional operations on that list.
Unlock Deck
Unlock for access to all 50 flashcards in this deck.
Unlock Deck
k this deck
36
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
Unlock Deck
Unlock for access to all 50 flashcards in this deck.
Unlock Deck
k this deck
37
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
Unlock Deck
Unlock for access to all 50 flashcards in this deck.
Unlock Deck
k this deck
38
What is true about how lists are indexed?

A) indices increase in both movement directions
B) indices decrease to the left and increase to the right
C) indices decrease in both movement directions
D) indices decrease to the right and increase to the left
Unlock Deck
Unlock for access to all 50 flashcards in this deck.
Unlock Deck
k this deck
39
Which of the following is true about lists?

A) items must be sorted
B) items must be physically contiguous
C) the order of items is unimportant
D) items are logically contiguous
Unlock Deck
Unlock for access to all 50 flashcards in this deck.
Unlock Deck
k this deck
40
In the implementation of the lister iterator on a doubly linked list, the method hasNext returns False if the cursor is less than the backing store's length.
Unlock Deck
Unlock for access to all 50 flashcards in this deck.
Unlock Deck
k this deck
41
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
Unlock Deck
Unlock for access to all 50 flashcards in this deck.
Unlock Deck
k this deck
42
Which of the following is NOT true about a file system's directory?

A) it occupies the first few tracks on the disk
B) it contains an entry for each file
C) each file entry holds the address of the sector containing file data
D) the directory is organized as a linear structure
Unlock Deck
Unlock for access to all 50 flashcards in this deck.
Unlock Deck
k this deck
43
When the first method is run on the list iterator, what happens?

A) the cursor is reset to 0
B) the list is cleared
C) the cursor is set to -1
D) the list is instantiated
Unlock Deck
Unlock for access to all 50 flashcards in this deck.
Unlock Deck
k this deck
44
In what type of programming did recursive list processing become an important building block?

A) procedural programming
B) object-oriented programming
C) sequential programming
D) functional programming
Unlock Deck
Unlock for access to all 50 flashcards in this deck.
Unlock Deck
k this deck
45
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 ]
Unlock Deck
Unlock for access to all 50 flashcards in this deck.
Unlock Deck
k this deck
46
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()
Unlock Deck
Unlock for access to all 50 flashcards in this deck.
Unlock Deck
k this deck
47
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)
Unlock Deck
Unlock for access to all 50 flashcards in this deck.
Unlock Deck
k this deck
48
What is the extra node needed to easily manipulate a doubly linked structure?

A) mid
B) next
C) tail
D) sentinel
Unlock Deck
Unlock for access to all 50 flashcards in this deck.
Unlock Deck
k this deck
49
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
Unlock Deck
Unlock for access to all 50 flashcards in this deck.
Unlock Deck
k this deck
50
Which structure is the ideal one to support a list iterator?

A) array
B) circular array
C) doubly linked
D) singly linked
Unlock Deck
Unlock for access to all 50 flashcards in this deck.
Unlock Deck
k this deck
locked card icon
Unlock Deck
Unlock for access to all 50 flashcards in this deck.