0% found this document useful (0 votes)
48 views

CSC 102 Lecture 2

Computer science
Copyright
© © All Rights Reserved
We take content rights seriously. If you suspect this is your content, claim it here.
Available Formats
Download as PDF, TXT or read online on Scribd
0% found this document useful (0 votes)
48 views

CSC 102 Lecture 2

Computer science
Copyright
© © All Rights Reserved
We take content rights seriously. If you suspect this is your content, claim it here.
Available Formats
Download as PDF, TXT or read online on Scribd
You are on page 1/ 15

CSC 102

LECTURE 2
Introduction to the core concepts of
computing: Problems and problem-solving.

DR. ZUBAIR ADAM


LAGOS STATE UNIVERSITY, OJO LAGOS
1
OVERVIEW

 Introduction to the core concepts of computing: Problems and problem-solving.


 The identification of problems and types of problems (routine problems and non-routine
problems).
 Method of solving computing problems (introduction to algorithms and heuristics).
 Solvable and unsolvable problems.
 Solution techniques of solving problems (abstraction, analogy, brainstorming, trial and
error, hypothesis
 Testing, reduction, literal thinking, means end analysis, method of focal object,
morphological analysis, research, root cause analysis, proof, divide and conquer).
 General Problem-solving process.
 Solution formulation and design: flowchart, pseudocode, decision table, decision tree.
Implementation, evaluation and refinement.
 Programming in C++, Python etc 2
Problem-solving Strategy

 A problem-solving strategy is a plan used to find a solution or overcome a


challenge.
 Different strategies have different action plans associated with them.
 For example, a well-known strategy is trial and error.
 Each problem-solving strategy includes multiple steps to provide you with
helpful guidelines on how to resolve a business problem or industry
 Problem Solving: Involves logical reasoning, interpretation, abstract thinking,
and creativity.
 Methods of Problem-solving: Introspection, simulation, computer modelling,
and experimentation. 3
Importance of Understanding Multiple
Problem-solving Strategies
 Problems themselves can be classified into two different categories:
 ill-defined
 well-defined problems.
 Ill-defined problems represent issues that do not have clear goals, solution
paths, or expected solutions
 Well-defined problems have specific goals, clearly defined solutions, and
clear expected solutions.
 Importance of understanding multiple problem-solving strategies:
 Different problems require different approaches.
 Mastering multiple strategies helps in selecting the right approach.
 Enhances critical thinking skills and problem-solving speed 4
Trial and Error

 Definition: Trying different solutions and ruling out those that don’t work.
 Example: Fixing a broken printer by checking ink levels, paper tray, or
connections.
 Characteristics:
 Useful with limited options.
 Not time-efficient but commonly used.

5
Algorithm and Heuristic
 Algorithm:
• Step-by-step problem-solving formula (e.g., recipes, search engine processes).
• Always produces the same result when followed exactly.
 Heuristic:
• General problem-solving framework or "rule of thumb“ (a conventional way of doing things).
• Saves time and energy but not always the most rational method.
 Types of Heuristics:
• Working Backwards:
• Focus on the end result to solve the problem.

• Breaking Down Tasks:


• Large tasks are divided into smaller, manageable steps. 6
Means-Ends Analysis

 Definition: Analyzing actions in smaller steps to achieve the goal.


 Example: Tower of Hanoi puzzle: The Tower of Hanoi problem consists of 3 rods and n discs of
different sizes. Roughly, the goal of the problem is to move the stack of discs from the leftmost rod
to the rightmost rod.
 Tower of Hanoi Rules:
1. Move only one disk at a time.
2. Place disks on top of another stack or an empty rod.
3. No larger disk on top of a smaller disk.
 Solutions:
 Iterative: Moving pieces systematically.
 Recursive: Breaking down into sub-problems.
 Non-recursive: Recognizing regularities.
 Binary and Gray-code: Using binary notation.
 Graphical Representations: Visual models to find efficient solutions. 7
Tower of Hanoi - Example and Methods

 Example:

