Data Structure
Data structures are used by computers as the containers within which information is stored
Static Data Structure
A fixed data structure that is reserved memory at the start of the program. The contents of a static array can be changed but the array cannot be resized
Dynamic Data Structure
Memory can be allocated and deallocated as required while the program is running.
Abstract data types
Do not exist as data structures in their own right, and instead make use of other data structures such as arrays to form a new way of storing data. It is a conceptual model that describes how data is organized and which operations can be carried out on the data
Primitive Data Type
only contains one value
Benefits of Static Data Structures?
Points of Dynamic Data Structures?
Array
An array is an indexed set of related elements, finite and only contains elements of the same data type
Example of 1D array
Array Names = {“Bob, “Will”, “Sam”}
Example of 2D array
Array Colours = {“light blue, dark blue, blue”}, {“light pink, dark pink, pink”}, {“light green, dark green, green”}}
(indexing starts at 0)
Colours(0,1) would return ‘dark blue’
Colours(2,0) would return ‘light green’
Static Memory Allocation
How does Dynamic Memory Allocation occur
What is Recursion?
A recursive subroutine is one that calls itself.
What is a Base case?
The case where recursion does not occur
Criteria for recursion?
Factorial
A Factorial (n!) is a function that multiplies a number by every number below it.
What are Queues? How/where are they used?
Queue Operations
How to remove items in a circular queue?
1. Check the queue is not already empty;
2. Compare the value of the front pointer with the maximum size of the array;
3. If equal then front pointer becomes one; A. index of the first position in the array instead of one
4. Otherwise, add one to the front pointer;
How to add items to a Linear queue?
How to add items to a Priority Queue?
Linear Queue
As an item is removed from the queue all other items move up one space. For a long queue this can take a lot of processing.
pointers
the pointer representing the start of the queue moves as an item is removed from the queue. However, this leads to a lot of empty cells/wasted memory at the front of the list. You also need to know the queue length and how many elements have been removed.
Circular Queues
As an item is removed memory locations are recycled: Unused memory locations at the front now become memory locations at the back of the queue, making it more memory efficient