Data Structures unit 2 Flashcards
(10 cards)
What is a data structure?
An organised collection of related elements used to store and manage data.
What is a one-dimensional array?
A list of elements, each with a unique index starting from 0.
Give an example of a one-dimensional array.
marks = [75, 80, 92, 66]
What is a two-dimensional array?
A matrix (grid) with rows and columns where each element is accessed using two indices.
Give an example of a two-dimensional array.
timetable = [
[“Math”, “English”],
[“Science”, “History”]
]
What data type do all elements in an array share?
The same data type (e.g., all integers or all strings).
What is a record in programming?
A collection of fields, where each field can store a value of a different data type.
Give an example of a record.
student = {
“name”: “Alice”,
“age”: 15,
“grade”: 8.5
}
What is the main difference between arrays and records?
Arrays store elements of the same type, records store different types of values in fields.
What does designing a record structure involve?
Deciding what fields are needed and what data type each one should store.