Week 4 Flashcards
What is abstraction?
It is the notion of retaining the releveant details for a given context and ignoring the irrelevant details.
What are simple/atomic data types?
These are data types that can be represented in data values which CANNOT be further divided.
What are examples of atomic data types?
Int
Str
Bool
Float
What are complex data types?
These are datatypes that represent collections of multiple data values
What are examples of complex data types?
Lists Dictionaries Tuples Strings Sets
What are abstract data types (ADTs)?
These are complex data types which specifies a set of data values AND a set of operations that can be perfomed on these data values.
i.e. a function
What are characteristics of literal values?
- They are objects
- As objects they require a certain amount of memory to hold data value
What are array-based structures?
The data items in this collection are organised and stored SEQUENTIALLY in a contigous block of memory.
Individual data items are located at the adjacent memory blocks.
How can you access data in an array-based data structure? Why does this method work?
Using indexing as the data is ordered.
What are link-based structures?
A data structure where the data items for a colection can be situated at ANY locations within memory.
The data items are linked together using the concept of ‘referencing’ the address of the subsequent item.
Can data in a link-based structure be accessed randomly?
No, since the data is not adjacent to each other in memory.
How can you access an item i in a link-based structure?
First you must begin at the first node, and traverse to the node that is linked to the initial node until reaching item i.
When are array-based structured preferred?
When the total number of elements in a data collection can be predetermined at the START of the program implementation.
When accesssing data elements at random.
This is due as array-based structures generally takes less memory compared to link-based structures at equal ‘fullness’.
When are link-based structured prefered?
If adding new elements and removing existing elements at random positions.
What is mutability?
It is the ability to modify an item.