Programming 2- module 8) Flashcards
What do data structures allow us to do?
Store multiple pieces of data used in programs.
In pseudocode, and in many programming languages, what are arrays indicated by?
[], as in ClassGroup = [Alex, Bailey, Krishna, Jamie, Riley].
What are the main data types?
Array.
Records.
What is an array?
Collection of something. Only 1 type of data can be stored in an array- if you want to mix, say, names and numbers you’d have to use a list. You only need to worry about 2 different types of array.
What is an example of an array?
Students in a class.
What are the 2 different types of array?
1-dimensional.
2-dimensional.
What is a record?
Single instance within an array (or database).
What is an example of a record?
A student’s info within a class database would be 1 record.
What is a record used for?
Holding different pieces of data about 1 item.
What could a two-dimensional array be used for?
Class timetable or book reviews by different students, so that each row is a different book, + each column is the review by a different student.
What is a record structure?
Template for data storage that will most effectively do whatever you need.
What are key fields uniquely attached to?
Each record.
Why will a two-dimensional array often include key fields?
So that if there were 2 people with the same name who read the same book we would know which one we were looking for, because the key field is different.
What would be an example of a key field?
In your school records, you will have a UPN, a Unique Pupil Number. This would be your key field, or primary key. Even if someone was born on the same day as you, with the same name and address, they couldn’t be mixed up with you.
What can you imagine a two-dimensional array as?
As a table, or a chess board.