Programming Concepts chapter 4 (book 2)

Lakukan tugas rumah & ujian kamu dengan baik sekarang menggunakan Quizwiz!

In the array class defined in chapter 4, how do you instantiate an array object that can hold 10 values? A. Array(10)myArray B. myArray = Array(10) C. myArray(10) = Array D. Array myArray, 10

B

In the following code to insert in an array, what is the missing code? for x in range(logicalSize, targetIndex, -1): myArray[x] = myArray[x - 1] a[targetIndex] = newItem <missing code> A. targetIndex -= 1 B. logicalSize += 1 C. targetIndex += 1 D. logicalSize -= 1

B

Older programming languages implement arrays as static data structures which are inefficient. What do modern languages use to remedy the problems of static arrays? A. Data stacks B. Dynamic arrays C. Hash tables D. Linked lists

B

Which of the following is an advantage of a doubly linked structure over a singly linked structure? A. It uses less memory B. You can easily access the predecessor of an item C. You can easily access the successor of an item D. It is less complex to import

B

When an array is instantiated, it is filled with zeros by default. True or false?

False

If the logical size of an array equals the physical size of the array, a new array must be created to add elements to the array. True or false?

True

In a doubly linked structure, the first and last item have an empty link. True or false?

True

Inserting data at the beginning of a linked structure uses constant time and memory. True or false?

True

On a linked structure, index-based operations must be emulated by manipulating links within the structure. True or false?

True

The first item in a singly linked structure is accessed using a head link. True or false?

True

What action does the following code perform assuming the Node class defined in Chapter 4? head = Node(newItem, head) A. Insertion of an item at the beginning of a linked list B. Appending an item to the end of a linked list C. Deletion of an item in a linked list D. Replacing an item at the beginning of a linked list

A

What are almost all operations on arrays based upon? A. Indexes B. Hashes C. Links D. Keys

A

What is the primary implementing structure of python's collections? A. Array B. Linked list C. Dictionary D. List

A

What type of memory scheme does a linked list use? A. Noncontiguous B. Overlapping C. Sequential D. Random

A

Which of the following is true about Python's array module? A. It is limited to storing numbers B. It behaves much like a dictionary C. You can define its size at run time D. It can only hold character values

A

Why are the insertion and removal of the first node special cases of the insert and remove ith node on singly linked structures? A. The head pointer must be reset B. The last item must be deleted C. The first item must be deleted D. The tail pointer must be reset

A

How does a programmer access the first item in a singly linked structure? A. By using the 0 index B. By following a head link C. With the first() method D. By a call to getLink(1)

B

How does the class definition of a doubly linked structure differ from a singly linked structure? A. By adding another head pointer B. By adding a previous pointer C. By adding an extra data field D. By removing the talk pointer

B

The following code sums all the values in the two-dimensional array. What is the missing code? sum = 0 for row in range(grid.getHeight()): for column in range(grid.getWidth()): <missing code> A. sum += grid[column + 1][row + 1] B. sum += grid[row][column] C. sum += grid[row - 1][column - 1] D. sum += grid[column][row]

B

What method does Python's list type use to increase the size of the underlying array? A. Augment B. Append C. Increase D. Size

B

Which statement tests if a singly linked node variable named myItem has been initialized? A. if myItem = None: B. if myItem != None: C. if myItem is not Null: D. if myItem is Null:

B

On average, what is the performance of a sequential search on a singly linked structure? A. Exponential B. Logarithmic C. Linear D. Random

C

What is the operation on a linked structure called that visits each node without deleting it? A. Probe B. Removal C. Traversal D. Insertion

C

What type of linked structure operation is the following code performing? z = 0 probe = head while probe != None: z = probe.data + z probe = probe.next A. Insertion B. Visit with removal C. Traversal D. Initialization

C

Which of the following statements accesses the second column in the third row of a two-dimensional array? A. twoDim[2][3] B. twoDim[4][3] C. twoDim[2][1] D. twoDim[1][2]

C

The following code searches a linked structure. What is the missing code? probe = head while probe != None and targetItem != probe.data: <missing code> if probe != None: print("Target item found!") else: print("Target item not found") A. probe.data = next.data B. probe.next = targetItem.data C. probe.head = probe.next D. probe = probe.next

D

The process for resizing an array named myArray is shown below. What is the missing code? if logicalSize == len(myArray): temp = Array(len(myArray) + 1) for i in range(logicalSize): <missing code> a = temp A. myArray[temp] = myArray[i] B. temp = myArray(len(myArray)) C. myArray[i] = temp[i] D. temp[i] = myArray[i]

D

What does the last item in a singly linked structure contain? A. a link to the previous item B. a method for appending an item C. a link to the first item D. an empty link

D

What process is required to avoid wasting memory if successive calls to the pop method on a list are made? A. Grow the array B. Reset the array C. Delete the array D. Shrink the array

D

What type of operation is the following code performing? probe = head while probe != None and targetItem!= probe.data: probe = probe.next if probe != None: probe.data = newItem return True else: return False A. Insertion B. Deletion C. Sum of all items D. Replacement

D

Which of the following best describes an array? A. A numeric value that points to a position in RAM where data can be found B. A list of values that are indexes to a database C. A collection of data points that represent an object D. A sequence of items that can be accessed at given index positions

D

A linked structure can have items that have a maximum of one link to another item. True or false?

False

A ragged grid has a fixed number of columns and a variable number of rows. True or false?

False

A traversal of a singly linked structure terminates when the temporary variable is equal to the head pointer. True or false?

False

If an array's logical size is greater than zero, the index of the last item in the array is the logical size plus 1. True or false?

False

In Python, a node in a doubly linked structure contains two structures: a data item and a reference to the next node. True or false?

False

It's easier to get to an item's predecessor in a singly linked structure than in a doubly linked structure. True or false?

False

Similar to an array, linked structures support random access. True or false?

False

The list is the primary implementing structure in Python collections. True or false?

False

The operation of removing an item at the end of a linked structure is constant in time and memory. True or false?

False

The run-time complexities of the operations on a doubly linked structure are typically double compared to the corresponding operations on the singly linked structure. True or false?

False

When a list's append method results in memory wasted beyond a threshold, the size of the underlying array is decreased. True or false?

False

A linked structure can be stored in noncontiguous memory. True or false?

True

The insertion and removal of the first node of a singly linked structure require that the head pointer be reset. True or false?

True

Time performance is improved if you double the size of the array when you need to increase its size. True or false?

True

To access a two-dimensional array, you use two subscripts. True or false?

True

To start a traversal of a linked structure, initialize a variable to the structure's head pointer. True or false?

True

When an array object is traversed in a for loop, the object's __iter__ method is called. True or false?

True

When an item is inserted into an array, the logical size of the array increases. True or false?

True


Set pelajaran terkait

Mental Health ........... Evolve Questions

View Set

Adaptive Learning: File Management

View Set

Earth Science - 3A : Section Review Questions - sarahbiblecat

View Set

California Real Estate Principles Chapter 14

View Set

Chapter 10 Beginning and Ending of Speech

View Set

Wiley Lesson Assessments, Wiley Test Bank, Wiley Study Tips, Wiley Vignettes, CFP Mock Exam 1

View Set