SlideShare a Scribd company logo
z
Maruf Farhan
z
z
Problem Solving as
a Computer
Scientist:
Imagine you’re working in a
tech company, and you
receive a complaint that
the company’s e-
commerce website is
running slow whenever
there are a lot of users
shopping at the same time.
This is a problem, and as a
computer scientist, your job
is to figure out a way to
solve it.
z
The Process of Problem Solving:
1. Analyzing the Problem:
You start by analyzing the issue. Why is the website slowing
down? Is it because of how data is being processed? Is the
database overloaded? Are there inefficient algorithms running
behind the scenes?
2. Designing an Algorithm:
Once you’ve identified the root cause (for example, the
website is not handling large amounts of traffic efficiently), you
need to design a solution. This might involve creating a better
algorithm to manage user traffic or optimizing how the
database queries are handled.
3. Developing a Solution:
You then develop an algorithm that can solve the issue. This
might involve implementing load balancing, which distributes
user traffic across multiple servers, or improving the efficiency
of data retrieval from the database.
z
Not All Problems Have Solutions!
"Not all problems have a solution!". Sometimes, a
problem might be so complex or have limitations (like
hardware, cost, or time) that it’s impossible to find a
perfect solution. In those cases, part of your role is to
decide the best possible solution given the constraints.
Example: Margret Hamilton and Apollo 11
The image in the slide shows Margaret Hamilton, a
computer scientist who helped develop the software for
the Apollo 11 mission. Just like modern computer
scientists, she and her team had to solve complex
problems using algorithms to ensure the mission's
success, knowing that there was no room for error.
z
z
Deriving Algorithms:
Imagine you’re a student taking a course in algorithms, and you’ve
been assigned a project to optimize the performance of an e-
commerce website. The website’s checkout process is slow, and
customers are abandoning their carts. You need to derive an
algorithm that improves the checkout flow.
To tackle this problem, you’ll apply structured methods like Polya’s
Principle and computational thinking to develop an effective
solution.
z
How to Derive Algorithms – Using Polya’s Principle:
Polya’s Principle is a well-known approach to solving problems methodically. It includes the
following steps:
1. Understand the Problem:
Before jumping to a solution, you need to clearly understand what’s causing the delay in the
checkout process. Is it slow database queries? Is it too many steps for the user? What are the
bottlenecks?
Example: You identify that the website is slow due to inefficient payment processing and
unnecessary validation steps.
2. Devise a Plan:
Think about how you can approach the problem. What steps can you take to optimize the
checkout process? Can you reduce the number of steps? Can you cache frequently used data to
reduce the load?
Example: You decide to optimize the database queries, reduce the number of user inputs, and
implement caching for commonly accessed information.
z
How to Derive Algorithms – Using Polya’s Principle:
 Carry Out the Plan:
• Now that you have a plan, you can start writing the algorithm that streamlines the
checkout process. You optimize the query structure, introduce asynchronous
processing for payment, and cache user data.
• Example: You develop an algorithm that reduces the number of database calls,
loads information faster, and only requires necessary inputs during checkout.
 Review and Improve:
• After implementing the solution, test it. Does it solve the problem? If not, what
improvements can be made?
• Example: After testing, you realize the payment gateway still causes delays. You
refine the algorithm further by implementing a payment gateway API that handles
requests more efficiently.
z
Polya’s Principles – A Step-by-Step Guide to Problem Solving:
1. Understand the Problem (Preparation)
Before solving any problem, it’s crucial to fully comprehend the details and constraints. This
phase is all about clarifying and analyzing the problem.
Example Scenario:
Imagine you are tasked with developing an algorithm that helps a delivery company optimize
its routes to save fuel and time.
Key Actions:
Ask Questions: What specific constraints are there? Do we want to minimize travel time,
distance, or fuel usage? Are there traffic or delivery time restrictions?
Define the Problem: You need to minimize travel distance while ensuring that delivery
deadlines are met for all customers.
Identify Constraints: The delivery truck can only carry a certain weight, the route should avoid
toll roads, and all deliveries must be completed within an 8-hour window.
Goal:
By fully understanding the problem, you can set clear objectives. For the delivery company
example, the objective is to reduce the overall distance while adhering to time and weight
constraints.
z
2. Devise a Plan/Strategy to Solve the Problem
 Now that the problem is clearly understood, it’s time to come up with a strategy. Here, you’ll
consider different approaches or algorithms that could solve the problem.
 Key Actions:
• Brainstorm Solutions: In the case of optimizing delivery routes, you might consider using
algorithms like Dijkstra’s algorithm, the Traveling Salesman Problem (TSP), or even heuristic
methods like Genetic Algorithms.
• Choose the Best Strategy: Compare the pros and cons of different strategies. For example, if
the delivery points change daily, a dynamic algorithm like TSP might be more appropriate.
However, if you only need a rough estimate quickly, a heuristic method could be sufficient.
 Goal:
 The goal of this step is to have a clear approach or algorithm in mind. For the delivery route
