Deck 9: Lists

ملء الشاشة (f)
exit full mode
سؤال
The items in a list are logically contiguous, but need not be physically contiguous in memory.
استخدم زر المسافة أو
up arrow
down arrow
لقلب البطاقة.
سؤال
Items in a list must be sorted to make sense.
سؤال
For a linked implementation of a list, a singly linked structure allows movement to the next node or the previous node.
سؤال
There are two broad categories of list operations discussed in most textbooks on data structures: index-based and content-based.
سؤال
A traversal with a list iterator begins by moving the cursor to the first position or to the last position.
سؤال
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.
سؤال
In the array implementation of a list, the index-based operation __getitem__ uses the subscript operator on the array variable.
سؤال
List positions are usually counted from 0 to the length of the list plus 1.
سؤال
Unlike a simple iterator, a list iterator supports movement to previous positions, directly to the first position, and directly to the last position.
سؤال
A disk's surface is divided into concentric tracks, and each track is further subdivided into sectors.
سؤال
The sentinel node points to the first data node and the last data node.
سؤال
The __init__ method of a doubly linked list creates a node with no data.
سؤال
Linked implementations of lists use physical positions in an array to represent logical order.
سؤال
A list is a concrete data structure with a specific and unvarying implementation based on a single block of physical memory.
سؤال
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.
سؤال
The list method remove(item) is an example of a content-based operation.
سؤال
The head of a list is at index 1 and the tail is at index n which is the length of the list.
سؤال
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.
سؤال
The basic building block of a doubly linked structure is a node with two pointers: head, which points left; and tail, which points right.
سؤال
A list supports manipulation of items at only the head and tail within a linear collection.
سؤال
A Lisp list is a recursive data structure.
سؤال
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
سؤال
What is the typical argument to a content-based list operation?

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

A) index
B) pointer
C) tail
D) vector
سؤال
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
سؤال
Recursive list processing became one of the building blocks of a movement in software development called abstract programming.
سؤال
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
سؤال
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
سؤال
The index-based function get returns the i th element of a given list.
سؤال
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
سؤال
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
سؤال
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
سؤال
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
سؤال
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
سؤال
A list iterator is an object attached to a list that provides positional operations on that list.
سؤال
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
سؤال
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
سؤال
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
سؤال
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
سؤال
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.
سؤال
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
سؤال
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
سؤال
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
سؤال
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
سؤال
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 ]
سؤال
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()
سؤال
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)
سؤال
What is the extra node needed to easily manipulate a doubly linked structure?

