Data Structures unit 2 Flashcards

(10 cards)

1
Q

What is a data structure?

A

An organised collection of related elements used to store and manage data.

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

What is a one-dimensional array?

A

A list of elements, each with a unique index starting from 0.

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

Give an example of a one-dimensional array.

A

marks = [75, 80, 92, 66]

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

What is a two-dimensional array?

A

A matrix (grid) with rows and columns where each element is accessed using two indices.

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

Give an example of a two-dimensional array.

A

timetable = [
[“Math”, “English”],
[“Science”, “History”]
]

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

What data type do all elements in an array share?

A

The same data type (e.g., all integers or all strings).

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

What is a record in programming?

A

A collection of fields, where each field can store a value of a different data type.

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

Give an example of a record.

A

student = {
“name”: “Alice”,
“age”: 15,
“grade”: 8.5
}

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

What is the main difference between arrays and records?

A

Arrays store elements of the same type, records store different types of values in fields.

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

What does designing a record structure involve?

A

Deciding what fields are needed and what data type each one should store.

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