1/45
Looks like no tags are added yet.
Thinking procedurally
Breaking a problem down into a sequence of steps that must be followed in a specific order to reach a solution. Like following a recipe: each step depends on the previous one. Identify steps, put them in order, and express them clearly.
Thinking logically
Using logical reasoning to make decisions within an algorithm. Involves conditions (if-then-else), Boolean logic (AND, OR, NOT), and determining what decision to make at each point. Helps predict outcomes and identify errors.
Thinking ahead
Planning what inputs, outputs, and pre-conditions are needed before starting to solve a problem. Involves identifying what data is needed, what format it should be in, and what resources are required. Includes pre-planning (caching, prefetching) to improve performance.
Thinking concurrently
Recognizing when parts of a problem can be solved at the same time (in parallel) rather than one after another. Example: in a restaurant, the chef can cook multiple dishes simultaneously. Improves efficiency but adds complexity (need to coordinate).
Thinking abstractly
Focusing on the essential details of a problem while ignoring irrelevant complexity. Removing unnecessary detail to create a simplified model. Example: a map is an abstraction of the real world that shows only relevant features (roads, cities) while omitting others (individual trees).
Thinking recursively (HL)
Solving a problem by having a function call itself with a smaller version of the same problem. Requires a base case (stopping condition) and a recursive case. Example: calculating factorial: factorial(n) = n * factorial(n-1), base case factorial(0) = 1.
Identifying the procedure for solving a problem
Decompose the problem into smaller sub-problems. For each sub-problem, identify the specific steps needed and put them in the correct order. This is the foundation of algorithmic thinking.
Decision-making in algorithms
Using conditions to determine which path an algorithm follows. Involves evaluating Boolean expressions and choosing between two or more actions. Represented as diamond shapes in flow charts and if/else statements in pseudocode.
Identifying when a decision is needed in a problem
A decision is needed whenever the algorithm must choose between different actions based on a condition. Example: "If the temperature is above 30, turn on the AC, otherwise do nothing."
Identifying the role of sub-procedures in solving a problem
Large problems are broken into smaller, manageable sub-procedures (functions/methods). Each sub-procedure solves one part of the problem. Benefits: reusability, easier testing, easier debugging, team collaboration.
Identifying pre-planning in a suggested problem
Before coding, determine: what inputs are needed, what outputs are expected, what data structures to use, what processing is required, what resources are available, and what constraints exist. Pre-conditions must be met before the algorithm can run.
Explaining the need for pre-conditions
Pre-conditions are requirements that must be true before an algorithm or sub-procedure can execute correctly. Example: a binary search requires the array to be sorted first. If pre-conditions are not met, the algorithm may produce incorrect results or crash.
Exceptions and their handling
An exception is an unexpected event that disrupts normal program flow (e.g. dividing by zero, file not found, invalid input). Exception handling involves detecting these events and responding gracefully (e.g. displaying an error message) instead of crashing.
Caching
Storing frequently used data in a fast-access location so it can be retrieved quickly without recalculating or re-fetching it. Example: a web browser caches web pages so they load faster on revisits. Trades memory space for speed.
Prefetching
Loading data or instructions before they are actually needed, based on predictions of what will be required next. Reduces waiting time. Example: a processor prefetches the next instruction while executing the current one.
Abstraction in problem-solving
Creating a simplified representation of a real-world entity or system that captures only the relevant details. Example: a Student object might have name, grade, and ID, ignoring details like height or favourite colour. Successive decomposition creates levels of abstraction.
Levels of abstraction through successive decomposition
A system is broken down into sub-systems, each sub-system into smaller components, and so on. Each level hides the complexity of the level below. Example: School -> Faculties -> Departments -> Courses.
Distinguishing between a real-world entity and its abstraction
The real-world entity has all details (a physical car has colour, weight, engine specs, scratch marks). Its abstraction captures only what matters for the problem at hand (a Car object in a parking system might only need license plate and entry time).
Sequential search (linear search)
Checks each element of an array one by one from the beginning until the target is found or the end is reached. Works on unsorted data. Pseudocode: loop from 0 to end, if ARRAY[i] = target then return i. Worst case checks every element.
Binary search
Requires a SORTED array. Repeatedly divides the search space in half. Compare target with middle element: if equal, found; if target is smaller, search left half; if larger, search right half. Much faster than sequential search for large sorted arrays. Worst case: log2(n) comparisons.
Binary search vs sequential search
Binary search is much faster for large sorted arrays (log2(n) vs n comparisons). But binary search requires the array to be sorted first, which takes time. Sequential search works on unsorted arrays and is simpler to implement. For very small arrays, the difference is negligible.
Bubble sort
Repeatedly steps through the array, comparing adjacent elements and swapping them if they are in the wrong order. Each pass "bubbles" the largest unsorted element to its correct position. Simple but slow for large arrays. Pseudocode: nested loops, outer loop for passes, inner loop for comparisons/swaps.
Selection sort
Finds the smallest element in the unsorted portion of the array and swaps it with the first unsorted element. Repeats for each position. Pseudocode: outer loop for each position, inner loop to find minimum, then swap. Makes fewer swaps than bubble sort but same number of comparisons.
Standard operations of collections
Collections store groups of similar elements. Standard operations: addItem() to add an element, getNext() to retrieve the next element, hasNext() to check if more elements exist, resetNext() to go back to the beginning.
Discussing algorithms for a specific problem
Explain what the algorithm does, trace through it with sample data, evaluate its efficiency (time and space), and compare it to alternatives. Example: discuss why binary search is better than sequential search for a sorted phonebook but sequential is needed if the list is unsorted.
Analysing a flow chart algorithm
Trace through the flow chart with specific input values. Track all variable values at each step. Follow decision diamonds (Yes/No branches). Determine the output. Assess whether the algorithm produces the correct result.
Analysing an algorithm in pseudocode
Read line by line, tracking variable values. Handle loops (determine how many times they execute), conditionals (which branch is taken), and operations. Determine the output for given inputs.
Constructing pseudocode from a description or flow chart
Translate the logic into IB pseudocode: use loop…end loop for iteration, if…then…else…end if for decisions, and standard notation for assignment, input/output. Follow the IB approved notation sheet conventions.
Determining how many times a step executes
Count loop iterations for given input. For nested loops, multiply the iteration counts. For conditional statements inside loops, count how many times the condition is true. Example: a loop from 0 to N-1 executes N times.
Fundamental operations of a computer
Add (arithmetic), compare (logical), retrieve (read data from memory), and store (write data to memory). All complex operations are composed of many simple fundamental operations.
Fundamental vs compound operations
Fundamental operations are the basic single steps a computer can do (add, compare, retrieve, store). Compound operations are built from multiple fundamental operations. Example: "find the largest" is a compound operation requiring many comparisons and stores.
Essential features of a computer language
Fixed vocabulary (specific keywords), unambiguous meaning (each instruction has one clear interpretation), consistent grammar and syntax (rules for combining words/symbols). These features allow the computer to parse and execute instructions reliably.
Need for higher-level languages
As computing needs grew, writing complex systems in machine code became impractical. Higher-level languages abstract away hardware details, are closer to human language, enable faster development, and are portable across different hardware. Examples: Python, Java, C++.
Translation process: compiler, interpreter, virtual machine
A compiler translates the entire source code into machine code before execution (produces an executable file). An interpreter translates and executes source code line by line (slower but easier debugging). A virtual machine provides a platform-independent execution environment (e.g. Java's JVM).
Variable
A named storage location in memory whose value can change during program execution. Example: counter = 0, then counter = counter + 1.
Constant
A named storage location whose value is set once and cannot be changed during execution. Used for values that should not be modified, like PI = 3.14159. Improves readability and prevents accidental changes.
Operator
A symbol that performs an operation on one or more values. Types: arithmetic (+, -, *, /), comparison (=,
Object (in programming)
An instance of a class that bundles data (attributes/properties) and actions (methods/procedures) together. Objects model real-world entities. Example: a Car object might have attributes (colour, speed) and methods (accelerate, brake).
Operators: mod and div
mod returns the remainder after integer division. Example: 17 mod 5 = 2 (because 17 / 5 = 3 remainder 2). div returns the integer quotient (whole number result). Example: 17 div 5 = 3. Useful for checking even/odd (N mod 2), extracting digits, and cycling through ranges.
Constructing algorithms using loops
Use loop…end loop for counted repetition: loop COUNT from 1 to 10 … end loop. Use loop while CONDITION … end loop for condition-based repetition. Nested loops place one loop inside another.
Constructing algorithms using branching
Use if CONDITION then … end if for single-path decisions. Use if CONDITION then … else … end if for two-path decisions. Nest if statements for multiple conditions.
Collection
A data structure that holds a group of similar elements. Unlike an array, a collection can grow dynamically. Access methods: addItem(data), getNext(), hasNext(), resetNext(), isEmpty().
Collection access methods
addItem(data): adds an element. getNext(): returns the next element and moves the pointer forward. hasNext(): returns true if there are more elements to retrieve. resetNext(): resets the pointer to the beginning. isEmpty(): returns true if the collection has no elements.
Sub-programmes (functions/procedures)
A named block of code that performs a specific task. Can be called from other parts of the program. Benefits: code reuse (write once, call many times), modularity (break program into manageable pieces), easier testing and debugging, team collaboration.
Need for sub-programmes and collections
Sub-programmes make code reusable and organized. Collections allow flexible storage of related data. Together they enable complex programs to be built from simple, tested components. Essential for maintenance by future programmers.
Constructing algorithms using sub-programmes, arrays, and collections
Combine all constructs: define sub-procedures for specific tasks, use arrays for fixed-size data storage, use collections for dynamic data, use loops and conditions for control flow. IB exams expect pseudocode only (not working code) in externally assessed components.