problem, you decide to use a variation of the TSP algorithm that accounts for time constraints.
z
3. Carry Out the Plan
Now that the plan is in place, it’s time to execute. This step is all about implementing the solution and coding
the algorithm.
Key Actions:
Write the Algorithm: For the delivery route optimization, you begin coding the TSP algorithm, factoring in
traffic and time constraints. You might also use a map API to calculate distances between delivery points.
Test and Debug: Once the algorithm is implemented, you run it with various test cases to ensure it works. In
this case, you might input different sets of delivery addresses to check if the routes are optimized effectively.
Ensure It Meets Constraints: Make sure the algorithm respects the delivery deadlines, maximum truck
weight, and road restrictions.
Goal:
Your goal here is to execute the plan successfully by coding and implementing the solution. At the end of this
step, the delivery route optimization algorithm should work as expected and meet all constraints.
z
4. Look Back (Review the Solution)
Once the solution is implemented, it’s important to review and reflect on how effective it was. This step involves
evaluating the solution’s efficiency and considering potential improvements.
Key Actions:
Evaluate the Solution: Does the algorithm optimize routes as expected? Is it fast enough to calculate routes in
real-time?
Optimize if Necessary: If the solution takes too long to compute or doesn’t fully optimize the routes, you might
need to refine it. For example, you could improve the algorithm's efficiency by using a faster heuristic method or
reducing the complexity of the calculations.
Learn for Future Problems: Consider what went well and what could be improved. Were there any edge cases
you hadn’t considered initially?
Goal:
The final goal is to ensure the solution is optimal and efficient. In the case of the delivery company, this means
the algorithm must consistently optimize routes and handle different scenarios effectively.
z
z
Scenario: Devise a Plan for Optimizing Search Results

Imagine you’re working on a
search engine for a shopping
website. Users complain that
search results take too long to
load, especially when searching
for items with common keywords
(like "shoes"). The problem is
clear, but now you need to
devise a plan to solve it.
Step 1: Ask the Right Questions (Thinking Time)
Before jumping into a solution, you need to ask key
questions that help you evaluate the situation:
• Why are the search results slow? Is it because of
database query inefficiencies?
• How many users are searching at the same
time? Is it causing a traffic bottleneck?
• Are there redundant or irrelevant search results
being processed?
 By asking these questions, you get a better
sense of the problem and what factors need to
be addressed.
z
Scenario: Devise a Plan for Optimizing Search Results
Imagine you’re working on a search
engine for a shopping website. Users
complain that search results take too
long to load, especially when searching
for items with common keywords (like
"shoes"). The problem is clear, but now
you need to devise a plan to solve it.
Step 2: Consider Different Approaches
Once you have a clear understanding, you begin thinking
about possible strategies. This could include:
Caching: Could you implement caching for common searches
so the results load faster without querying the database
repeatedly?
Indexing: Could you optimize the search by indexing the most
frequently searched terms?
Parallel Processing: Should you distribute the search process
across multiple servers to handle more queries
simultaneously?
Each of these techniques has its pros and cons, and choosing
the right one depends on the specific requirements and
constraints of the system.
z
Scenario: Devise a Plan for Optimizing Search Results
Imagine you’re working on a search
engine for a shopping website. Users
complain that search results take too
long to load, especially when searching
for items with common keywords (like
"shoes"). The problem is clear, but now
you need to devise a plan to solve it.
 Step 3: Choose a Strategy
 After evaluating the possible
approaches, you decide to implement
caching. You choose this because
many users search for the same
popular items, and caching these
results would speed up searches for
frequently requested items. This
solution addresses the problem
without overhauling the entire system.
z
z
Carry Out the Plan (Insight)
Key Steps:
Implement the Solution:
Write the code or algorithm based on your plan.
Test as you go to ensure each part works correctly.
Evaluate and Adjust:
Monitor the results of your implementation.
If the plan doesn’t fully solve the problem, tweak or refine your approach.
Learn from Each Attempt:
If an approach doesn’t work, use what you learned to eliminate that option and try another.
Persistence Pays Off:
Keep trying, and eventually, you’ll gain insights that help you reach the solution.
z
Reviewing and Reflecting After Solving a Problem
Let’s say you’ve just
implemented an algorithm to
speed up search results on a
website. Now, it’s time to review
and reflect to ensure that your
solution meets the requirements
and performs well.
Step 2: Can the Solution Be Improved?
Next, think about whether there’s a way to make the
algorithm even better. Could it be faster or simpler?
•Example: You notice that some searches are still
slow when users search for uncommon terms. You
could consider adding an indexing feature to
improve those searches.
Step 3: Fixing Mistakes
If your solution doesn’t fully work, there might be a
small mistake. Instead of starting over, try fixing or
adjusting the current solution.
•Example: During testing, you find a small bug in
how the algorithm handles specific types of queries.
You fix this error, and now the solution works as
expected.
z
Reviewing and Reflecting After Solving a Problem
Let’s say you’ve just
implemented an algorithm to
speed up search results on a
website. Now, it’s time to review
and reflect to ensure that your
solution meets the requirements
and performs well.
Step 4: Is There a Simpler Way?
Sometimes, there might be a simpler or more
efficient way to solve the problem. Consider if
another approach could work better.
•Example: You realize that instead of adding more
complexity, simplifying the database queries could
also speed up the search results.
Step 5: Can This Solution Help in the Future?
Lastly, think about whether the method you used
can be applied to other problems. Could this
algorithm help you solve similar issues in the
future?
•Example: You realize that the caching system you
used could also help with other website features,
like loading product images faster.
z
Top-Down Design in Problem Solving
Imagine you are making a game where players collect coins. At the
end of the game, you need to calculate how many coins each
player has and show the total.
This might sound like a lot to do at once, but by using top-down
design, you can break it into smaller, simpler steps.
z
 What is Top-Down
