cs 2.1 data structures (ALEVEL) Flashcards

(14 cards)

1
Q

Linear queues

A

has two pointers (front +rear)
- identify which item at front and where to place new item
Add item:

check if list is full - if not…
the item is added to where rear pointer is pointed to
and rear pointer moves to nest available position

remove item:

check if list is empty - if not…
item that the front pointer is pointing at is removed
front pointer moves to the next item

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

queues operations

A

Enqueue
Dequeue
IsEmpty
IsFull

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

circular queue

A

front and rear pointer can move over the two ends of the queue making for more memory efficient data structure
know how to:
add item, remove item

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

priority queues

A

items are assigned a priority, items with highest priority are dequeued before low priority items.
if 2/more items have same priority items are removed in FIFO order
e.g. priority printer queue

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

Stacks + operations

A

has a top pointer
push
pop
peek
IsFull (if it is = stack overflow)
IsEmpty (if it is = Stack underflow)
know how to:
add, remove,peek, an item

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

graphs - adjacency matrices

A

-stores every possible edge between nodes even those that don’t exist = almost half of matrix is repeated data (memory inefficient)
-allows specified edge to be queried very quickly (time efficient)
-suited to dense graphs where there’s large no. of edges.

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

graph -adjacency list

A

-only stores edges that exist in graph(memory efficient)
-slow to query, each item in list must be searched sequentially (time inefficient)
-well suited to sparse graph, where there’s few edges

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

hash tables

A

constant time complexity - O(1)
stores key-value pairs
key sent to hash function, resulting hash is index of key-value pair in hash table

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

hashing algorithm

A

takes an input and returns a hash
-hash is unique to its input + cannot be reversed to retrieve the input value

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

hash table -collisions

A

different inputs produce same hash
rehashing technique = keep on moving to next position until an available one is found

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

Dictionaires

A
  • collection of key-value pairs
    -value accessed by associated key
  • application = dictionary-based compression
How well did you know this?
1
Not at all
2
3
4
5
Perfectly
12
Q

Vectors

A

if viewed as function - represented by dictionary
if viewed as a list - represented by one-dimensional array

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

Static data structure

A

fixed in size
if no. of data items to be stored exceeds no. of memory location allocated to structure = overflow error

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

Dynamic data structure

A

change in size
no. of memory locations required isn’t fixed
computer can’t allocate contiguous memory locations, each item is stored alongside a reference to where next item is stored in memory

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