5. Data Structures Flashcards
What is a data structure?
A data structure is a set of related elements held in a computer’s memory.
What are some examples of data structures?
- one dimensional arrays
- two dimensional arrays
- strings
- records
What is a static data structure?
When the size of the data structure is predetermined. This can be limiting as you need to know how large the data structure needs to be in advance, however it is easier to code as you always know how much space they’re going to take up.
What is a dynamic data structure?
A data structure that has no fixed size and can expand or shrink when needed.
What is an array?
A collection of data elements of the same data type grouped together under one identifier. They are static data structures.
Give an example of a 1 dimensional and a 2 dimensional array
One dimensional
declaring: Names = [“Sam”, “Lucy”, “James”]
calling: Names[1] would retrieve Lucy
Two dimensional
declaring: Names = [“Sam”, “Lucy”, “James”],
[“Peter”, “Sarah”, “Tom”]
calling: Names[1, 0] would retrieve Peter
What is a record?
A record is a set of items all related to a single entity. Records can contain more than 1 data type.