Computer science

1. Abstraction
  • Definition: Abstraction in computing refers to the concept of simplifying complex systems by focusing on the relevant details while ignoring unnecessary ones.

  • Why it's used: It is used to reduce complexity in software design and development.

    • Focusing on key details allows programmers to concentrate on functionality without becoming overwhelmed by intricacies.

  • What is removed: Unnecessary detail that does not contribute to system function or design.

  • Real-life example: A map exemplifies abstraction as it represents geographical features at a simplified scale.

  • Computing example: In games, character statistics are abstracted away to allow players to focus on gameplay rather than the underlying algorithms.

  • Exam tip: A common mistake to avoid is confusing abstraction with detail - it's crucial to understand what to abstract out.

  • Challenge: Explain how abstraction helps programmers manage complex systems by streamlining processes and reducing cognitive load.

2. Decomposition
  • Definition: Decomposition is the process of breaking down a complex problem into smaller, manageable parts or sub-problems.

  • Purpose:

    • To make problem-solving more manageable and systematic.

  • Steps involved:

    1. Identify the main problem.

    2. Break it down into smaller tasks.

    3. Solve each task individually.

  • Benefits:

    • Easier debugging as smaller components can be tested separately.

    • Encourages teamwork, allowing multiple people to work on different parts.

    • Improves readability as smaller sections are often clearer and easier to understand.

  • Example Problem: Creating a game or a website can be decomposed into various parts: UI design, backend development, database integration, etc.

  • Link to Other Concepts: Related to abstraction and sub-programmes, as decomposition often leads to creating smaller, manageable code segments.

3. Sub-programmes
  • Definition: Sub-programmes are smaller, reusable pieces of code that carry out specific tasks within a larger program.

  • Types:

    • Procedures: Sub-programmes that perform actions but do not return a value.

    • Functions: Sub-programmes that perform actions and return a value to the caller.

  • Inputs: Use of parameters to pass data into a sub-programme.

  • Outputs: Return values when sub-programmes finish executing.

  • Advantages:

    • Encourages code reuse across different parts of a program or in different projects.

    • Increases code readability by breaking tasks into clearly defined sections.

    • Eases testing and debugging as each part can be verified independently.

  • Pseudocode Example: A simple function or procedure can be represented in pseudocode format to illustrate its structure.

  • Stretch: Explain how sub-programmes facilitate decomposition by managing complexity through modular design.

4. Condition Controlled Loop
  • Definition: A loop that continues executing until a specified condition is met.

  • Keywords Used:

    • WHILE: Continues until the condition is false.

    • REPEAT UNTIL: Continues until the condition becomes true.

  • When to Use: Useful for situations where the number of iterations is not known beforehand.

  • Difference Between Loops: Contrast with count-controlled loops which have a predetermined number of iterations.

  • Flowchart Symbol: Typically represented by a diamond shape indicating a decision point.

  • Example: Implementing a password check where the loop continues until the user inputs the correct password or until a maximum number of attempts is reached.

  • Exam Tip Branch: To prevent infinite loops, ensure that the condition will eventually evaluate to false; implement safeguards where necessary.

5. Iteration
  • Definition: The process of repeating a set of instructions until a condition is met.

  • Types of Iteration:

    • Count-controlled: Runs a specific number of times.

    • Condition-controlled: Runs until a certain condition is met.

  • Keywords:

    • FOR: Typically used for count-controlled loops.

    • WHILE: Used for condition-controlled loops.

    • REPEAT: Indicates loops that are condition-controlled.

  • Why Iteration is Used: To automate repetitive tasks, reduce code redundancy, and enhance efficiency.

  • Real-world Example: Processing items in a list until all items have been accounted for.

  • Common Errors:

    • Off-by-one errors in which the loop runs one too many or one too few times.

    • Infinite loops that occur when the termination condition is never met.

  • Compare Branch: Understand the operational differences between iteration (repeating actions) and selection (choosing between options).

6. Selection
  • Definition: Selection refers to the decision-making capability in programming that allows branching of execution based on conditions.

  • Statements Used:

    • IF: Executes a block of code if the condition is true.

    • ELSE: Executes if the previous IF condition is false.

    • ELSE IF: Evaluates additional conditions if the preceding IF was false.

    • CASE: A multi-way branch selector.

  • Boolean Conditions: Conditions that evaluate to either true or false.

  • Flowchart Symbols: Often represented by diamond shapes that denote decision points.

  • Example: A grading system that assigns letter grades based on numerical scores (e.g., IF score >= 90 THEN grade = 'A').

  • Comparison with Iteration: Selection is used for choosing pathways in code, while iteration involves repeating actions based on defined parameters.

  • Exam Question Branch: Write a condition that checks if age is 18 or over using the appropriate selection statement.