With 3 disks, the puzzle can be solved in 7 moves.


Minimal moves required: 2n−1, where n is the number of disks.
For 14 disks: 214−1=16,383 moves.
 Iterative Solution:
 Move the smallest pieces systematically.
 Recursive Solution:
 Break down the puzzle into sub-problems.
 Non-recursive Solution:
 Recognize regularities, e.g., every odd move involves the smallest disk.
 Binary and Gray-code Solutions:
 Use binary notation to represent disk moves.
 Graphical Representations:
 Visual models, such as the unidirectional, pyramid-shaped graph. 8
Other Problem-solving Strategies

 Other Problem-solving Strategies


• Past Experience:
• Adapt solutions from similar past situations.
• Bring in a Facilitator:
• Enhance group efficiency and collaboration.
• Decision Matrix:
• Rank solutions based on factors like timeliness, risk, and effectiveness.
• Peer Assistance:
• Gain new perspectives and unique solutions.
• Step Away:
• Take a break to refresh and refocus. 9
Computational Approaches for Solving Problems
Brute-force Approach

• Characteristics:
• Lack of sophistication; takes the most direct or obvious route.
• Does not minimize the number of operations required.
• Example:
• Searching through a list of candidates to find a desired object.
• Analogy: Finding a frozen pie in an unfamiliar grocery store by searching each aisle.
• Padlock Example:
• A padlock with 4 digits (0-9).
• Forgot combination: try all possible combinations from 0000 to 9999.
• Worst case: 104=10,00010^4 = 10,000104=10,000 tries.

10
Computational Approaches for Solving Problems
Divide and Conquer Approach

• Definition:: Problem is solved recursively in three steps: Divide, Conquer, and Combine.
• Divide: Split the problem into smaller sub-problems.
• Conquer: Solve the sub-problems recursively.
• Combine: Merge solutions of sub-problems to solve the whole problem.
• Example:
• Merge Sort Algorithm:
• 1. Divide an array into two halves.
• 2. Recursively sort each half.
• 3. Combine the sorted halves.
 Advantages
• Solves difficult problems by dividing into solvable sub-problems.
• Can lead to discovering efficient algorithms.
• Uses memory caches effectively.
• Suited for parallel execution.
 Disadvantages
• Recursion can be slow.
• Sometimes more complicated than iterative approaches.
11
Computational Approaches for Solving Problems
Dynamic Programming Approach

• Definition:
• Similar to divide-and-conquer but reuses results of sub-problems.
• Bottom-up technique; solves smallest sub-problems first.
• Example:
• Fibonacci Series:
• Sequence: 0, 1, 1, 2, 3, ...
• Each term is the sum of the two preceding ones.

 Recursion vs Dynamic Programming


• Dynamic programming optimizes by avoiding recalculating the same results.
• Recursive algorithms like Merge Sort can't use dynamic programming due to lack of
overlapping sub-problems.
12
Computational Approaches for Solving Problems
Greedy Algorithm Approach

 Definition:
• At each step, makes the choice with the smallest immediate cost.
• Does not look ahead to find the global optimum.
• Characteristics:
• Simple and efficient for certain optimization problems.
 Comparison
• Dynamic Programming:
• Finds optimal solution by solving sub-problems and combining results.
• Greedy Algorithms:
• Look for locally optimal solutions, hoping to find a global optimum.
13
Computational Approaches for Solving Problems
Randomized Approach

 Randomized Approach
• Definition:
• Depends on input data and values from a random number generator.
• Often more effective when determining the optimal choice is difficult.
• Applications:
• Ensures fairness in game-theoretic situations.
• Widely used in computer security and games.

14
Discussion

15

You might also like

pFad - Phonifier reborn

Pfad - The Proxy pFad of © 2024 Garber Painting. All rights reserved.

Note: This service is not intended for secure transactions such as banking, social media, email, or purchasing. Use at your own risk. We assume no liability whatsoever for broken pages.


Alternative Proxies:

Alternative Proxy

pFad Proxy

pFad v3 Proxy

pFad v4 Proxy