1.5 Abstract data types Flashcards

1
Q

What is an abstract data type (ADT)?

A

A data type described by predefined user operations without indicating how each operation is implemented.

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

Can an ADT be implemented using different underlying data structures?

A

Yes.

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

What is an example of a common ADT for holding ordered data?

A

List.

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

What operations does a list ADT commonly support?

A
  • Append a data item
  • Remove a data item
  • Search for a data item
  • Print the list.
How well did you know this?
1
Not at all
2
3
4
5
Perfectly
5
Q

What are the two common data structures used to implement a list ADT?

A
  • Arrays
  • Linked lists.
How well did you know this?
1
Not at all
2
3
4
5
Perfectly
6
Q

True or False: A programmer must know the underlying implementation of the list ADT to use it.

A

False.

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

What is the result of appending 11, 4, and 7 to an empty list in order?

A

11, 4, 7.

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

What happens when the item 2 is removed from the list containing 2, 20, 30?

A

20, 30.

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

What type of ADT is a stack?

A

An ADT in which items are only inserted on or removed from the top.

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

What is a deque?

A

An ADT where items can be inserted and removed at both the front and back.

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

What is a bag ADT?

A

An ADT for storing items where order does not matter and duplicates are allowed.

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

What is the underlying data structure for a priority queue?

A

Heap.

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

Fill in the blank: A __________ is an ADT that associates keys with values.

A

Dictionary (Map).

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

How does a priority queue order its items?

A

Based on items’ priority.

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

What is the characteristic of a set ADT regarding items?

A

Items are not ordered and duplicates are not allowed.

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

What is the result of the Print operation on a list ADT containing 55, 88, and 66?

A

55, 88, 66.

17
Q

True or False: Different underlying data structures require different algorithms for the same list ADT operation.

18
Q

What is the length of the agesList after appending three items?