121 Week 6 - Abstract Data Structures + Queue Flashcards

You may prefer our related Brainscape-certified flashcards:
1
Q

Abstract data structure (ADT)

A

A type (or class) for objects whose behaviour is defined by a set of values and a set of operations. It will state operations to be performed but not how they will be performed.

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

Queue example

A

An ADT which is an ordered collection of items.
It has a head and tail which are the first and last items in the queue.
Items are added to the tail and removed from the head - First in Last out.

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

Operations of a queue

A

queue() - create a new empty queue
enqueue(item) - add item to the end of the queue
dequeue() - if the queue isn’t empty, remove the item at the head of the queue and return its value
isEmpty() - test if the queue is empty
size() - find the size of the queue

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

Abstraction

A

Removing unnecessary information and hiding internal details

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

Difference between data structure and abstract data structure

A

Data structure is the physical representation of the structure of the data being stored in memory.
Abstract data structure is both the data structure and the procedures/functions which manipulate that data structure.

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

Encapsulation

A

A way of stopping the user from directly interacting with the ADT but instead providing an interface through which they can interact with the ADT instead.
Encapsulation is strong if details on how the data structure is stored is completely hidden from the user.

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

Queue implementation through pointers

A

A queue can be implemented by having a head pointer which points to the first item in the queue.
Each item then points to the next item in the queue.
The last item will point to NULL, indicating the end of the queue.
An empty queue is indicated by head being NULL.

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

Bounded queue implementation through arrays

A

Assume queue can have at most max_size elements.
Create an array of length max_size.
Enqueue an item into the next free space in the array as long as the array is not full.
Dequeue an item by setting the last stored item in the array to be free

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