Course Lecture Note
On
Problem Solving (COS 102)
Lecturers In charge: Mr. Womiloju A.A.
Mrs. Akano I.A.
Mr. Orisadare A.E.
1
Course Information
Course Code: COS 102
Course Status: Core
Course Units: 3.0
Level: 100-Level
Departments: Computer Science, Cybersecurity Software Engineering,
Information and Communication Technology (ICT), Computer Science Education,
Physics Education, Mathematics Education and Mathematics.
Learning Outcomes
At the end of this course, students should be able to:
1. explain problem solving processes;
2. demonstrate problem solving skills;
3. describe the concept of algorithms development and properties of algorithms;
4. discuss the solution techniques of solving problem;
5. solve computer problems using algorithms, flowcharts, pseudocode; etc.; and
6. solve problems using programming language using C, PYTHON, etc.
Course Contents
1. Introduction to the core concepts of computing.
2. Problems and problem-solving.
3. The identification of problems and types of problems (routine problems and non-routine
problems).
4. Method of solving computing problems (introduction to algorithms and heuristics).
5. Solvable and unsolvable problems.
6. Solution techniques of solving problems (abstraction, analogy, brainstorming, trial and
error, hypothesis testing, reduction, literal thinking, meansend analysis, method of focal
object, morphological analysis, research, root cause analysis, proof, divide and conquer).
7. General Problem-solving process.
8. Solution formulation and design: flowchart, pseudocode, decision table, decision tree.
9. Implementation, evaluation and refinement. Programming in C, Python etc.
Lab Work: Use of simple tools for algorithms and flowcharts; writing pseudocode; writing
assignment statements, input-output statements and condition statements; demonstrating simple
programs using any programming language (Visual Basic, Python, C).
2
LESSON ONE
Introduction to the Core Concepts of Computing
1.1 Basic Concepts of Computing
Trends in the world tech-hub today are computing which refers to as the study and application of
how computers process, store, and communicate information. Computing is vast improving our
way of life posing a great problem solving future to both current and future generations.
Otherwise, we describe Computing as the systematic manipulation of symbols in the concept of
designing, creating, constructing a solution to a well defined problem. It encompasses both
hardware (the physical parts of computers) and software (the programs and operating systems).
For any problem to be well-defined must possess the under-listed characteristic:
• It must have an effectively computable operations
• It must be well-order
• It must have unambiguous operations
• It must halt in a finite amount of time (i.e., must begin and end)
1. Data and Information
Data: Raw facts and figures without context (e.g., "25", "Blue").
Information: Data that has been processed and given meaning (e.g., "The temperature is
25°C").
2. Hardware and Software
Hardware: The physical components of a computer (CPU, memory, hard drive, etc.).
Software: The instructions that tell the hardware what to do (applications, operating
systems).
3. Input, Process, Output, Storage (IPOS)
Input: Data entered into the computer (keyboard, mouse).
Process: The computer's processor (CPU) manipulates the data.
Output: The results of processing are displayed (monitor, printer).
Storage: Data is saved for future use (hard drive, SSD, cloud).
4. Programming and Algorithms
Programming: Writing code to instruct computers (using languages like Python, Java).
Algorithm: A step-by-step set of instructions to solve a problem or perform a task.
5. Operating Systems and Applications
3
Operating System (OS): Manages computer hardware and software (Windows, macOS,
Linux).
Applications: Software designed for end users (web browsers, word processors).
6. Networks and the Internet
Networks: Systems that connect computers to share resources (LAN, WAN).
Internet: A global network of networks that allows data exchange and communication.
7. Cybersecurity
Protecting computer systems and networks from theft, damage, or unauthorized access.
8. Artificial Intelligence and Machine Learning
AI: Making machines simulate human intelligence.
Machine Learning: Training computers to learn from data and improve over time.
4
LESSON TWO
Problem and Problem Solving
2.1 What is a Problem?
A problem can be defined as a situation in which there is a gap between the current state and the
desired state. It represents a challenge that needs to be addressed or overcome. In computing,
problems often arise when there is a need to perform specific tasks or processes that require
efficient methods for solution.
• Problem Domain: The area of focus where the problem exists. For example, in software
development, the problem domain might involve issues like optimizing code performance
or ensuring software security.
• Problem Statement: A clear description of the problem that needs solving, outlining the
objective, constraints, and any relevant parameters.
2.2 Types of Problems
In problem-solving, understanding the type of problem you're dealing with is crucial to finding
the right approach.
• Routine Problems: These are problems that have a well-established solution and are
often repeated. For instance, sorting a list of numbers, performing basic arithmetic
operations, or searching for an item in a database are all routine problems.
• Non-Routine Problems: These are unique and often complex problems that do not have
straightforward solutions. They may require creative thinking, new algorithms, or trial-
and-error methods. Examples include designing a new algorithm, developing software
systems, or solving optimization problems.
2.3 Problem Solving in Computing
Problem solving in computing involves applying systematic methods to find solutions for
different types of problems. It requires breaking down a problem into smaller, manageable parts,
identifying possible solutions, testing them, and evaluating their effectiveness.
The Problem Solving Process
The problem-solving process is a systematic approach to solving problems in computing. It
involves several stages:
• Problem Identification: Understanding and defining the problem is the first step. This
includes analyzing the problem’s context, gathering necessary information, and ensuring
you understand the requirements.
• Exploration and Discovery: This involves exploring various potential approaches and
gathering knowledge related to the problem.
5
• Solution Design: In this phase, possible solutions are formulated, and different methods
are tested.
• Solution Implementation: The chosen solution is implemented in code or through a
computational model.
• Testing and Evaluation: The solution is tested under various conditions to check if it
works correctly and meets the requirements.
• Refinement and Optimization: Once a solution is found, it is often refined or optimized
to ensure it performs efficiently, especially for larger datasets or more complex problems.
2.4 Why is Problem Solving Important in Computing?
Problem-solving is a fundamental skill in computing because computers are designed to
automate tasks, process large amounts of data, and solve problems efficiently. Whether it's
through designing a new algorithm, debugging code, or creating software systems, problem-
solving skills are essential to success in the field.
• Efficiency: Problem-solving allows programmers to find the most efficient solutions,
reducing time and resource consumption.
• Innovation: By solving unique or non-routine problems, programmers and computer
scientists can innovate and push the boundaries of technology.
• Adaptability: Problem-solving helps individuals to adapt to new challenges and change,
such as dealing with new types of problems that may arise in the future.
2.5 Common Approaches to Problem Solving
Different methods can be applied when solving computing problems, and these approaches can
be mixed depending on the nature of the problem. Some common methods include:
• Algorithmic Thinking: Breaking down problems into steps that can be solved
algorithmically. This approach emphasizes logical steps, often leading to deterministic
solutions.
• Heuristic Approaches: Using experience-based techniques for problem-solving, which
may not always guarantee the optimal solution but are effective for complex or
ambiguous problems. For example, heuristic search methods in AI.
• Trial and Error: This approach involves trying different solutions until a satisfactory
one is found. While not always optimal, it is often used in exploratory phases or for
problems with no known solution.
6
LESSON THREE
3.1 Identification of Problems and Types of Problems
Identifying a problem is the crucial first step in the problem-solving process. Proper
identification ensures that you understand what needs to be solved, its constraints, and the
objectives to be achieved. Often, the problem will arise from a situation that is either inefficient,
ineffective, or incomplete.
• Symptoms vs. Root Cause: It's important to distinguish between symptoms (the
observable effects) and the root cause (the underlying issue). In computing, it’s common
to focus on symptoms, such as a slow-running program, without identifying the
underlying cause, like inefficient algorithms or insufficient hardware resources.
• Defining the Problem Statement: A clear and concise problem statement helps guide
the rest of the problem-solving process. For example, "Improve the sorting speed of an
algorithm used to sort large datasets" provides specific context to guide the search for a
solution.
3.2 Routine Problems
Routine problems are well-defined issues with established solutions or methods. These types of
problems occur frequently and often have simple, efficient solutions. In computing, routine
problems are often the result of repetitive tasks that need automation or optimization.
Characteristics of Routine Problems:
• Predictability: The problem is well-understood, and the outcome of the solution is
predictable.
• Repetitive: It arises frequently in similar contexts.
• Simple Solutions: Solutions are typically known and well-documented.
Examples in Computing:
• Sorting a list of numbers using well-known algorithms like Bubble Sort or
QuickSort.
• Searching for a specific value in an array using a linear or binary search.
• Basic file manipulation tasks such as reading, writing, or copying files.
Approaches for Solving Routine Problems:
• Algorithmic Solutions: Routine problems are often tackled using well-established
algorithms.
• Automation: Since routine problems are repetitive, automating them with a program can
save significant time and effort.
• Optimization: For routine problems, solutions can often be optimized to improve
performance, for example, using more efficient sorting algorithms.
7
3.3 Non-Routine Problems
Characteristics of Non-Routine Problems:
• Novelty: These problems often arise in new or untested contexts.
• Complexity: They usually require more advanced thinking, as the solution may not be
immediately obvious.
• Unpredictability: The outcome is not easily predicted, and several solutions might be
considered and tested.
Examples in Computing:
• Designing an entirely new software system or application.
• Developing algorithms for new types of data or environments (e.g., quantum computing
or artificial intelligence).
• Solving optimization problems with multiple conflicting objectives, such as resource
allocation in complex systems.
Approaches for Solving Non-Routine Problems:
• Heuristics: Non-routine problems are often solved using heuristic approaches—rules of
thumb that help guide the search for a solution, even if the exact solution cannot be
guaranteed.
• Creative Problem Solving: Brainstorming, analogy, and lateral thinking are often
applied to generate innovative solutions.
• Collaborative Problem Solving: Due to their complexity, non-routine problems may
require collaboration with experts or interdisciplinary approaches.
• Trial and Error: Since non-routine problems may have no clear path to a solution, trial
and error might be used to explore possible solutions.
• Abstraction and Decomposition: Breaking the problem into smaller, more manageable
parts or simplifying the problem can help to focus on key aspects of the problem.
Examples of Non-Routine Problems in Computing:
• AI Model Development: Creating and refining AI models that can perform new types of
tasks, such as natural language processing, autonomous driving, or decision-making in
complex environments.
• Software Engineering for New Domains: Developing software solutions for entirely
new fields, such as blockchain technology, or addressing the needs of emerging
technologies like virtual reality or augmented reality.
• Performance Optimization: Identifying bottlenecks in large-scale systems or distributed
computing environments and finding creative ways to optimize performance beyond
known techniques.
• Transition from Routine to Non-Routine Problems
As computing advances, routine problems often evolve into non-routine ones due to
increasing complexity. For example, a simple sorting problem may grow into a large-
scale optimization issue in the context of Big Data, requiring novel approaches to ensure
efficiency.
8
9
LESSON FOUR
Solvable and Unsolvable Problems and Solution Techniques
Solvable and Unsolvable Problems
4.1 What is a Problem?
A problem in computing is a question that requires a computational solution or decision, usually
involving input and expected output.
4.2 Solvable Problems
These are problems for which an algorithm exists that:
Takes a finite input
Performs a sequence of well-defined steps
Produces the correct output
Halts after a finite number of steps
Examples:
Sorting numbers (e.g., Bubble Sort, Merge Sort)
Searching in a list
Solving quadratic equations
Calculating factorial of a number
Key Attributes:
Well-defined input and output
Deterministic procedures
Verifiable solution
4.3 Unsolvable Problems
These are problems for which no algorithm can solve all instances of the problem correctly and
halt in a finite amount of time.
Famous Example: The Halting Problem
10
i. Given a computer program and an input, determine whether the program halts or runs
forever.
ii. Proven to be unsolvable by Alan Turing in 1936.
Other Examples:
Entscheidungsproblem (Decision problem)
General theorem proving
Certain optimization problems under constraints
Characteristics:
No general solution exists
May involve infinite loops or undecidable logic
Can only be partially solved or approximated
4.4 Importance in Computer Science
Understanding these problems helps:
Recognize computational limits
Avoid wasting resources on unsolvable tasks
Develop approximation or heuristic solutions where exact solutions are impossible
4.5 Solution Techniques for Solving Problems
Below are techniques used in the problem-solving process. These can be combined depending on
the nature of the problem.
1. Abstraction: Focusing on essential details and ignoring irrelevant information.
Example: When designing a student database, abstract away physical features and focus on
name, ID, course, etc.
Purpose: Simplifies complex systems.
2. Analogy: Solving a new problem using the solution to a similar, previously solved problem.
11
Example: Designing a hotel booking system using concepts from a previously designed library
booking system.
3. Brainstorming: Generating a wide range of ideas or solutions in a group setting without
immediate judgment.
Use Case: Useful during the early stages of problem identification.
4. Trial and Error: Attempting multiple solutions until a workable one is found.
Example: Guessing a password through multiple attempts.
Limitation: Inefficient for large or complex problems.
5. Hypothesis Testing: Making an assumption and testing it through experimentation or
simulation.
Example: If a network is slow, hypothesize that a specific server is the bottleneck and test it.
6. Reduction: Breaking a large problem into smaller, more manageable sub-problems.
Example: Solving a large matrix by reducing it to smaller sub-matrices.
7. Literal Thinking: Solving a problem by interpreting it in its most direct or literal form.
Example: Solving a riddle by taking its words at face value rather than metaphorically.
8. Means-End Analysis: Identifying the difference between the current state and the goal state
and taking steps to reduce that difference.
Steps:
Identify current state
Define end goal
Break into subgoals
Solve subgoals
Example: In chess, planning moves to checkmate by reducing the opponent's options.
12
9. Method of Focal Object: Taking unrelated objects or ideas and forcing connections between
them.
Use Case: Useful in innovation and product design.
Example: Combining a camera and phone to create a smartphone.
10. Morphological Analysis: Structuring a complex problem into multiple dimensions or
variables and systematically exploring all combinations.
Example: Designing a vehicle by analyzing fuel type, size, and transmission.
11. Research: Gathering information from reliable sources to inform your understanding of the
problem.
Use Case: Before developing a new app, research existing solutions and user needs.
12. Root Cause Analysis: Finding the fundamental cause of a problem rather than its symptoms.
Technique: "5 Whys" – keep asking "why" until the root is identified.
Example:
Problem: Website is slow.
Why? Too many requests.
Why? Poor caching.
Why? Misconfigured server...
13. Proof: Using logic or mathematics to verify the correctness of a solution.
Example: Proving that a sorting algorithm always returns a sorted array.
14. Divide and Conquer: Dividing a complex problem into independent parts, solving them
individually, and combining results.
Examples:
Merge Sort
Binary Search
13
Summary Table of Techniques
Technique Main Purpose Best For
Abstraction Simplify complex systems System design, modeling
Analogy Apply past solutions to new problems Design, architecture
Brainstorming Generate multiple ideas Initial planning, group work
Trial and Error Find solution through attempts Simple or exploratory problems
Hypothesis Testing Validate assumptions Debugging, diagnostics
Reduction Make problem manageable Complex software, algorithms
Literal Thinking Take direct approach Puzzles, literal challenges
Means-End Analysis Reduce gap to goal Planning, strategy
Focal Object Method Foster creativity Innovation, product design
Morphological Analysis Explore all options Engineering, design
Research Gather facts Analysis, preparation
Root Cause Analysis Fix the real issue Troubleshooting, optimization
Proof Validate correctness Math-based problems, logic
Divide and Conquer Modular problem solving Recursion, algorithms
Class Activities
Case Study: Use root cause analysis to troubleshoot a failed software deployment.
Group Work: Apply brainstorming and analogy to design a basic mobile app.
Lab: Implement a divide-and-conquer algorithm in Python (e.g., Merge Sort).
Assignment: Write a short paper on one unsolvable problem in computing and its implications.
14
Recap and Conclusion
Understanding the distinction between solvable and unsolvable problems is foundational in
computer science. Applying appropriate solution techniques equips students to tackle real-world
challenges effectively.
Assessment Questions
1. What makes a problem solvable in computing?
2. Give an example of an unsolvable problem and explain why it is unsolvable.
3. Discuss how divide and conquer and abstraction work together in algorithm design.
4. Compare and contrast brainstorming and the method of the focal object in creative problem-
solving.
15
LESSON FIVE
General Problem-Solving
5.1 Problem in Computing
A problem in computing is a question that requires a computational solution or decision, usually
involving input and expected output. There are two major divisions in problem solving to be
address, namely Solvable and Unsolvable Problems.
5.2 Solvable Problems
These are problems for which an algorithm exists that:
Takes a finite input
Performs a sequence of well-defined steps
Produces the correct output
Halts after a finite number of steps
Examples:
Sorting numbers (e.g., Bubble Sort, Merge Sort)
Searching in a list
Solving quadratic equations
Calculating factorial of a number
Key Attributes:
Well-defined input and output
Deterministic procedures
Verifiable solution
5.3 Unsolvable Problems
These are problems for which no algorithm can solve all instances of the problem correctly and
halt in a finite amount of time.
Famous Example: The Halting Problem
16
i. Given a computer program and an input, determine whether the program halts or runs
forever.
ii Proven to be unsolvable by Alan Turing in 1936.
Other Examples:
Entscheidungs problem (Decision problem)
General theorem proving
Certain optimization problems under constraints
Characteristics:
No general solution exists
May involve infinite loops or undecidable logic
Can only be partially solved or approximated
5.4 Importance in Computer Science
Understanding these problems helps:
Recognize computational limits
Avoid wasting resources on unsolvable tasks
Develop approximation or heuristic solutions where exact solutions are impossible
5.5 Problem Solving Process / Procedure in Computer Science
This is a structured approach to transforming a problem into a working solution (typically via a
program). It involves logical analysis, design, and implementation.
1.1 Key Steps in the Problem-Solving Process
17
Step Description
Clearly identify and understand the problem. Ask: What is the problem?
1. Problem Definition
What are the constraints? What is the desired output?
Break the problem into smaller parts. Determine input, output,
2. Analyze the Problem
constraints, and relevant data.
3. Generate and Explore possible algorithms or methods of solving the problem.
Evaluate Solutions Evaluate their feasibility.
Use tools like flowcharts, pseudocode, or diagrams to outline the
4. Design the Solution
process.
5. Implement the Convert the design into actual code using programming languages like
Solution Python or C.
6. Test and Debug Test for correctness with sample data. Fix any bugs or errors.
7. Document and Write documentation and ensure the code is maintainable for future
Maintain improvements.
18
LESSON SIX
Solution Formulation and Design
Solution design is about converting ideas into structured representations that computers can
follow. Tools like flowcharts, pseudocode, decision tables, and decision trees are essentially used
in formulating and designing problem solutions in computing.
6.1 Flowcharts
Definition: A flowchart is a diagrammatic representation of an algorithm using symbols to show
the flow of control.
Common Flowchart Symbols
Symbol Name Purpose
Terminator Start/End of a process
Input/output For input and output operation
Process Performs an operation
Decision Represents a decision or condition (Yes/No)
Arrow Shows flow direction
Connector For page connector
Predefined Process Define and Initialize values
Preparation For gathering data elements
Data Repository Stores data/information
Delay Ignite little process delay or process spooling
19
Example: Sum of Two Numbers
Start
Input a,b
c=a+b
Print c
Stop
6.2 Pseudocode
Definition: Pseudocode is a plain English-like representation of an algorithm that outlines the
logic without following the syntax of a programming language.
Characteristics
Language-independent
Easy to read
Focuses on logic rather than syntax
Example: Write a pseudocode to add two numbers
# Prompt the user to enter the first number
number1= float(input(“Enter the first number: ”))
# Prompt the user to enter the second number
number2= float(input(“Enter the second number: ”))
# Calculate the sum
sum= number1 + number2
# Display the result
print(“The sum is: ”, sum)
20
Notes:
float( ) is used so it can handle both integer and decimals.
input ( ) gets user as a string, and float( ) converts it to a number.
Print ( ) displays the result.
6.3 Decision Table
Definition: A decision table is a tabular method for representing complex decision logic. It
consists of conditions, rules, and actions.
Structure
Condition 1 Condition 2 Rule 1 Rule 2
A>B B>A T F
Action Print A Print B
Use Case
When multiple conditions determine actions, decision tables help organize and document them
systematically.
6.4 Decision Tree
Definition: A decision tree is a tree-like structure that models decisions and their possible
outcomes. It’s a graphical representation of conditional logic.
Structure
Root Node: The starting point (first decision)
Branches: Represent possible outcomes
Leaf Nodes: Final actions or decisions
Example: Eligibility for Voting
[Age >= 18?]
21
/ \
Yes No
/ \
[Are you registered?] [Not eligible]
/ \
Yes No
/ \
[Eligible] [Register first]
6.5 Comparative Summary of Solution Tools
Tool Purpose Best Used When…
Flowchart Visualizing step-by-step logic Teaching, initial planning
Pseudocode Writing logic in natural language Transitioning to programming
Decision Table Tabulating multiple conditions Systematic rule-based decisions
Decision Tree Visualizing conditional paths Simple to moderate conditional flows
Practical Example
Problem: Write an algorithm to check if a number is even or odd.
Pseudocode
START
INPUT number
IF number MOD 2 == 0 THEN
PRINT "Even"
22
ELSE
PRINT "Odd"
ENDIF
END
Flowchart Steps
Start
Input number
Check if number MOD 2 == 0
If Yes: Print "Even"
If No: Print "Odd"
End
Class Activities
Lab: Create flowcharts for a temperature conversion (Celsius to Fahrenheit).
Group Exercise: Develop a decision table for student grading (A, B, C, etc.).
Homework:
1. Write pseudocode and flowchart for a basic ATM withdrawal process.
2. Discussion hen is a decision tree better than a decision table?
Summary
Problem-solving requires a systematic process from problem definition to implementation.
Solution formulation tools help translate abstract ideas into executable logic.
Flowcharts and pseudocode are foundational tools for programming.
23
Decision tables and trees help manage complex conditions effectively.
Exercise:
Activity 2: Assessment Questions
1. What is the purpose of a flowchart in problem-solving?
2. Give one difference between pseudocode and a decision tree.
3. Describe the general steps in the problem-solving process in computing.
4. Explain how flowcharts and pseudocode aid the process of program development.
Activity 2: Practical
1. Design a flowchart to compute the factorial of a number.
2. Create a decision tree to determine the risk level of a bank loan applicant.
3. Would you like this content formatted into slides, worksheets, or lab instructions?
4. Identify the tool used in the sample (Find Maximum of Two Numbers) problem solution
below and transform it into its equivalent flowchart
START
INPUT A, B
IF A > B THEN
MAX = A
ELSE
MAX = B
ENDIF
PRINT MAX
END
24