Design?
 Top-down design means
starting with the big task and
breaking it into smaller
tasks. You handle each
small task one at a time until
the whole problem is solved.
 Step 1: Breaking the Problem into
Smaller Steps
 Let’s say the big task is to count the
total number of coins each player has.
To make this easier, we can break it
down into smaller tasks:
1. Count the coins the player collected.
2. Add any bonus coins they earned.
3. Show the total number of coins.
 Each of these small tasks is much
easier to handle on its own.
z
Step 2: Building and Testing Small Tasks
For each small task, we can create a simple
function. For example:
A function to count the coins collected.
A function to add bonus coins.
A function to show the total.
We test each of these small tasks to make sure
they work before moving on. For example, you
can test if the coin counter is working correctly
before adding the bonus coins.
Why Use Top-Down Design?
•It Makes Things Easier: By focusing
on one small task at a time, the big
problem doesn’t feel so hard.
•Less Confusing: Each small task is
clear and simple.
•Easy to Fix: If something goes wrong,
it’s easier to find where the mistake is.
z
problems
z
Top-Down Design in a University
Registration Program
 Imagine you are tasked with
building a program for
students to register for classes
at a university. This is a big
task with many parts. To make
it easier, we use top-down
design, which helps you
break the large problem into
smaller, more manageable
parts.
z
Top-Down Design in a University
Registration Program
 Imagine you are tasked with
building a program for
students to register for classes
at a university. This is a big
task with many parts. To make
it easier, we use top-down
design, which helps you
break the large problem into
smaller, more manageable
parts.
z
Top-Down Design in a
University Registration
Program
 Imagine you are tasked
with building a program for
students to register for
classes at a university. This
is a big task with many
parts. To make it easier, we
use top-down design,
which helps you break the
large problem into smaller,
more manageable parts.
z
Designing a Simple Calculator Using Top-
Down Algorithm Design
 Imagine you’re building
a simple calculator that
can perform basic
operations like
addition, subtraction,
multiplication, and
division. This is the
main problem you want
to solve. Let’s apply
top-down algorithm
design to break it into
manageable parts.
z
Designing a Simple Calculator Using Top-
Down Algorithm Design
 Imagine you’re building
a simple calculator that
can perform basic
operations like
addition, subtraction,
multiplication, and
division. This is the
main problem you want
to solve. Let’s apply
top-down algorithm
design to break it into
manageable parts.
z
Designing a Simple Calculator Using Top-Down Algorithm Design
 Imagine you’re building a
simple calculator that can
perform basic operations
like addition, subtraction,
multiplication, and division.
This is the main problem
you want to solve. Let’s
apply top-down algorithm
design to break it into
manageable parts.
z
Building a Simple To-Do List App
Imagine you’re creating a to-
do list app. It feels like a big
job, but we can break it down
into small, easy steps using
top-down design.
z
Building a Simple To-Do List App
Imagine you’re creating a to-
do list app. It feels like a big
job, but we can break it down
into small, easy steps using
top-down design.
z
Building a Simple To-Do List App
Imagine you’re creating a
to-do list app. It feels like a
big job, but we can break it
down into small, easy
steps using top-down
design.
z
Building a Shopping Cart Feature Using Top-Down Design
Imagine you’re working on an
online store, and you need to
create a shopping cart where
users can add items, view their
total, and check out. This can
seem like a lot to handle at once,
but with top-down design, you
can break it down into smaller
tasks.
Advantages of Top-Down Design:
1.Breaking the Problem into Parts
You start by breaking the shopping cart task into
smaller tasks, like:
1. Add items to the cart.
2. Show the total price.
3. Check out and process payment.
2.Simplifies the Work
Each smaller task becomes easier to understand
and complete.
3.Reusable Code
Once you’ve built the function to add items to the
cart, you might be able to reuse it in other parts of
the store.
4.Collaboration
Different people can work on each part (like one
person building the "Add Item" feature, another
handling the "Checkout" part).
z
Building a Chat Feature Using Bottom-
Up Methodology
 Imagine you're developing
