1.4.2 - Data structures Flashcards

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

What is an array?

A

A data structure which contains a set of data items of the same data type grouped under a single identifier.

Is static so size cannot change.

Each individual element can be addressed and accessed directly via its index or subscript i.e. random access.

Contents are stored contiguously in computer memory.

Unlike lists, they can be multi-dimensional.

Therefore it isn’t flexible (static)

But is faster to read through

Contiguous

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

What is a record?

A

are data stores organised by attributes (fields).

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

What are lists?

A

A List is an ordered collection of elements of a single data type. There is no limit on how many elements can be in the list so therefore

is more flexible

but is slower to read through if there are loads of elements

but isn’t contiguous

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

What is a tuple?

A

Tuples are lists that cannot be modified once set up i.e. immutable.
Used to store multiple items of different data types in a single variable.

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

What are linked lists?

A

Is a dynamic data structure

Uses index values and pointer to sort a list in a specific way.

Can be organised on more than one category.

Needs to be traversed until the desired element is found

To add data to a list, it is added in the next available space and the pointers are updated accordingly

To remove an item from the list, the pointer in the previous item is set to the value in the item to be removed,
effectively bypassing the removed item.

The contents may not be stored contiguously in memory.

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

What are graphs?

A

Is a collection of data nodes/vertices and the connections/edges set between them.

The connections (edges) can be:
- directional or bi-directional
- directed or undirected
- weighted or unweighted.

Can be represented by an adjacency matrix.

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

What are stacks?

A

Are LIFO (‘last in, first out’) dynamic data structures.

There are two pointers: a top and a bottom. The top is often called the stack pointer.

Data is added and removed from the top of the stack.

Use the command PUSH to add data and POP to remove data.

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

What are queues?

A

Are FIFO (‘first in, first out’) dynamic data structures.

There are two pointers: a start and an end. The start is often called the queue pointer.

Data is added from the end and removed from the start of the queue.

Use the command PUSH to add data and POP to remove data.

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

What are trees?

A

Are dynamic branching data structures.

They consist of nodes that have sub nodes (children).

The first node at the start of the tree is called the ‘root node’.

The lines that join the nodes are called ‘branches’.

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

What are hash tables?

A

Enable access to data that is not stored in a structured manner.

Hash functions generate an address in a table for the data that can be recalculated to locate that data.

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

What is a binary search tree (BST)?

A

One specific kind of tree is a BST, where each node only has maximum of 2 children from a left branch and a right
branch.

To add data to the tree, it is placed at the end of the list in the first available space and added to the tree following the
rules:

If a child node is less than a parent node, it goes to the left of the parent.

If a child node is greater than a parent node, it goes to the right of the parent.

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

What is stack overflow?

A

When an item is attempted to be pushed onto a stack but the stack is full.

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

What is a stack underflow?

A

Returning the value from the top of the stack without removing it.

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

What is popping?

A

Adding an item to the top of a stack.

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

What is pushing?

A

Removing an item from the top of the stack.

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

What is peeking?

A

Returning the value from the top of the stack without removing it.

17
Q

What is enqueue?

A

Where an item in a queue is added at the back of the queue.

18
Q

What is a dequeue?

A

Where an item is removed from the front of the queue.

19
Q

What is a priority queue?

A

Allows for things to jump the queue if it has higher priority.