A) mid
B) next
C) tail
D) sentinel
سؤال
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
سؤال
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 Deck
1/50
auto play flashcards
العب
simple tutorial
ملء الشاشة (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.
فتح الحزمة
افتح القفل للوصول البطاقات البالغ عددها 50 في هذه المجموعة.
فتح الحزمة
k this deck
5
A traversal with a list iterator begins by moving the cursor to the first position or to the last position.
فتح الحزمة
افتح القفل للوصول البطاقات البالغ عددها 50 في هذه المجموعة.
فتح الحزمة
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.
فتح الحزمة
افتح القفل للوصول البطاقات البالغ عددها 50 في هذه المجموعة.
فتح الحزمة
k this deck
7
In the array implementation of a list, the index-based operation __getitem__ uses the subscript operator on the array variable.
فتح الحزمة
افتح القفل للوصول البطاقات البالغ عددها 50 في هذه المجموعة.
فتح الحزمة
k this deck
8
List positions are usually counted from 0 to the length of the list plus 1.
فتح الحزمة
افتح القفل للوصول البطاقات البالغ عددها 50 في هذه المجموعة.
فتح الحزمة
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.
فتح الحزمة
افتح القفل للوصول البطاقات البالغ عددها 50 في هذه المجموعة.
فتح الحزمة
k this deck
10
A disk's surface is divided into concentric tracks, and each track is further subdivided into sectors.
فتح الحزمة
افتح القفل للوصول البطاقات البالغ عددها 50 في هذه المجموعة.
فتح الحزمة
k this deck
11
The sentinel node points to the first data node and the last data node.
فتح الحزمة
افتح القفل للوصول البطاقات البالغ عددها 50 في هذه المجموعة.
فتح الحزمة
k this deck
12
The __init__ method of a doubly linked list creates a node with no data.
فتح الحزمة
افتح القفل للوصول البطاقات البالغ عددها 50 في هذه المجموعة.
فتح الحزمة
k this deck
13
Linked implementations of lists use physical positions in an array to represent logical order.
فتح الحزمة
افتح القفل للوصول البطاقات البالغ عددها 50 في هذه المجموعة.
فتح الحزمة
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.
فتح الحزمة
افتح القفل للوصول البطاقات البالغ عددها 50 في هذه المجموعة.
فتح الحزمة
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.
فتح الحزمة
افتح القفل للوصول البطاقات البالغ عددها 50 في هذه المجموعة.
فتح الحزمة
k this deck
16
The list method remove(item) is an example of a content-based operation.
فتح الحزمة
افتح القفل للوصول البطاقات البالغ عددها 50 في هذه المجموعة.
فتح الحزمة
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.
فتح الحزمة
افتح القفل للوصول البطاقات البالغ عددها 50 في هذه المجموعة.
فتح الحزمة
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.
فتح الحزمة
افتح القفل للوصول البطاقات البالغ عددها 50 في هذه المجموعة.
فتح الحزمة
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.
فتح الحزمة
افتح القفل للوصول البطاقات البالغ عددها 50 في هذه المجموعة.
فتح الحزمة
k this deck
20
A list supports manipulation of items at only the head and tail within a linear collection.
فتح الحزمة
افتح القفل للوصول البطاقات البالغ عددها 50 في هذه المجموعة.
فتح الحزمة
k this deck
21
A Lisp list is a recursive data structure.
فتح الحزمة
افتح القفل للوصول البطاقات البالغ عددها 50 في هذه المجموعة.
فتح الحزمة
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
فتح الحزمة
افتح القفل للوصول البطاقات البالغ عددها 50 في هذه المجموعة.
فتح الحزمة
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
فتح الحزمة
افتح القفل للوصول البطاقات البالغ عددها 50 في هذه المجموعة.
فتح الحزمة
k this deck
24
What is each numeric position in a list called?

A) index
B) pointer
C) tail
D) vector
فتح الحزمة
افتح القفل للوصول البطاقات البالغ عددها 50 في هذه المجموعة.
فتح الحزمة
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
فتح الحزمة
افتح القفل للوصول البطاقات البالغ عددها 50 في هذه المجموعة.
فتح الحزمة
k this deck
26
Recursive list processing became one of the building blocks of a movement in software development called abstract programming.
فتح الحزمة
افتح القفل للوصول البطاقات البالغ عددها 50 في هذه المجموعة.
فتح الحزمة
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
فتح الحزمة
افتح القفل للوصول البطاقات البالغ عددها 50 في هذه المجموعة.
فتح الحزمة
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
فتح الحزمة
افتح القفل للوصول البطاقات البالغ عددها 50 في هذه المجموعة.
فتح الحزمة
k this deck
29
The index-based function get returns the i th element of a given list.
فتح الحزمة
افتح القفل للوصول البطاقات البالغ عددها 50 في هذه المجموعة.
فتح الحزمة
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
فتح الحزمة
افتح القفل للوصول البطاقات البالغ عددها 50 في هذه المجموعة.
فتح الحزمة
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
فتح الحزمة
افتح القفل للوصول البطاقات البالغ عددها 50 في هذه المجموعة.
فتح الحزمة
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
فتح الحزمة
افتح القفل للوصول البطاقات البالغ عددها 50 في هذه المجموعة.
فتح الحزمة
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
فتح الحزمة
افتح القفل للوصول البطاقات البالغ عددها 50 في هذه المجموعة.
فتح الحزمة
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
فتح الحزمة
افتح القفل للوصول البطاقات البالغ عددها 50 في هذه المجموعة.
فتح الحزمة
k this deck
35
A list iterator is an object attached to a list that provides positional operations on that list.
فتح الحزمة
افتح القفل للوصول البطاقات البالغ عددها 50 في هذه المجموعة.
فتح الحزمة
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
فتح الحزمة
افتح القفل للوصول البطاقات البالغ عددها 50 في هذه المجموعة.
فتح الحزمة
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
فتح الحزمة
افتح القفل للوصول البطاقات البالغ عددها 50 في هذه المجموعة.
فتح الحزمة
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
فتح الحزمة
افتح القفل للوصول البطاقات البالغ عددها 50 في هذه المجموعة.
فتح الحزمة
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
فتح الحزمة
افتح القفل للوصول البطاقات البالغ عددها 50 في هذه المجموعة.
فتح الحزمة
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.
فتح الحزمة
افتح القفل للوصول البطاقات البالغ عددها 50 في هذه المجموعة.
فتح الحزمة
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
فتح الحزمة
افتح القفل للوصول البطاقات البالغ عددها 50 في هذه المجموعة.
فتح الحزمة
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
فتح الحزمة
افتح القفل للوصول البطاقات البالغ عددها 50 في هذه المجموعة.
فتح الحزمة
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
فتح الحزمة
افتح القفل للوصول البطاقات البالغ عددها 50 في هذه المجموعة.
فتح الحزمة
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
فتح الحزمة
افتح القفل للوصول البطاقات البالغ عددها 50 في هذه المجموعة.
فتح الحزمة
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 ]
فتح الحزمة
افتح القفل للوصول البطاقات البالغ عددها 50 في هذه المجموعة.
فتح الحزمة
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()
فتح الحزمة
افتح القفل للوصول البطاقات البالغ عددها 50 في هذه المجموعة.
فتح الحزمة
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)
فتح الحزمة
افتح القفل للوصول البطاقات البالغ عددها 50 في هذه المجموعة.
فتح الحزمة
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
فتح الحزمة
افتح القفل للوصول البطاقات البالغ عددها 50 في هذه المجموعة.
فتح الحزمة
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
فتح الحزمة
افتح القفل للوصول البطاقات البالغ عددها 50 في هذه المجموعة.
فتح الحزمة
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
فتح الحزمة
افتح القفل للوصول البطاقات البالغ عددها 50 في هذه المجموعة.
فتح الحزمة
k this deck
locked card icon
فتح الحزمة
افتح القفل للوصول البطاقات البالغ عددها 50 في هذه المجموعة.