a chat feature for an app.
Instead of starting with the
entire chat system, the
bottom-up approach
focuses on building the
smallest components first
and gradually combining
them.
Start Small
Begin with the simplest components:
•Create a function to send a message.
•Create a function to receive a message.
Build Up Gradually
After these small components are working:
•Combine the send and receive functions.
•Add features like showing the message history.
Complete the Solution
As each component works, you connect them to form the
entire chat feature. You focus on solving small problems
and gradually build the full chat system.
z
Key Steps of Bottom-Up Design:
1. Identify Basic Components
Start with simple building blocks:
1. Sending a message.
2. Receiving a message.
2. Solve Basic Components
Work on these tasks individually. Ensure:
1. The send message function works alone.
2. The receive message function operates by
itself.
3. Combine Components
After confirming they work individually, combine
them:
1. When a message is sent, it should appear in the
received messages.
1.Repeat and Refine
Keep adding components like:
1. Message history: Combine it with
send/receive to store past messages.
2. User notifications: Add notifications when
new messages are received.
2.Test Incrementally
Test each part (send, receive, history) as you add it to
ensure they work well together.
3.Address the Main Problem
Once all the smaller components work, combine them
to complete the messaging system.
4.Optimise and Document
Improve the system’s performance and document the
components so it's easier to maintain.

More Related Content

PDF
5 Tips to Bulletproof Your Analytics Implementation
PDF
Doing Analytics Right - Designing and Automating Analytics
PDF
7 Cases Where You Can't Afford to Skip Analytics Testing
PPTX
Six Sigma - DMAIC Fundamentals
PPTX
LPP application and problem formulation
PDF
9th Comp Ch 1 LQ.pdf
PPTX
Smart solutions for productivity gain IQA conference 2017
PDF
Chapter_6_Prescriptive_Analytics_Optimization_and_Simulation.pptx.pdf
5 Tips to Bulletproof Your Analytics Implementation
Doing Analytics Right - Designing and Automating Analytics
7 Cases Where You Can't Afford to Skip Analytics Testing
Six Sigma - DMAIC Fundamentals
LPP application and problem formulation
9th Comp Ch 1 LQ.pdf
Smart solutions for productivity gain IQA conference 2017
Chapter_6_Prescriptive_Analytics_Optimization_and_Simulation.pptx.pdf

Similar to Algorithm and data science foundation ISC (20)

PDF
DOCX
14 CREATING A GROUP AND RUNNING A PROJECTIn this chapter, we wil.docx
PDF
Using the DMAIC Process for SEO Projects
PDF
How to Master your Marketing Data - Cody Crumrine, Data Aptitude
DOCX
Improve Your Process Quality with These 7 QC Tools.docx
PDF
Using the DMAIC Process for SEO Projects
PDF
Whitepaper:Barriers to Effective and Strategic SPM Compensation
PPTX
Types of Machine Learning- Tanvir Siddike Moin
PPTX
Business process mapping
PPT
I07 Simulation
PPT
I07 Simulation
PPTX
Lean Manufacturing Projects - Introduction
PPTX
When is a custom app the right choice?
PPTX
When is a custom app the right choice?
PPTX
PQF Overview
PPTX
Real timeanalyticsl oreal
PPTX
case study for sapiens project management
PDF
recommendation = optimization(prediction)
PPTX
Data Science in Python.pptx
PPTX
Challenges-and-Consideration-in-Programming-Logic-and-Design...pptx
14 CREATING A GROUP AND RUNNING A PROJECTIn this chapter, we wil.docx
Using the DMAIC Process for SEO Projects
How to Master your Marketing Data - Cody Crumrine, Data Aptitude
Improve Your Process Quality with These 7 QC Tools.docx
Using the DMAIC Process for SEO Projects
Whitepaper:Barriers to Effective and Strategic SPM Compensation
Types of Machine Learning- Tanvir Siddike Moin
Business process mapping
I07 Simulation
I07 Simulation
Lean Manufacturing Projects - Introduction
When is a custom app the right choice?
When is a custom app the right choice?
PQF Overview
Real timeanalyticsl oreal
case study for sapiens project management
recommendation = optimization(prediction)
Data Science in Python.pptx
Challenges-and-Consideration-in-Programming-Logic-and-Design...pptx
Ad

More from MarufFarhanRigan1 (14)

