KEMBAR78
Week 2 - Computational Thinking | PDF | Algorithms | Applied Mathematics
0% found this document useful (0 votes)
9 views33 pages

Week 2 - Computational Thinking

Uploaded by

Ryan K 9D - 25
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)
9 views33 pages

Week 2 - Computational Thinking

Uploaded by

Ryan K 9D - 25
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/ 33

Computational Thinking and Algorithm

Dyah Aruming Tyas


Topics
• Computational Thinking
• Algorithm: Flowchart, Pseudocode
Computational Thinking
Some quotes about Computational Thinking
• “Computational Thinking is the new literacy of the 21st century. The
goal is for it to be a fundamental skill used by everyone in the world
by the middle of the 21st century. Just like reading, writing and
arithmetic.”
• “Even people who aren’t going into computer science or engineering
programs, should be exposed to computer science. Programming
teaches you how to take problems, break them down into smaller
problems, and solve them. Any kind of job that involves problem
solving can benefit from computing.”
Some quotes about Computational Thinking
• “Computers are extremely talented at performing menial tasks
quickly; Computational Thinkers can leverage that power to find
solutions to previously impossible problems.”
• “I think everyone should get a little exposure to computer science
because it really forces you to think in a slightly different way, and it’s
a skill that you can apply in life in general.”
Computational Thinking
Computational Thinking is a
problem-solving process that
includes the following
characteristics :

➢Abstraction
➢Decomposition
➢Pattern Recognition
➢Algorithms
Decomposition: Breaking problems into simple parts
Decomposition illustration
1. Make chocolate crust
2. Make mousse and chill
3. Wash & slice fresh
strawberries
4. Whip cream
5. Make chocolate hearts
6. Assemble
Abstraction
• Abstraction is the process of filtering out unnecessary
information.
• Abstraction allows us to create a general idea of what the
problem is and how to solve it
Example:
Abstracting a general procedure for baking cookies
• Bring butter and eggs to room
temperature
• Sift dry ingredients
• Cream sugars and butter
• Add eggs and vanilla
• Mix in dry ingredients
• Mix in add-ins like chips, nuts,
etc.
• Bake
Pattern Recognition
• The goal of pattern recognition is to find common similarities
and differences among objects.
• This allows us to solve seemingly diverse problems by a single
algorithm
Designing algorithms
• Determine the right steps
• Determine the correct order of the steps
• Follow the steps completely
• Verify that the algorithm is working correctly
• Determine if algorithm is the “best” approach for solving
problem
Algorithm
Looking up a name in the data
If you are looking up, e.g., Dyah Aruming Tyas (it is called key) in the
data, then the following would be an algorithm for finding the name,
assuming the data is in ascending order:
1. Go to the first row of data
2. Check if the data is equal to the key.
3. If not, go to the next row.
4. Repeat step 2 and 3 until it is found, or not found.
Looking up a name in the data
• If there are N = 100.000 rows,
there will be 100.000 checking
processes.
• This algorithm is called complete
search or brute-force method.
Looking up a name in the data
• What if N becomes very large, for example 1010? Can you develop a
faster algorithm?
Looking up a name in the data
Use divide-and-conquer approach!

How many checking processes (at most) that we need to do for N = 100.000?
What if N = 1010?
Complete Search vs Divide-and-Conquer

• Complete search or brute force: O(N)


• Divide-and-Conquer: O(log(N))
Multiple Algorithms
• May result in the same answer, but with different complexity
(time/space)
• May result in different answers
• Leads to wrong or non-optimal answer
Multiple Algorithms: Examples
Suppose you are packing your backpack for a hike but
you have 6 items you are interested in taking but their
total weight is 96 lbs. The maximum weight you are
willing to carry is 50 lbs. You assign each item an
importance value between 0 and 25; the higher the
number the more valuable. What items should you take?

Let’s discuss!
Algoritme I - random
Algoritma 1 - Random
• Strategi random dapat menghasilkan kemungkinan sebagai berikut:
Algoritma II – Mengurutkan nilai
Algoritma III – urutkan rasion nilai/berat
Ways to Describe an Algorithm
• Natural language
• Diagrams, e.g. flowchart
• Pseudocode

Thursday, 22 August 2024 28


Flowchart
• Made in the form of a flow of symbols that can be traced from a
starting point to an end point of an algorithm or program.
• Easy to understand for high level description
• With a small number of steps
• Quick to be complicated, impractical, difficult to understand for
detailed description
• With many steps
• Good for presentations

Thursday, 22 August 2024 29


Flowchart Elements

Start/End Process Decision Input/Output

Predefined
Delay
Process

Manual Manual
Display
Input Operation

Thursday, 22 August 2024 30


Flowchart Elements

Off-Page On-Page Merge


Connector Connector

Document Multiple Data Internal Tape Database Paper Tape


Documents Storage Storage

Thursday, 22 August 2024 31


Flowchart Example

Thursday, 22 August 2024 32


Flowchart Example

Thursday, 22 August 2024 33


Flowchart Example: Prime Number

Start no
i < n?
Print
true End

yes

Read n n is yes
divisible Print
by i ? false

no

Assign
i←2 Increment i
(i ← i + 1)

Thursday, 22 August 2024 34


Case Study
Make a flowchart of an ATM machine with the following conditions:
1. If it is wrong 3 times in entering the pin, the card is swallowed.
2. There are 2 features that an ATM machine can do, namely transfer,
check balance.
3. The transfer must be to another existing account, with a nominal
not exceeding the balance and not exceeding the daily transfer
limit.
4. Repeat the above features until the user selects the exit option.
Draw the flowchart neatly, completely, and clearly. There is no need to
add features other than those mentioned above.
Thank you!

You might also like