3.1 Data Structures Flashcards

1
Q

Data structure

A

An organised means of storing related data.

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

7 examples of data structures

A
  1. Arrays
  2. Records
  3. Stacks
  4. Queues
  5. Trees
  6. Linked Lists
  7. Hash tables.
How well did you know this?
1
Not at all
2
3
4
5
Perfectly
3
Q

Array

A

A data structure that stores multiple data items of the same data type.

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

Element of an array (2)

A
  1. The index of each data value in the array.
  2. Accessed by its index - 0,1,2,3 etc.
How well did you know this?
1
Not at all
2
3
4
5
Perfectly
5
Q

3 advantages of an array.

A
  1. Allows direct accessing of elements.
  2. Can be used to implement other data structures e.g. stacks/queues.
  3. No need to declare large number of variables individually.
How well did you know this?
1
Not at all
2
3
4
5
Perfectly
6
Q

Disadvantage of an array.

A

Cannot be dynamically resized in most languages.

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

Record

A

A data structure to store multiple pieces of data with may have different data types.

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

Field

A

A single item of data within a record.

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

Stack

A

A FILO or LIFO data structure where data items can be pushed or popped.

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

FILO

A

First In Last Out

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

LIFO

A

Last In First Out

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

Pushed

A

When an item is added to the top of the stack.

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

Popped

A

When an item is taken from the top of the stack.

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

What is significant about the top of the stack?

A

It is the only position where a record can be added or removed.

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

How can a stack be implemented? (2)

A
  1. Can be implemented using an array and one integer variable.
  2. A variable, called “Top” can be used as the stack pointer.
How well did you know this?
1
Not at all
2
3
4
5
Perfectly
16
Q

Stack pointer

A

To contain the index of the most recent data item added.

17
Q

How do you push records using arrays and variables? (2)

A
  1. Add new data in “Top” + 1
  2. Add 1 to “Top” variable
18
Q

How do you pop records using arrays and variables? (3)

A
  1. Subtract 1 from the “Top” variable
  2. Data that has been popped can also been deleted, but does not need to be.
  3. The next time data is pushed the old data will be overwritten.
19
Q

*Practical uses for stacks (3)

A
  1. ‘Undo’ function in a word processing package.
  2. ‘Back’ button on a browser to take user to the most recently visited page.
  3. Sub-program return address
20
Q

*Practical uses for stacks (3)

A
  1. Recursion values
  2. Reverse polish calculations
  3. As part of a compiler, check that bracket are closed )}]> in the reverse order to that in which they were opened <[{(