1.1 data structures Flashcards
pre order
dots to the left
in order
dots on the bottom
post order
dots on the right
linked list characteristics
- dynamic data structure it can grow and stinks in size after declaration
- each element is called a node - first element is head node
- each node consists of the data and the reference to the next node
- consists of starter pointer which points at the first item in the list and so on
- items can be added into a linked list without having to shift the other items to fill the gap left (adv over 1D array)
how to create binary trees
from first element - bigger (right) smaller (left)
remove from a binary tree with 2 children
go the right pointer and find the lowest value child from that element then replace the value being deleted with that child
what is a data structure
a set of related data items
why are the data structures are useful
- efficient way of organising data relating to a real problem
- may be efficient to deal with various elements as one item
an example of data that could be stored in a 2D array
sales of each product number by month
what are the key features of an array
- a data structure which is a set of data elements of the same type
- can be directly accessed via indexes, subscripts, row/column names
- has a fixed number of elements (static)
give an example of data that could be stored in 3D arrays
what is a record data and structure and when would they be used
- a record is a set of data items all related to a single individual/ entity
- a record can contain data of different types
- a record would be used if there is data of more than one type
drawbacks of using 3D arrays
- more complex to program/process
what data is suitable for a 1D array
when the data set comprises of single values of the same data type
what is a stack
- a container of objects that are inserted and removed according to LIFO
- It has a limited access data structure - elements can be added and removed from the stack only at the top
- push adds an item to the top of the stack
- pop removes the item from the top
- a stack can be used as a recursive data structure
- a stack is either empty or is consists of a top and the rest which is a stack
- underflow occurs when an attempt is made to pop an empty stack or when an attempt is made to push a full stack