In this session, we will review key concepts from Topic 2.1: Thinking Abstractly, Ahead, Procedurally, Logically, and Concurrently. These skills are fundamental to solving problems efficiently in Computer Science.
Abstraction helps us simplify complex systems, thinking ahead ensures we plan effectively, and procedural thinking allows us to break down problems into manageable steps. Logical thinking enables us to structure decisions clearly, while concurrent thinking improves performance by handling multiple tasks simultaneously.
By mastering these techniques, you will improve your ability to design, develop, and optimize software solutions.
Nature of Abstraction: Simplifies complexity by focusing on essential details. Example: Maps show key locations but not every tree.
Need for Abstraction: Reduces complexity, improves efficiency, and enhances communication.
Representational Abstraction: Simplified models like subway maps or GUI interfaces.
Abstraction by Generalisation: Groups similar concepts (e.g., all vehicles under "transport").
Information Hiding: Conceals internal workings; a driver uses a car without knowing engine details.
Procedural Abstraction: Defines processes as reusable functions (e.g., calculate_area(length, width)).
Functional Abstraction: Focuses on inputs and outputs, not internal computation (add(a, b)).
Data Abstraction: Works with data conceptually (e.g., using a queue without knowing its structure).
Problem Abstraction: Breaks complex problems into smaller, solvable parts (e.g., solving a maze step by step).
Identifying Inputs/Outputs: Defining required data and expected results (e.g., IPO tables).
Determining Preconditions: Ensuring correct inputs before execution to prevent errors.
Caching: Temporarily storing data for faster access but risks stale or excessive memory use.
Reusable Components: Using libraries and functions to save time and ensure consistency.
Decomposition: Breaking problems into smaller, manageable tasks (e.g., school system → student records, timetables).
Top-Down Design: Solving high-level problems first, then refining them into subtasks.
Conditions & Decisions: Programs execute based on Boolean expressions (e.g., if age >= 18).
Logical Operators: Use AND, OR, NOT for complex conditions.
Lists & Dictionaries in Decisions: Simplifies condition checking (if username in valid_users).
Error Handling: Prevents crashes by validating inputs.
Concurrency vs. Parallelisation: Concurrency uses time-slicing (e.g., multitasking on one core), while parallelisation runs tasks simultaneously on multiple cores.
Challenges: Deadlocks, race conditions, and overhead in managing multiple tasks.
Real-World Examples: Web servers handling multiple users, video games processing physics, AI, and rendering.
You should be able to do the following, and can expect to be asked to do these things in the EOU assessment:
Focus on the most important details and ignore unnecessary ones.
Use abstraction to solve problems and design systems.
Understand different types of abstraction, like procedural and data abstraction.
Identify the inputs, processes, and outputs of a problem and express this as a IPO table.
Recognize preconditions needed for a program to run correctly.
Understand caching and how it improves performance.
Use reusable code to save time and effort.
Break big problems into smaller steps (decomposition).
Plan solutions using Top-Down Design (starting from the big picture and working down to details).
Use IF statements and Boolean logic to make decisions in programs.
Apply AND, OR, and NOT to create complex conditions.
Express algorithms with flowcharts, pseudocode, and python code.
Use lists and dictionaries to make decision-making easier.
Handle errors to prevent program crashes.
Understand the difference between concurrency (switching between tasks) and parallelisation (doing tasks at the same time).
See how concurrency is used in real life (e.g., web browsers, multitasking).
Recognize problems like deadlocks and race conditions when running multiple tasks at once.
Explain the concept of abstraction and describe how it is used in software development. Provide an example where abstraction simplifies a real-world system. (6 marks) (2.1 Thinking Abstractly, 2.3 Thinking Procedurally)
A weather app displays temperature, humidity, and wind speed but does not show complex atmospheric calculations.
Explain how this is an example of representational abstraction. (3 marks)
Why is it important for software systems to use representational abstraction? (3 marks)
(2.1 Thinking Abstractly, 2.2 Thinking Ahead)
A supermarket system categorizes all items (e.g., milk, apples, cereal) under "products."
Describe how abstraction by generalisation is used in this scenario. (4 marks)
Explain one benefit of using generalisation when designing a system. (2 marks)
(2.1 Thinking Abstractly, 2.3 Thinking Procedurally)
A car rental system allows customers to book vehicles online without knowing how the internal database processes the request.
Explain how information hiding is applied in this system. (4 marks)
Why is information hiding important in software development? (3 marks)
(2.1 Thinking Abstractly, 2.4 Thinking Logically)
You are designing a ticket booking system. Before implementation, you define the inputs, processes, and outputs.
Why is it important to identify inputs and outputs before writing the program? (4 marks)
Give an example of an input, a process, and an output in this system. (3 marks)
(2.2 Thinking Ahead, 2.3 Thinking Procedurally)
A program calculates the square root of a number entered by the user.
Explain why a precondition is necessary for this function. (3 marks)
Write a Python code snippet that includes a precondition to check for valid input. (3 marks)
(2.2 Thinking Ahead, 2.4 Thinking Logically)
A password validation system checks if a password is at least 8 characters long and contains at least one number.
Write a Python function that implements this logic. (4 marks)
Explain how logical operators are used in your solution. (3 marks)
(2.4 Thinking Logically, 2.5 Thinking Concurrently)
A banking system allows multiple users to transfer money at the same time.
Describe a potential race condition that could occur in this system. (4 marks)
Explain how locking mechanisms or synchronization could prevent this issue. (4 marks)
(2.5 Thinking Concurrently, 2.4 Thinking Logically)
A web server handles multiple user requests at the same time. Some tasks share resources, while others run independently.
Explain the difference between concurrency and parallelisation. (4 marks)
Give an example of when a web server might use each technique. (4 marks)
(2.5 Thinking Concurrently, 2.3 Thinking Procedurally)
A robotic vacuum cleaner must decide where to move next based on sensor data. The system must handle multiple tasks at once: detecting obstacles, planning movement, and adjusting suction power.
Identify and describe two computational thinking techniques used in this system. (6 marks)
(2.1 Thinking Abstractly, 2.2 Thinking Ahead, 2.5 Thinking Concurrently)
A self-driving car needs to navigate roads, detect objects, and plan routes while processing real-time data.
Identify and explain three computational thinking techniques that the car's software must use. (6 marks)
(2.1 Thinking Abstractly, 2.2 Thinking Ahead, 2.5 Thinking Concurrently)
Activity 1: Pass or Fail?
Ask the user for their exam score.
If the score is 50 or more, print "You passed!". Otherwise, print "You failed.".
Add an "Excellent!" message for scores 80 or more.
Activity 2: Even or Odd?
Ask the user for a number.
Print "Even" if the number is even, otherwise print "Odd".
Activity 3: Simple Login System
Ask for a username and password.
If the username is "admin" and the password is "password123", print "Access granted.".
Otherwise, print "Access denied.".
Make the password case insensitive.
Activity 4: Guess the Number
Ask the user to guess a number between 1 and 10.
If correct, print "Correct!". Otherwise, print "Wrong, try again!".
Tell the user if their guess is too high or too low.
Activity 5: Shopping Discount
Ask for the total amount spent.
If $50 or more, apply a 10% discount.
If $100 or more, apply a 20% discount.
Print the discount and final price.
Activity 6: Traffic Light
Ask the user to enter "red", "yellow", or "green".
Print "Stop!", "Slow down!", or "Go!" accordingly.
Ignore uppercase/lowercase differences.
Activity 7: Weather App
Ask for the temperature in Celsius.
If 30°C or more, print "It's hot!".
If below 15°C, print "It's cold!".
Otherwise, print "The weather is nice.".
Add "Freezing!" for negative temperatures.
Activity 8: Multiples of 5
Ask the user for a number.
Print "Multiple of 5" if true, otherwise print "Not a multiple of 5".
Activity 9: Rock, Paper, Scissors
Ask the user for "rock", "paper", or "scissors".
Check if their choice is valid.
Make the computer choose randomly.
Compare choices and decide the winner.
Activity 10: Speed Limit Check
Ask for the driving speed.
If over 60 km/h, print "Slow down!".
If 80 km/h or more, print "Fine issued!".
Otherwise, print "You are driving safely.".
Activity 11: Age Group Classifier
Ask the user for their age.
Classify them into:
"Child" (0-12)
"Teenager" (13-19)
"Adult" (20-64)
"Senior" (65+)
Activity 12: Simple Chatbot
Ask "How are you feeling today?"
If "happy", print "That's great!".
If "sad", print "Hope your day gets better.".
Otherwise, print "Thanks for sharing!".
Accept similar words like "good" for "happy".