• Congratulations to the Class of 2024 on your results!
    Let us know how you went here
    Got a question about your uni preferences? Ask us here

Multidimensional array vs array of records (1 Viewer)

SadCeliac

done hsc yay
Joined
Sep 23, 2021
Messages
2,490
Location
Sydney <3
Gender
Male
HSC
2023
What's the difference and how would I explain what each one does??

Also what is an example of each? I would say that a grid or table can be represented by a 2D array, but I'm not sure what array of records do.

Thanks!
 

cossine

Well-Known Member
Joined
Jul 24, 2020
Messages
626
Gender
Male
HSC
2017
multidimensional array is array with 2 or more dimension. For each dimension you will need to provide a index if you want to access an element. So an example would be an RGB image. 1st dimension row, 2nd dimension column, 3rd dimension the channel (e.g. R, G or B).

When you say array of records that makes me think of the rows of a dataframe (dataframe is just fancy word for table of data). I guess another possibility would be a list containing a Python dictionaries. e.g. [{name:"XYZ", age: 9}, {name:"NMJ", age: 14}].
 

SadCeliac

done hsc yay
Joined
Sep 23, 2021
Messages
2,490
Location
Sydney <3
Gender
Male
HSC
2023
multidimensional array is array with 2 or more dimension. For each dimension you will need to provide a index if you want to access an element. So an example would be an RGB image. 1st dimension row, 2nd dimension column, 3rd dimension the channel (e.g. R, G or B).

When you say array of records that makes me think of the rows of a dataframe (dataframe is just fancy word for table of data). I guess another possibility would be a list containing a Python dictionaries. e.g. [{name:"XYZ", age: 9}, {name:"NMJ", age: 14}].
Okay

Because I had this come up in a practice trial today and the answers said that array of records is ordered as well? Is that correct?
 

cossine

Well-Known Member
Joined
Jul 24, 2020
Messages
626
Gender
Male
HSC
2017
Okay

Because I had this come up in a practice trial today and the answers said that array of records is ordered as well? Is that correct?
So array is generally ordered i.e. order of the elements matter. That is depending on the index you pass you will get a different element.

So in example we gave

arr_records = [{name:"XYZ", age: 9}, {name:"NMJ", age: 14}]

print(arr_records[0]) will output {name:"XYZ", age: 9}.
print(arr_records[1]) will output {name:"NMJ", age: 14}

In contrast if you working with a set data type order will not matter. This is due to how sets are defined inmathematics. i.e. {1, 2} = {2, 1}
 

wizzkids

Well-Known Member
Joined
Jul 13, 2016
Messages
339
Gender
Undisclosed
HSC
1998
What's the difference and how would I explain what each one does??

Also what is an example of each? I would say that a grid or table can be represented by a 2D array, but I'm not sure what array of records do.

Thanks!
When you set up a multidimension array, you have to initialise "dim" the array and define explicitly how many dimensions it will hold and what data types it will hold. Then sufficient memory will be reserved to hold this size of array. It could be a 4-dimensional array.
Then you can read or write any element by addressing the appropriate values for each dimension. So you can see this is a fast way of randomly accessing an element.
An array of records sounds more like a flat-file database, where each record is numbered sequentially. You don't need to define the dimensions of a one-dimensional array. Well, I suppose you could, but why would you bother? Just keep writing line by line as the array expands. Then read through the records line by line. I suppose the records could be considered "ordered" in the sense that they are read sequentially.
 

dav53521

Well-Known Member
Joined
Mar 23, 2022
Messages
317
Gender
Male
HSC
2022
Maybe my issue is I just don't get what a record is??
A record has multiple different "variables" that can be of different types and each variables is accessed in the record by it's name.

An example record could be a student record which is declared in NESA pseudocode as (things between DIM and END should be indented)

DIM RECORD Student
Name as String (50)
Age as Integer
School as String (100)
Grade as Integer
TotalAverage as Real
END RECORD

And with this record a hypothetical student called Bob could have a record that would be structured like
Name: Bob Smith
Age: 17
School: James Ruse
Grade: 10
TotalAverage: 94.57

Also if you want to learn more you could (if you haven't already) look at the course specs as it's really helpful for stuff like the standard algorithms and the data structures used in SDD.
 
Last edited:

SadCeliac

done hsc yay
Joined
Sep 23, 2021
Messages
2,490
Location
Sydney <3
Gender
Male
HSC
2023
A record has multiple different "variables" that can be of different types and each variables is accessed in the record by it's name.

An example record could be a student record which is declared in NESA pseudocode as (things between DIM and END should be indented)

DIM RECORD Student
Name as String (50)
Age as Integer
School as String (100)
Grade as Integer
TotalAverage as Real
END RECORD

And with this record a hypothetical student called Bob could have a record that would be structured like
Name: Bob Smith
Age: 17
School: James Ruse
Grade: 10
TotalAverage: 94.57

Also if you want to learn more you could (if you haven't already) look at the course specs as it's really helpful for stuff like the standard algorithms and the data structures used in SDD.
tysm!
 

Users Who Are Viewing This Thread (Users: 0, Guests: 1)

Top