PPTX
402IT CUL CW2 Sample 1 High ssScore.pptx
PPTX
introduction to linux operating system level 4
PPTX
introduction to operating system level 3
PPTX
week 3 cloud computing northumbria foudation
PPTX
week 5 cloud security computing northumbria foudation
PPTX
week 3 cloud computing northumbria foudation
PPTX
ADST university of Sussex foundation class
PPTX
foundation class python week 4- Strings.pptx
PPTX
python user input slides FOundation program
PPTX
1. Python Indentation sussex isc for oundation
PPTX
University of Wolverhampton Interview.pptx
PPTX
Cyber Security Induction university of UK
PPTX
Week 1 Session 1 - Introduction to Personal Computer.pptx
PPTX
Week 1 Session 1 Networking Coventry University
402IT CUL CW2 Sample 1 High ssScore.pptx
introduction to linux operating system level 4
introduction to operating system level 3
week 3 cloud computing northumbria foudation
week 5 cloud security computing northumbria foudation
week 3 cloud computing northumbria foudation
ADST university of Sussex foundation class
foundation class python week 4- Strings.pptx
python user input slides FOundation program
1. Python Indentation sussex isc for oundation
University of Wolverhampton Interview.pptx
Cyber Security Induction university of UK
Week 1 Session 1 - Introduction to Personal Computer.pptx
Week 1 Session 1 Networking Coventry University
Ad

Recently uploaded (20)

PPTX
FINAL REVIEW FOR COPD DIANOSIS FOR PULMONARY DISEASE.pptx
PPTX
Infosys Presentation by1.Riyan Bagwan 2.Samadhan Naiknavare 3.Gaurav Shinde 4...
PPTX
Construction Project Organization Group 2.pptx
PPTX
Geodesy 1.pptx...............................................
PDF
Model Code of Practice - Construction Work - 21102022 .pdf
PDF
Structs to JSON How Go Powers REST APIs.pdf
PDF
Mohammad Mahdi Farshadian CV - Prospective PhD Student 2026
PPT
Mechanical Engineering MATERIALS Selection
PPTX
UNIT-1 - COAL BASED THERMAL POWER PLANTS
PPTX
Foundation to blockchain - A guide to Blockchain Tech
PDF
composite construction of structures.pdf
PDF
Operating System & Kernel Study Guide-1 - converted.pdf
PPTX
IOT PPTs Week 10 Lecture Material.pptx of NPTEL Smart Cities contd
PDF
The CXO Playbook 2025 – Future-Ready Strategies for C-Suite Leaders Cerebrai...
PDF
BMEC211 - INTRODUCTION TO MECHATRONICS-1.pdf
PDF
Evaluating the Democratization of the Turkish Armed Forces from a Normative P...
PDF
Mitigating Risks through Effective Management for Enhancing Organizational Pe...
PPTX
Strings in CPP - Strings in C++ are sequences of characters used to store and...
PDF
Digital Logic Computer Design lecture notes
PDF
Embodied AI: Ushering in the Next Era of Intelligent Systems
FINAL REVIEW FOR COPD DIANOSIS FOR PULMONARY DISEASE.pptx
Infosys Presentation by1.Riyan Bagwan 2.Samadhan Naiknavare 3.Gaurav Shinde 4...
Construction Project Organization Group 2.pptx
Geodesy 1.pptx...............................................
Model Code of Practice - Construction Work - 21102022 .pdf
Structs to JSON How Go Powers REST APIs.pdf
Mohammad Mahdi Farshadian CV - Prospective PhD Student 2026
Mechanical Engineering MATERIALS Selection
UNIT-1 - COAL BASED THERMAL POWER PLANTS
Foundation to blockchain - A guide to Blockchain Tech
composite construction of structures.pdf
Operating System & Kernel Study Guide-1 - converted.pdf
IOT PPTs Week 10 Lecture Material.pptx of NPTEL Smart Cities contd
The CXO Playbook 2025 – Future-Ready Strategies for C-Suite Leaders Cerebrai...
BMEC211 - INTRODUCTION TO MECHATRONICS-1.pdf
Evaluating the Democratization of the Turkish Armed Forces from a Normative P...
Mitigating Risks through Effective Management for Enhancing Organizational Pe...
Strings in CPP - Strings in C++ are sequences of characters used to store and...
Digital Logic Computer Design lecture notes
Embodied AI: Ushering in the Next Era of Intelligent Systems

