Week 1: What is Computational Thinking?
2192 words
11 min read
Visual companion
Python
Type and operator map
Python Week 1: the first filter for runtime behavior
View
Revision summary
What this note is really saying
Short form
# Week 1: What is Computational Thinking? > **BSCS1001 — IIT Madras BS Degree** **Prerequisite:** None (this is your first topic!) **Cross-links:** BSCS1002-Python (Week 1), BSCS2002-PDSA (Week 1) ## 1.

Week 1: What is Computational Thinking?
BSCS1001 — IIT Madras BS Degree Prerequisite: None (this is your first topic!) Cross-links: BSCS1002-Python (Week 1), BSCS2002-PDSA (Week 1)
1. Motivation: Why Computational Thinking?
Imagine you are a teacher with a stack of 200 answer sheets. You need to:
- Find the highest score
- Calculate the class average
- Count how many students scored above 80 You could do this manually, but it would take hours and you might make mistakes. Now imagine you could describe the steps so precisely that a computer (which has no common sense) could do it for you in milliseconds. Computational Thinking is exactly this — the art of taking a real-world problem and breaking it down into such precise, step-by-step instructions that a machine can execute them.
Real-World Analogy: A Cooking Recipe
| Recipe Step | Computational Thinking Concept |
|---|---|
| "Gather all ingredients" | Dataset — the collection of items to process |
| "Repeat for each onion" | Iteration — doing something repeatedly |
| "If the onion is brown, discard it" | Filtering — selective processing |
| "Keep count of how many onions you chopped" | Variable — tracking a value |
| "Chop until all onions are done" | Loop termination — when to stop |
Key Insight: Computational thinking is not about computers — it is about thinking in a structured, methodical way. Computers just happen to be very good at executing such structured thinking.
2. What is Computational Thinking?
Formal Definition
Computational Thinking (CT) is the process of formulating problems and expressing their solutions in a way that a computer — human or machine — can effectively carry out.
The four pillars of computational thinking are:
(Diagram)
Note for absolute beginners: Don't worry if these four pillars seem abstract. By Week 4, every one of them will feel natural. This course focuses mainly on Algorithm Design (the last pillar).
Course Context
In BSCS1001, we focus on:
- Procedural approach — describing solutions as sequences of steps
- Pattern identification — recognizing that many problems share the same solution structure
- Data representation — choosing the right way to store information
- Algorithm analysis — understanding which solutions are faster
3. Patterns in Problem Solving
The most important skill you will learn is pattern recognition — noticing that two seemingly different problems can be solved using the same approach.
Example: The "Find the Best" Pattern
Consider these three problems:
| Problem | What You Need | Same Pattern? |
|---|---|---|
| Find the student with highest marks | Maximum value in a list | ✅ Yes |
| Find the oldest person in a room | Maximum age | ✅ Yes |
| Find the most expensive item in a cart | Maximum price | ✅ Yes |
All three use the same algorithm: look at each item, remember the best one seen so far, update if current is better.
Example: The "Count Things" Pattern
| Problem | What You Need | Same Pattern? |
|---|---|---|
| Count students in a class | Total number | ✅ Yes |
| Count words in a paragraph | Total words | ✅ Yes |
| Count items in a shopping bill | Total items | ✅ Yes |
All three use: start at 0, add 1 for each item.
💡 Takeaway: Once you learn one pattern, you can reuse it everywhere. This is the superpower of computational thinking.
4. Datasets: The Raw Material
A dataset is just a collection of information. In this course, we work with three main types:
Dataset Examples from the Course
(Diagram)
How We Visualize Datasets
In this course, we imagine data as cards in a pile:
- Pile 1: Cards we haven't looked at yet (the "unseen" pile)
- Pile 2: Cards we have already processed (the "seen" pile) We pick cards one by one from Pile 1, process them, and move them to Pile 2.
pseudoPile 1 (Unseen) → Pick a card → Process it → Pile 2 (Seen) [Card A] [Card B] ──► Pick Card B ──► Read data ──► [Card B] [Card C]
Why this analogy? Computers don't have "piles" — they have memory. But the pile analogy perfectly captures the idea of sequential processing: one item at a time, in order.
5. Iteration: The Most Powerful Pattern
Iteration means doing the same thing repeatedly. It is the single most used pattern in this course (and in all of programming).
The Iterator Pattern
(Diagram)
The Four Steps of Every Iterator
| Step | Description | Example (Counting Cards) |
|---|---|---|
| 1. Initialization | Set up starting values | Count = 0 |
| 2. Continue or Exit | Check if there's more data | Pile 1 has more cards? |
| 3. Repeat Step | Pick one item, process it | Pick card, add 1 to Count |
| 4. Go Back | Return to step 2 | Go back to check condition |
Worked Example 1: Counting Cards
Let's trace through the process of counting 3 cards: [A, B, C]
| Step | What Happens | Pile 1 | Pile 2 | Count |
|---|---|---|---|---|
| Start | Initialize Count to 0 | [A, B, C] | [] | 0 |
| Check | Pile 1 has cards → continue | [A, B, C] | [] | 0 |
| Pick | Pick card A | [B, C] | [] | 0 |
| Move | Move A to Pile 2 | [B, C] | [A] | 0 |
| Update | Increment Count: 0+1=1 | [B, C] | [A] | 1 |
| Check | Pile 1 has cards → continue | [B, C] | [A] | 1 |
| Pick | Pick card B | [C] | [A] | 1 |
| Move | Move B to Pile 2 | [C] | [A, B] | 1 |
| Update | Increment Count: 1+1=2 | [C] | [A, B] | 2 |
| Check | Pile 1 has cards → continue | [C] | [A, B] | 2 |
| Pick | Pick card C | [] | [A, B] | 2 |
| Move | Move C to Pile 2 | [] | [A, B, C] | 2 |
| Update | Increment Count: 2+1=3 | [] | [A, B, C] | 3 |
| Check | Pile 1 empty → exit | [] | [A, B, C] | 3 |
| End | Return Count = 3 | — | — | 3 |
🔍 Notice: Every time we go through the loop, Count increases by exactly 1. The process stops when Pile 1 is empty.
Worked Example 2: Sum of Marks
Now let's sum the Maths marks of 4 students.
Dataset:
| Card | Name | Maths |
|---|---|---|
| 1 | Alice | 85 |
| 2 | Bob | 72 |
| 3 | Charlie | 91 |
| 4 | Diana | 68 |
Tracing:
| Step | Card | Action | Sum |
|---|---|---|---|
| Start | — | Sum = 0 | 0 |
| Iter 1 | Alice | Sum = 0 + 85 | 85 |
| Iter 2 | Bob | Sum = 85 + 72 | 157 |
| Iter 3 | Charlie | Sum = 157 + 91 | 248 |
| Iter 4 | Diana | Sum = 248 + 68 | 316 |
| End | — | Return 316 | 316 |
6. Variables: Keeping Track
A variable is a named storage location whose value changes during computation.
Key Properties of Variables
| Property | Explanation | Example |
|---|---|---|
| Name | A label to identify the variable | Sum, Count, Max |
| Value | The data currently stored | Sum = 157 |
| Type | What kind of data it can hold | Integer, Boolean, Character |
| Mutable | Value can be changed by assignment | Sum = Sum + 85 |
The Assignment Statement
The
= sign in computational thinking does not mean equality (like in mathematics). It means assignment — take the value on the right and store it in the variable on the left.pseudoSum = 0 ← "Store the value 0 in the variable named Sum" Sum = Sum + 85 ← "Take the current value of Sum, add 85, store the result back in Sum"
Math = | CT = |
|---|---|
x = x + 1 is impossible (no number equals itself plus one) | x = x + 1 is normal — it means "increase x by 1" |
| States a truth | Gives an instruction |
| Read as "equals" | Read as "becomes" or "gets" |
⚠️ Common Pitfall: Beginners often confuse assignment with equality. In pseudocode,=always means assignment. To check equality, we use==(two equals signs).
Common Variable Roles
| Role | Description | Example |
|---|---|---|
| Counter | Counts how many items processed | Count = Count + 1 |
| Accumulator | Adds up values | Sum = Sum + x.Maths |
| Tracker | Remembers the "best so far" | if x.Marks > Max then Max = x.Marks |
| Flag | Records whether something happened | Found = True |
7. Filtering: Selecting What Matters
Filtering means processing only the items that satisfy a condition, ignoring the rest.
The Filtering Pattern
sqlInitialize variables while (Pile 1 has more cards) { Pick a card X from Pile 1 Move X to Pile 2 if (condition is true) { Update variables with X's data } }
Worked Example: Sum of Boys' Maths Marks Only
Dataset:
| Card | Name | Gender | Maths |
|---|---|---|---|
| 1 | Alice | F | 85 |
| 2 | Bob | M | 72 |
| 3 | Charlie | M | 91 |
| 4 | Diana | F | 68 |
Tracing with Filter:
| Step | Card | Gender | Condition: M? | Action | Sum |
|---|---|---|---|---|---|
| Start | — | — | — | Sum = 0 | 0 |
| Iter 1 | Alice | F | No | Skip | 0 |
| Iter 2 | Bob | M | Yes | Sum = 0 + 72 | 72 |
| Iter 3 | Charlie | M | Yes | Sum = 72 + 91 | 163 |
| Iter 4 | Diana | F | No | Skip | 163 |
| End | — | — | — | Return 163 | 163 |
Types of Filtering Conditions
| Type | Example | Explanation |
|---|---|---|
| Constant comparison | x.Gender == "M" | Compare with a fixed value |
| Variable comparison | x.Marks > Max | Compare with another variable |
| Range check | x.Marks >= 0 AND x.Marks <= 100 | Check if within bounds |
| Compound condition | x.Gender == "M" AND x.Maths > 80 | Multiple conditions at once |
8. Flowcharts: Visualizing Algorithms
A flowchart is a picture of an algorithm. It uses standard symbols to show the steps and the flow of control.
Standard Flowchart Symbols
(Diagram)
| Symbol | Shape | Purpose |
|---|---|---|
| Start/End | Oval / Pill | Marks beginning and end of algorithm |
| Process | Rectangle | Any operation that changes variable values |
| Decision | Diamond | A yes/no question that determines which path to take |
| Input/Output | Parallelogram | Reading data or displaying results |
| Flow line | Arrow | Shows the direction of execution |
Flowchart for Counting Cards
(Diagram)
Flowchart for Sum with Filtering (Boys' Marks)
(Diagram)
Advantages and Disadvantages of Flowcharts
| ✅ Advantages | ❌ Disadvantages |
|---|---|
| Visual and easy to understand | Become very large for complex algorithms |
| Good for teaching beginners | Hard to share and edit (images) |
| Help catch logical errors | No standard way to determine level of detail |
| Excellent for debugging | Difficult to version-control |
Why flowcharts first? Before we write pseudocode (Week 2), flowcharts help you see the logic. Once you understand the picture, translating to text is much easier.
9. Putting It All Together
Complete Example: Finding the Maximum Mark
Problem: Find the highest Maths score in a class.
Flowchart:
(Diagram)
Tracing Table (Dataset: [45, 78, 62, 91, 53]):
| Step | Card | X.Maths | Max (before) | X.Maths > Max? | Max (after) |
|---|---|---|---|---|---|
| Start | — | — | 0 | — | 0 |
| Iter 1 | 1 | 45 | 0 | 45 > 0 ✅ Yes | 45 |
| Iter 2 | 2 | 78 | 45 | 78 > 45 ✅ Yes | 78 |
| Iter 3 | 3 | 62 | 78 | 62 > 78 ❌ No | 78 |
| Iter 4 | 4 | 91 | 78 | 91 > 78 ✅ Yes | 91 |
| Iter 5 | 5 | 53 | 91 | 53 > 91 ❌ No | 91 |
| End | — | — | — | — | 91 |
Result: The maximum Maths mark is 91.
The Big Picture: How Week 1 Concepts Fit Together
(Diagram)
10. Practice Questions
Basic Questions
Q1. What is the value of
Count after this sequence?pseudoCount = 0 Count = Count + 1 Count = Count + 2 Count = Count + 3
Show Answer
| Step | Statement | Count |
|---|---|---|
| 1 | Count = 0 | 0 |
| 2 | Count = 0 + 1 = 1 | 1 |
| 3 | Count = 1 + 2 = 3 | 3 |
| 4 | Count = 3 + 3 = 6 | 6 |
Answer: 6 Q2. Trace the following algorithm for dataset [10, 20, 30, 40]:
sqlSum = 0 while (Pile 1 has more cards) { Pick a card X from Pile 1 Move X to Pile 2 if (X > 25) { Sum = Sum + X } }
Show Answer
| Iter | X | X > 25? | Sum |
|---|---|---|---|
| 1 | 10 | No | 0 |
| 2 | 20 | No | 0 |
| 3 | 30 | Yes | 30 |
| 4 | 40 | Yes | 70 |
Answer: 70 Q3. Identify the four steps of every iterator pattern. Show Answer
- Initialization — set starting values
- Continue or Exit — check if there's more data
- Repeat Step — pick and process one item
- Go Back — return to step 2 Q4. What is the difference between
=in mathematics and=in computational thinking? Show AnswerIn mathematics,=states equality (a truth). In computational thinking,=means assignment (an instruction).x = x + 1is impossible in math but normal in CT — it means "increase x by 1."
Intermediate Questions
Q5. Draw a flowchart for finding the minimum value in a dataset.
Show AnswerDiagram(Diagram) Q6. Trace the counting algorithm for 6 cards. Show the state of Count and both piles at each step. Show Answer
| Step | Pile 1 | Pile 2 | Count |
|---|---|---|---|
| Start | [1,2,3,4,5,6] | [] | 0 |
| Iter 1 | [2,3,4,5,6] | [1] | 1 |
| Iter 2 | [3,4,5,6] | [1,2] | 2 |
| Iter 3 | [4,5,6] | [1,2,3] | 3 |
| Iter 4 | [5,6] | [1,2,3,4] | 4 |
| Iter 5 | [6] | [1,2,3,4,5] | 5 |
| Iter 6 | [] | [1,2,3,4,5,6] | 6 |
| End | [] | [1,2,3,4,5,6] | 6 |
Q7. Write the pseudocode (in words) to find the sum of only those numbers in a dataset that are even.
Show AnswersqlSum = 0 while (Pile 1 has more cards) { Pick a card X from Pile 1 Move X to Pile 2 if (X is even) { Sum = Sum + X } } Return SumWhere "X is even" meansX % 2 == 0(X divided by 2 leaves remainder 0).
Advanced Questions
Q8. What happens if we initialize
Max to 0 but all marks are negative? What should we initialize it to instead?Show AnswerIfMax = 0and all marks are negative (e.g., [-5, -10, -3]), the algorithm would incorrectly return 0 instead of the actual maximum (-3).Better initialization: SetMaxto the first card's value. Or set it to-INFINITY(a very large negative number) so any real value will be larger.Alternatively, we can initializeMax = -1andMaxCard = -1(invalid card ID), and only update when we see a valid card. Q9. Compare and contrast: constant filtering condition vs. variable filtering condition. Give an example of each. Show Answer
| Aspect | Constant Condition | Variable Condition |
|---|---|---|
| Value compared against | Fixed, does not change | Changes as algorithm runs |
| Example | x.Gender == "M" | x.Marks > Max |
| When evaluated | Same check each iteration | Check changes as Max updates |
| Use case | Counting, summing subgroups | Finding max/min |
Q10. Why is the pile analogy used in this course? What real computer memory concept does it represent?
Show AnswerThe pile analogy is used because it's intuitive — you can visualize physically picking up cards one by one. It represents sequential access memory where data items are processed one after another in order. This is how computers typically read data from storage or iterate through collections.The two-pile system (Pile 1 = unseen, Pile 2 = seen) ensures we process each item exactly once, which is the foundation of all iterative algorithms.
📚 Cross-References
| Course | Topic | Connection |
|---|---|---|
| BSCS1002 (Python) | Week 1 — Variables & Data Types | Python's = assignment, int, bool types |
| BSCS2002 (PDSA) | Week 1 — Algorithm Basics | The iteration pattern formalized |
| BSCS2002 (PDSA) | Week 2 — Complexity | How many steps does iteration take? |
Next Topic: 02 — Data Types & RepresentationQuiz Tip: Practice tracing iteration by hand — it's the most common question type in Quiz 1! Join Discord NextData Types & Representation