7. Error Codes
  • Definition: Error codes and messages are generated by the compiler or interpreter to indicate that a problem has prevented the program from running correctly.

  • Detailed Types and Causes:

    1. Syntax Errors:

    • Definition: The code does not follow the grammatical rules (syntax) of the language.

    • Causes: Typos in keywords (e.g., prnt instead of print), missing punctuation (missing brackets () or colons :), or incorrect indentation.

    • Result: The program will not start or compile.

    1. Logic Errors:

    • Definition: The program runs but produces an incorrect or unexpected result.

    • Causes: Flawed algorithms, using the wrong operator (e.g., using + when you meant -), or incorrect boolean conditions (e.g., IF x > 10 when it should be IF x >= 10).

    • Result: The program finishes, but the output is wrong. These are often the hardest to spot.

    1. Runtime Errors:

    • Definition: An error that occurs while the program is executing, causing it to crash.

    • Causes: Mathematical impossibilities (e.g., division by 00), memory exhaustion, or trying to access a file or network resource that doesn't exist.

    • Result: The program stops abruptly or "hangs."

  • Fixing and Identifying Errors:

    • Error Messages: Often provide a line number and a description of the problem (e.g., "NameError: name 'x' is not defined at line 5").

    • Dry Runs: Using trace tables to manually step through the logic and find logic errors.

    • Debugging Tools: Utilizing features in an IDE to pause execution and inspect variable values.

8. Relational & Arithmetic Operators
  • Centre: Operators

  • Main Branches:

    • Arithmetic Operators: Operators such as +, -, *, /, and MOD for performing basic math calculations.

    • Relational Operators: Operators such as <, >, <=, >=, ==, and != for comparing values and returning Boolean outcomes.

  • Boolean Outcomes: Evaluate conditions to yield true or false, crucial for decision-making in programs.

  • Used In:

    • Selection processes to determine which branch of code to execute.

    • Loop conditions to control iterations.

  • Example Expressions: Check a value's conditions (e.g., x < 10, y == 5).

  • Practice Branch: Write an expression that checks if a number is even using the modulo operator: number MOD 2 == 0.

9. Sort and Search Methods
  • Centre: Sort & Search Methods

  • Branches:

    • Sorting Methods:

    • Bubble Sort: A simple, inefficient sorting algorithm that repeatedly steps through the list, compares adjacent elements, and swaps them if they are in the wrong order.

    • Merge Sort: A more efficient, divide-and-conquer sorting algorithm that divides the input array into two halves, sorts each half, and then merges them back together.

    • Searching Methods:

    • Linear Search: The simplest searching algorithm that checks every element until the desired value is found.

    • Binary Search: Requires a sorted array; divides the search interval in half repeatedly to narrow down the possible locations of the desired value.

  • When Each is Used: Choose appropriate methods based on dataset size and complexity.

  • Advantages & Disadvantages: Different methods vary in performance based on the situation:

    • Bubble Sort: Simple but inefficient for large datasets.

    • Merge Sort: More efficient, especially for large datasets but more complex to implement.

  • Data Requirements: When using Binary Search, data must be ordered; Linear Search does not have this constraint.

  • Step-by-Step Example: Illustrate each sorting and searching method with example data.

  • Exam Tip: For a binary search to work, the data must be sorted beforehand, as the algorithm relies on the order to eliminate half of the search space with each comparison.

10. Binary, Denary & Hexadecimal
  • Centre: Number Systems

  • Branches:

    • Binary (Base 2): The fundamental numbering system used in computers, representing values using two symbols: 0 and 1.

    • Denary (Base 10): The everyday numbering system used by humans, where ten symbols (0-9) represent values.

    • Hexadecimal (Base 16): A base system that uses sixteen symbols (0-9 and A-F) to simplify binary representation for easier human readability.

  • Why Computers Use Binary: Because binary corresponds directly to the on/off states of transistor switches within computer hardware.

  • Why Hexadecimal is Used: It provides a more compact representation of binary data, making it easier to read for humans and easier to manipulate in programming.

  • Conversions:

    • Binary → Denary: To convert, sum the powers of 2 that correspond to each binary digit.

    • Binary → Hex: Group binary digits in sets of four (starting from the right) and convert each group to its hexadecimal equivalent.

  • Example Values: Include examples for each of the number systems