1.4 Relation between data structures and algorithms Flashcards

1
Q

What do data structures define?

A

How data is organized and stored, and the operations performed on the data structure.

How well did you know this?
1
Not at all
2
3
4
5
Perfectly
2
Q

What is a common operation for data structures?

A

Inserting, removing, and searching for data.

How well did you know this?
1
Not at all
2
3
4
5
Perfectly
3
Q

True or False: The algorithm to append an item to a linked list is the same as for an array.

A

False

How well did you know this?
1
Not at all
2
3
4
5
Perfectly
4
Q

Fill in the blank: The algorithm to append an item to a linked list points the tail node’s next pointer and the list’s tail pointer to the _______.

A

new node

How well did you know this?
1
Not at all
2
3
4
5
Perfectly
5
Q

What is the first step in the algorithm to append an item to an array?

A

Determine the current size of the array.

How well did you know this?
1
Not at all
2
3
4
5
Perfectly
6
Q

In the ListAppend algorithm, what happens if the list is empty?

A

list⇢head and list⇢tail are set to newNode.

How well did you know this?
1
Not at all
2
3
4
5
Perfectly
7
Q

What does the ArrayAppend algorithm do after increasing the array size?

A

Assigns the new item as the last array element.

How well did you know this?
1
Not at all
2
3
4
5
Perfectly
8
Q

What does the GetCurrentSize function return?

A

The length subitem of the values.

How well did you know this?
1
Not at all
2
3
4
5
Perfectly
9
Q

What is the purpose of the topSales array in the DisplayTopFiveSalespersons algorithm?

A

To store the top five salespersons sorted by their total sales.

How well did you know this?
1
Not at all
2
3
4
5
Perfectly
10
Q

What initial values are assigned to the topSales array elements?

A

All elements are initialized with a negative sales total.

How well did you know this?
1
Not at all
2
3
4
5
Perfectly
11
Q

Which of the following is NOT equal to the number of items in the topSales array?

A

allSalesperson⇢length

How well did you know this?
1
Not at all
2
3
4
5
Perfectly
12
Q

To adapt the algorithm to display the top 10 salespersons, what modifications are required?

A

Both the array creation and all loops.

How well did you know this?
1
Not at all
2
3
4
5
Perfectly
13
Q

True or False: If allSalespersons has length 3, DisplayTopFiveSalespersons() displays five elements.

A

True

How well did you know this?
1
Not at all
2
3
4
5
Perfectly
14
Q

What does the algorithm do when a salesperson’s total sales is greater than the last topSales element?

A

Assigns the last element in topSales with the current salesperson and sorts topSales.

How well did you know this?
1
Not at all
2
3
4
5
Perfectly
15
Q

What is the output of the DisplayTopFiveSalespersons algorithm?

A

The top five salespersons.

How well did you know this?
1
Not at all
2
3
4
5
Perfectly
16
Q

What is the significance of the SortDescending function in the DisplayTopFiveSalespersons algorithm?

A

It sorts topSales in descending order based on total sales.

17
Q

What data structure is used in the algorithm that determines a list of the top five salespersons?

18
Q

What happens to the topSales array if a new salesperson qualifies?

A

The last element is updated, and the array is sorted.

19
Q

Fill in the blank: The algorithm to append an item to an array requires _______ to increase the array size.

A

increasing the array size by one

20
Q

What is the first item accessed in an array?

21
Q

What pointer does the tail node in a linked list point to when a new node is appended?

A

The new node.