Software Design & Development: Unit 2 - Data Types and Structures Flashcards
What is a 1-D array?
A data structure containing a set of variables of the same data type, with positions stored as an integer index.
What is a 2-D array?
An array of 1-D arrays
What is a record structure?
A data structure containing a set of variables of different data types (similar to a database record, made of different field types)
What is an array of records?
An array containing a set of records
What is a linked list?
A set of items organised sequentially just like an array, but each item includes a link to the next item in the list
What are advantages of using a linked list? (2)
- 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
What is a disadvantage of using a linked list?
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.
What is a stack?
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)
What is an advantage of using a stack?
It is useful where a situation calls for the most recent item to be accessed
What is a queue? (2)
- 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)
What is an advantage of using a queue?
It is useful where a situation calls for events to be placed in a queueing system waiting to be processed in order.
Implement a 2-D array
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
Implement an array of records
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 }