Software Design & Development: Unit 2 - Data Types and Structures Flashcards

1
Q

What is a 1-D array?

A

A data structure containing a set of variables of the same data type, with positions stored as an integer index.

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

What is a 2-D array?

A

An array of 1-D arrays

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

What is a record structure?

A

A data structure containing a set of variables of different data types (similar to a database record, made of different field types)

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

What is an array of records?

A

An array containing a set of records

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

What is a linked list?

A

A set of items organised sequentially just like an array, but each item includes a link to the next item in the list

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

What are advantages of using a linked list? (2)

A
  • Dynamic data structure, which means that its size is not fixed
  • Memory efficient, only needs to be as large as the number of items to be stored, instead of as large as the total possible number of items stored
How well did you know this?
1
Not at all
2
3
4
5
Perfectly
7
Q

What is a disadvantage of using a linked list?

A

Not possible to identify a specific item directly using its index - as in an array - and to identify an item you have to walk through the list from beginning to end.

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

What is a stack?

A

A data structure acting like a vertical list, where data elements can be added or deleted only from the ‘top’ of the stack (Last In First Out)

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

What is an advantage of using a stack?

A

It is useful where a situation calls for the most recent item to be accessed

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

What is a queue? (2)

A
  • A data structure where data items are inserted and retrieved at different ends
  • In a queue two pointers are used, one to point to the head of the queue and one for the end (First In First Out)
How well did you know this?
1
Not at all
2
3
4
5
Perfectly
11
Q

What is an advantage of using a queue?

A

It is useful where a situation calls for events to be placed in a queueing system waiting to be processed in order.

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

Implement a 2-D array

A

DECLARE example AS ARRAY OF ARRAY OF INTEGER INITIALLY []
SET example TO [ [] ] * X #array with X elements, each an empty array

FOR column FROM 0 TO Y DO #Y=max column no.
FOR row FROM 0 TO Z DO #Z=max row no.
SEND example[column][row] TO DISPLAY
END FOR
END FOR

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

Implement an array of records

A

RECORD record IS{STRING name, INTEGER number}

DECLARE example AS ARRAY OF record INITIALLY []

SET example[0] TO { name=”A’ , number=1 }
SET example[1] TO { name=”B” , number=2 }
SET example[2] TO { name=”C” , number=3 }

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