Itty Bits Flashcards
byVal vs byRef:
By value: A copy of the value is passed.
By reference: The address of the parameter is given so it will be updated at the given address.
Local variables vs global variables
Local variables:
+ Ensures subroutines are self contained
+ Requires less memory
Global variables:
- Can be unintentionally overwritten
- Take up more storage
Recursive methods advantages and disadvantages
+ Efficient use of code
+ Tail recursion: Less space is required
- If it calls itself too many times, that could result in stack overflow, causing a crash
- Difficult to trace
Concurrency advantages and disadvantages:
Each task is given a slice of processor time
+ Number of tasks is increased
+ Less time wasted waiting for an input, as other tasks can be completed
— Can take longer to complete when there’s a large number of users and tasks
— Not all tasks are suited to being broken up and performed correctly
What does abstraction do?
Hides information that is too complex or irrelevant to the systems purpose
Enables more efficient software design
Reduces time spent on project
Modular programming
Splitting tasks into smaller moduals.
Top down approach:
Continually broken down into sub-problems, which each can be represented as single task
Backtracking
Methodically visiting each path, and if a path is found to be invalid, bacingtracking to the previous stage and visits an alternate path
Example: Depth-first traversals
Quick Sort
Selects a central element called a pivot
Elements smaller than the pivot are placed on the left (as close to the centre as possible, working through from the centre outwards), and elements larger are placed on the right.
This process repeats recursively on each new list until all elements in the lists are old pivots or have a length of 1
Old pivots are ignored
Pivot reads from centre outwards
Merge Sort Tip
The parts are called elements
Binary Search Tip
Biases to the right
Depth-First Traversal
Same as post-order
Goes as far down into the tree as possible before backtracking
Uses a stack
Breadth-First traversal
Uses a queue
Decomposition defintion
Breaking down the problem into smaller solutions
Decomposition benefits:
+ Easier to manage
+ Development teams can be deployed
+ Parts can be worked in parallel
+ Easier to locate errors within specific moduals
+ Without it, testing would have to be done all at once.