Algorithm and data science foundation ISC

  • 2. z
  • 3. z Problem Solving as a Computer Scientist: Imagine you’re working in a tech company, and you receive a complaint that the company’s e- commerce website is running slow whenever there are a lot of users shopping at the same time. This is a problem, and as a computer scientist, your job is to figure out a way to solve it.
  • 4. z The Process of Problem Solving: 1. Analyzing the Problem: You start by analyzing the issue. Why is the website slowing down? Is it because of how data is being processed? Is the database overloaded? Are there inefficient algorithms running behind the scenes? 2. Designing an Algorithm: Once you’ve identified the root cause (for example, the website is not handling large amounts of traffic efficiently), you need to design a solution. This might involve creating a better algorithm to manage user traffic or optimizing how the database queries are handled. 3. Developing a Solution: You then develop an algorithm that can solve the issue. This might involve implementing load balancing, which distributes user traffic across multiple servers, or improving the efficiency of data retrieval from the database.
  • 5. z Not All Problems Have Solutions! "Not all problems have a solution!". Sometimes, a problem might be so complex or have limitations (like hardware, cost, or time) that it’s impossible to find a perfect solution. In those cases, part of your role is to decide the best possible solution given the constraints. Example: Margret Hamilton and Apollo 11 The image in the slide shows Margaret Hamilton, a computer scientist who helped develop the software for the Apollo 11 mission. Just like modern computer scientists, she and her team had to solve complex problems using algorithms to ensure the mission's success, knowing that there was no room for error.
  • 6. z
  • 7. z Deriving Algorithms: Imagine you’re a student taking a course in algorithms, and you’ve been assigned a project to optimize the performance of an e- commerce website. The website’s checkout process is slow, and customers are abandoning their carts. You need to derive an algorithm that improves the checkout flow. To tackle this problem, you’ll apply structured methods like Polya’s Principle and computational thinking to develop an effective solution.
  • 8. z How to Derive Algorithms – Using Polya’s Principle: Polya’s Principle is a well-known approach to solving problems methodically. It includes the following steps: 1. Understand the Problem: Before jumping to a solution, you need to clearly understand what’s causing the delay in the checkout process. Is it slow database queries? Is it too many steps for the user? What are the bottlenecks? Example: You identify that the website is slow due to inefficient payment processing and unnecessary validation steps. 2. Devise a Plan: Think about how you can approach the problem. What steps can you take to optimize the checkout process? Can you reduce the number of steps? Can you cache frequently used data to reduce the load? Example: You decide to optimize the database queries, reduce the number of user inputs, and implement caching for commonly accessed information.
  • 9. z How to Derive Algorithms – Using Polya’s Principle:  Carry Out the Plan: • Now that you have a plan, you can start writing the algorithm that streamlines the checkout process. You optimize the query structure, introduce asynchronous processing for payment, and cache user data. • Example: You develop an algorithm that reduces the number of database calls, loads information faster, and only requires necessary inputs during checkout.  Review and Improve: • After implementing the solution, test it. Does it solve the problem? If not, what improvements can be made? • Example: After testing, you realize the payment gateway still causes delays. You refine the algorithm further by implementing a payment gateway API that handles requests more efficiently.
  • 10. z Polya’s Principles – A Step-by-Step Guide to Problem Solving: 1. Understand the Problem (Preparation) Before solving any problem, it’s crucial to fully comprehend the details and constraints. This phase is all about clarifying and analyzing the problem. Example Scenario: Imagine you are tasked with developing an algorithm that helps a delivery company optimize its routes to save fuel and time. Key Actions: Ask Questions: What specific constraints are there? Do we want to minimize travel time, distance, or fuel usage? Are there traffic or delivery time restrictions? Define the Problem: You need to minimize travel distance while ensuring that delivery deadlines are met for all customers. Identify Constraints: The delivery truck can only carry a certain weight, the route should avoid toll roads, and all deliveries must be completed within an 8-hour window. Goal: By fully understanding the problem, you can set clear objectives. For the delivery company example, the objective is to reduce the overall distance while adhering to time and weight constraints.
  • 11. z 2. Devise a Plan/Strategy to Solve the Problem  Now that the problem is clearly understood, it’s time to come up with a strategy. Here, you’ll consider different approaches or algorithms that could solve the problem.  Key Actions: • Brainstorm Solutions: In the case of optimizing delivery routes, you might consider using algorithms like Dijkstra’s algorithm, the Traveling Salesman Problem (TSP), or even heuristic methods like Genetic Algorithms. • Choose the Best Strategy: Compare the pros and cons of different strategies. For example, if the delivery points change daily, a dynamic algorithm like TSP might be more appropriate. However, if you only need a rough estimate quickly, a heuristic method could be sufficient.  Goal:  The goal of this step is to have a clear approach or algorithm in mind. For the delivery route problem, you decide to use a variation of the TSP algorithm that accounts for time constraints.
  • 12. z 3. Carry Out the Plan Now that the plan is in place, it’s time to execute. This step is all about implementing the solution and coding the algorithm. Key Actions: Write the Algorithm: For the delivery route optimization, you begin coding the TSP algorithm, factoring in traffic and time constraints. You might also use a map API to calculate distances between delivery points. Test and Debug: Once the algorithm is implemented, you run it with various test cases to ensure it works. In this case, you might input different sets of delivery addresses to check if the routes are optimized effectively. Ensure It Meets Constraints: Make sure the algorithm respects the delivery deadlines, maximum truck weight, and road restrictions. Goal: Your goal here is to execute the plan successfully by coding and implementing the solution. At the end of this step, the delivery route optimization algorithm should work as expected and meet all constraints.
  • 13. z 4. Look Back (Review the Solution) Once the solution is implemented, it’s important to review and reflect on how effective it was. This step involves evaluating the solution’s efficiency and considering potential improvements. Key Actions: Evaluate the Solution: Does the algorithm optimize routes as expected? Is it fast enough to calculate routes in real-time? Optimize if Necessary: If the solution takes too long to compute or doesn’t fully optimize the routes, you might need to refine it. For example, you could improve the algorithm's efficiency by using a faster heuristic method or reducing the complexity of the calculations. Learn for Future Problems: Consider what went well and what could be improved. Were there any edge cases you hadn’t considered initially? Goal: The final goal is to ensure the solution is optimal and efficient. In the case of the delivery company, this means the algorithm must consistently optimize routes and handle different scenarios effectively.
  • 14. z
  • 15. z Scenario: Devise a Plan for Optimizing Search Results Imagine you’re working on a search engine for a shopping website. Users complain that search results take too long to load, especially when searching for items with common keywords (like "shoes"). The problem is clear, but now you need to devise a plan to solve it. Step 1: Ask the Right Questions (Thinking Time) Before jumping into a solution, you need to ask key questions that help you evaluate the situation: • Why are the search results slow? Is it because of database query inefficiencies? • How many users are searching at the same time? Is it causing a traffic bottleneck? • Are there redundant or irrelevant search results being processed?  By asking these questions, you get a better sense of the problem and what factors need to be addressed.
  • 16. z Scenario: Devise a Plan for Optimizing Search Results Imagine you’re working on a search engine for a shopping website. Users complain that search results take too long to load, especially when searching for items with common keywords (like "shoes"). The problem is clear, but now you need to devise a plan to solve it. Step 2: Consider Different Approaches Once you have a clear understanding, you begin thinking about possible strategies. This could include: Caching: Could you implement caching for common searches so the results load faster without querying the database repeatedly? Indexing: Could you optimize the search by indexing the most frequently searched terms? Parallel Processing: Should you distribute the search process across multiple servers to handle more queries simultaneously? Each of these techniques has its pros and cons, and choosing the right one depends on the specific requirements and constraints of the system.
  • 17. z Scenario: Devise a Plan for Optimizing Search Results Imagine you’re working on a search engine for a shopping website. Users complain that search results take too long to load, especially when searching for items with common keywords (like "shoes"). The problem is clear, but now you need to devise a plan to solve it.  Step 3: Choose a Strategy  After evaluating the possible approaches, you decide to implement caching. You choose this because many users search for the same popular items, and caching these results would speed up searches for frequently requested items. This solution addresses the problem without overhauling the entire system.
  • 18. z
  • 19. z Carry Out the Plan (Insight) Key Steps: Implement the Solution: Write the code or algorithm based on your plan. Test as you go to ensure each part works correctly. Evaluate and Adjust: Monitor the results of your implementation. If the plan doesn’t fully solve the problem, tweak or refine your approach. Learn from Each Attempt: If an approach doesn’t work, use what you learned to eliminate that option and try another. Persistence Pays Off: Keep trying, and eventually, you’ll gain insights that help you reach the solution.
  • 20. z Reviewing and Reflecting After Solving a Problem Let’s say you’ve just implemented an algorithm to speed up search results on a website. Now, it’s time to review and reflect to ensure that your solution meets the requirements and performs well. Step 2: Can the Solution Be Improved? Next, think about whether there’s a way to make the algorithm even better. Could it be faster or simpler? •Example: You notice that some searches are still slow when users search for uncommon terms. You could consider adding an indexing feature to improve those searches. Step 3: Fixing Mistakes If your solution doesn’t fully work, there might be a small mistake. Instead of starting over, try fixing or adjusting the current solution. •Example: During testing, you find a small bug in how the algorithm handles specific types of queries. You fix this error, and now the solution works as expected.
  • 21. z Reviewing and Reflecting After Solving a Problem Let’s say you’ve just implemented an algorithm to speed up search results on a website. Now, it’s time to review and reflect to ensure that your solution meets the requirements and performs well. Step 4: Is There a Simpler Way? Sometimes, there might be a simpler or more efficient way to solve the problem. Consider if another approach could work better. •Example: You realize that instead of adding more complexity, simplifying the database queries could also speed up the search results. Step 5: Can This Solution Help in the Future? Lastly, think about whether the method you used can be applied to other problems. Could this algorithm help you solve similar issues in the future? •Example: You realize that the caching system you used could also help with other website features, like loading product images faster.
  • 22. z Top-Down Design in Problem Solving Imagine you are making a game where players collect coins. At the end of the game, you need to calculate how many coins each player has and show the total. This might sound like a lot to do at once, but by using top-down design, you can break it into smaller, simpler steps.
  • 23. z  What is Top-Down Design?  Top-down design means starting with the big task and breaking it into smaller tasks. You handle each small task one at a time until the whole problem is solved.  Step 1: Breaking the Problem into Smaller Steps  Let’s say the big task is to count the total number of coins each player has. To make this easier, we can break it down into smaller tasks: 1. Count the coins the player collected. 2. Add any bonus coins they earned. 3. Show the total number of coins.  Each of these small tasks is much easier to handle on its own.
  • 24. z Step 2: Building and Testing Small Tasks For each small task, we can create a simple function. For example: A function to count the coins collected. A function to add bonus coins. A function to show the total. We test each of these small tasks to make sure they work before moving on. For example, you can test if the coin counter is working correctly before adding the bonus coins. Why Use Top-Down Design? •It Makes Things Easier: By focusing on one small task at a time, the big problem doesn’t feel so hard. •Less Confusing: Each small task is clear and simple. •Easy to Fix: If something goes wrong, it’s easier to find where the mistake is.
  • 26. z Top-Down Design in a University Registration Program  Imagine you are tasked with building a program for students to register for classes at a university. This is a big task with many parts. To make it easier, we use top-down design, which helps you break the large problem into smaller, more manageable parts.
  • 27. z Top-Down Design in a University Registration Program  Imagine you are tasked with building a program for students to register for classes at a university. This is a big task with many parts. To make it easier, we use top-down design, which helps you break the large problem into smaller, more manageable parts.
  • 28. z Top-Down Design in a University Registration Program  Imagine you are tasked with building a program for students to register for classes at a university. This is a big task with many parts. To make it easier, we use top-down design, which helps you break the large problem into smaller, more manageable parts.
  • 29. z Designing a Simple Calculator Using Top- Down Algorithm Design  Imagine you’re building a simple calculator that can perform basic operations like addition, subtraction, multiplication, and division. This is the main problem you want to solve. Let’s apply top-down algorithm design to break it into manageable parts.
  • 30. z Designing a Simple Calculator Using Top- Down Algorithm Design  Imagine you’re building a simple calculator that can perform basic operations like addition, subtraction, multiplication, and division. This is the main problem you want to solve. Let’s apply top-down algorithm design to break it into manageable parts.
  • 31. z Designing a Simple Calculator Using Top-Down Algorithm Design  Imagine you’re building a simple calculator that can perform basic operations like addition, subtraction, multiplication, and division. This is the main problem you want to solve. Let’s apply top-down algorithm design to break it into manageable parts.
  • 32. z Building a Simple To-Do List App Imagine you’re creating a to- do list app. It feels like a big job, but we can break it down into small, easy steps using top-down design.
  • 33. z Building a Simple To-Do List App Imagine you’re creating a to- do list app. It feels like a big job, but we can break it down into small, easy steps using top-down design.
  • 34. z Building a Simple To-Do List App Imagine you’re creating a to-do list app. It feels like a big job, but we can break it down into small, easy steps using top-down design.
  • 35. z Building a Shopping Cart Feature Using Top-Down Design Imagine you’re working on an online store, and you need to create a shopping cart where users can add items, view their total, and check out. This can seem like a lot to handle at once, but with top-down design, you can break it down into smaller tasks. Advantages of Top-Down Design: 1.Breaking the Problem into Parts You start by breaking the shopping cart task into smaller tasks, like: 1. Add items to the cart. 2. Show the total price. 3. Check out and process payment. 2.Simplifies the Work Each smaller task becomes easier to understand and complete. 3.Reusable Code Once you’ve built the function to add items to the cart, you might be able to reuse it in other parts of the store. 4.Collaboration Different people can work on each part (like one person building the "Add Item" feature, another handling the "Checkout" part).
  • 36. z Building a Chat Feature Using Bottom- Up Methodology  Imagine you're developing a chat feature for an app. Instead of starting with the entire chat system, the bottom-up approach focuses on building the smallest components first and gradually combining them. Start Small Begin with the simplest components: •Create a function to send a message. •Create a function to receive a message. Build Up Gradually After these small components are working: •Combine the send and receive functions. •Add features like showing the message history. Complete the Solution As each component works, you connect them to form the entire chat feature. You focus on solving small problems and gradually build the full chat system.
  • 37. z Key Steps of Bottom-Up Design: 1. Identify Basic Components Start with simple building blocks: 1. Sending a message. 2. Receiving a message. 2. Solve Basic Components Work on these tasks individually. Ensure: 1. The send message function works alone. 2. The receive message function operates by itself. 3. Combine Components After confirming they work individually, combine them: 1. When a message is sent, it should appear in the received messages. 1.Repeat and Refine Keep adding components like: 1. Message history: Combine it with send/receive to store past messages. 2. User notifications: Add notifications when new messages are received. 2.Test Incrementally Test each part (send, receive, history) as you add it to ensure they work well together. 3.Address the Main Problem Once all the smaller components work, combine them to complete the messaging system. 4.Optimise and Document Improve the system’s performance and document the components so it's easier to maintain.