Static and Dynamic Data types Flashcards

(10 cards)

1
Q

What are Arrays

A

Static data structures that store data of the same type under a single identifier. Data is stored in elements, each with its own index, arranged as a contiguous block in memory of a fixed length

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

How does indexing work in arrays?

A

The index acts as an offset to the data from the start off the structure in memory. For this reason the dimensions and data type of the array must be known.

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

What is a multidimensional array?

A

An n-dimensional array is a set of elements with the same data type that are indexed by a tuple of n integers, where a tuple is an ordered list of elements.

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

What are the uses of arrays?

A
  • Can store multiple homogenous values (1D)
  • Can represent vectors (1D)
  • Can store tabular data in a matrix (2D)
  • Multidimensional arrays are common in machine learning applications where large data sets containing multiple related data are used to train models
How well did you know this?
1
Not at all
2
3
4
5
Perfectly
5
Q

What are the advantages of static data structures?

A
  • Do not require pointers so take up less space for a given number of elements
  • Can randomly access any element in constant time because data is stored in contiguous memory locations
  • Faster than dynamic data structures
How well did you know this?
1
Not at all
2
3
4
5
Perfectly
6
Q

What are the disadvantages of static data structures?

A
  • Cannot increase in size to allow more data to be stored than size declared at compilation allows
  • Cannot decrease in size to free up memory
  • Inefficient if more space is allocated than required
  • Can lead to errors if not enough space is allocated
How well did you know this?
1
Not at all
2
3
4
5
Perfectly
7
Q

What are static data structures

A

-Data structures with a fixed size determined at declaration/compilation
-are arranged in contiguous locations in memory
-no pointers

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

What are dynamic data structures

A

-Data structures that can change size at run time as new items are added/removed during a program’s execution, by allocating from the ‘heap’
-Require pointers

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

Advantages of Dynamic Data structures

A

More flexible, with no wasted space as they only take up as much space as is required for their data

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

Disadvantages of Dynamic Data structures

A

Do not store items in consecutive memory locations and require memory to store pointers to next items

Consumes more space to store N items than a static structure.

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