topic: data structures Flashcards

records, lists, tuples, data structures (19 cards)

1
Q

what is an array

A

a data structure that contains more than data item, they have to be the same data type
it is also a linear data structure as it allocates a contiguous part of memory for the purpose of storing that data

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

what is the difference between an array and a list

A

an array is a static data structure- you cannot change its size once its been set up, only 1 data type
a list is dynamic, and can store more than 1 data type

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

visuals for 2d arrays, 3d arrays, and 4d arrays

A

a table (rown, column)
a cube (height, length, depth)
multiple cubes (first index chooses the cube, height, length, depth)

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

what is a record structure

A

composite data structure that groups related fields of different data types under one identifier
it represents a single fixed entity
a field is a variable

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

what is special about fields, in record structures

A

each field can have different data types

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

what are the 3 steps to use a record data structure

A
  1. define record structure. what fields will it have?
  2. declare a variable or array to use with the record structure
  3. assign and retrieve data from the variable record
How well did you know this?
1
Not at all
2
3
4
5
Perfectly
7
Q

give a list of linear data structures

A

arrays, records, lists (- linked lists, tuples), stacks, queues, hash table

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

what is a static data structure
examples ..

A

when data structure are in a fixed size when structure is created
and the size cannot change at run-time
e.g. arrays.

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

what is a dynamic data structure
examples..

A

a data structure thats size change during processing
it uses an area of memory called the heap

e.g. lists and linked lists

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

what is the problem with a dynamic data structure
examples..

A

as the size can change it is possible for the structure to ‘overflow’ if it exceeds the maximum allowed memory
this means the system returns an error since the memory allocation has failed and the program should detect the failure

e.g. list, linked-list

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

what are some dynamic data structures

A

lists and linked lists

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

what is the heap

A

memory set aside for dynamic allocation like dynamic data structures, objects
space is allocated and deallocated as required

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

what does immutable mean examples..

A

means the data structure does not change - static data / fixed size
elements cannot be added, removed or changed .e.g. tuples

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

define data structure
what are the two types of data structures

A

a particular way of storing and organising related data in a way that utilises it in an efficient manner
-linear and non linear data structures

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

define a linear data structure

A

the elements are stored sequentially, and the elements are connected to the previous and the next element, so they can be traversed or accessed in a single run
the implementation of linear data structures is easier as the elements are sequentially organized in memory

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

define non linear data structure

A

when data elements are not arranged in a contiguous manner, since the arrangement is nonsequential, so the data elements cannot be traversed or accessed in a single run
in the non-linear data structure, an element can be connected to more than two elements

17
Q

what are 3 traits of tuples

A
  • an immutable list which cannot be changed (size or contents) during processing
  • unlike arrays, tuples can have different datatypes
  • they’re good for data which does not change in size or content .e.g. days of the week or months of the year
18
Q

what are 4 traits of records

A
  • they’re a group or collection of related fields under a single identifier
  • each field (variable) can have a different data type (unlike arrays)
  • used in conjunction with arrays or lists e.g. a list of students
  • to access each field in the structure, use dot notation as shown right
19
Q

what are 3 traits of arrays

A
  • mutable (meaning individual elements stored in them can be changed or replaced)
  • they are typically static (meaning their total size/length is fixed upon declaration)
  • can only store one data type