CS25C03 - ESSENTIALS OF COMPUTING
MODULE II – COMPUTATIONAL THINKING
COMPUTATIONAL THINKING
Computational thinking is a fundamental problem-solving process in computer science that
involves breaking down complex problems, identifying patterns, abstracting away
unnecessary details, and developing step-by-step algorithms or solutions that can be executed
by a computer. It combines logical thinking, critical thinking, and the principles of computer
science to design systematic and effective solutions, applicable not just to computing but to a
wide range of problems and disciplines.
Computational Thinking (CT) is a problem-solving approach that uses methods and
principles from computer science. It helps in analyzing problems, designing solutions, and
automating processes.
The key components of Computational Thinking are:
1. Decomposition
Breaking down a complex problem into smaller, more manageable parts.
Example: To design an online shopping system, you split it into product catalog, cart
system, payment, and delivery modules.
2. Pattern Recognition
Identifying similarities or trends among problems or data to simplify solutions.
Example: Recognizing that both bus and train ticket booking systems require seat
selection and payment → reuse logic.
3. Abstraction
Focusing on important details while ignoring unnecessary ones; creating a simplified model
of the problem.
Example: A map shows roads and landmarks but not every tree or building → keeps
only relevant details for navigation.
4. Algorithm Design
Creating a step-by-step set of instructions to solve the problem.
Example: Recipe for cooking pasta (boil water → add pasta → cook → drain → add
sauce).
5. Evaluation (Optional but often included)
Assessing how effective and efficient the solution or algorithm is, and improving it if needed.
Example: If an algorithm is too slow, optimize it with better logic or data structures.
✅ In short:
Computational Thinking = Decomposition + Pattern Recognition + Abstraction +
Algorithm Design (+ Evaluation).
Example 1: Navigation Apps (Google Maps, GPS)
Decomposition → Break the journey into smaller steps (starting point →
intermediate turns → destination).
Pattern Recognition → Uses past traffic data to predict delays.
Abstraction → Shows only roads, distances, and directions (hides unnecessary
details like every tree/building).
Algorithm Design → Finds the shortest or fastest route using step-by-step
instructions.
Evaluation → Updates route if traffic changes.
Example 2: Online Shopping System (e.g., Amazon, Flipkart)
Decomposition → Divide into browsing, cart, payment, and delivery modules.
Pattern Recognition → Recommends products based on your past purchases
(patterns in data).
Abstraction → Shows product name, price, and image (ignores unnecessary backend
database details).
Algorithm Design → Search filters, price sorting, and payment processing
algorithms.
Evaluation → Optimizes speed of checkout and delivery tracking.
Computational Thinking in Real-Life Examples
Navigation App (Google Online Shopping System
CT Component
Maps/GPS) (Amazon/Flipkart)
Break journey into steps: start → Split into browsing, cart, payment,
Decomposition
turns → destination. delivery modules.
Pattern Uses past traffic data to predict Recommends products based on past
Recognition delays and suggest better routes. purchases & browsing history.
Shows only roads, distance, and Displays product name, price, and
Abstraction
time (hides irrelevant details). image (hides backend details).
Calculates shortest/fastest path
Algorithm Uses search, filters, price sorting, and
using step-by-step route
Design payment algorithms.
instructions.
Updates route dynamically if Optimizes speed of checkout,
Evaluation
traffic changes or accidents occur. payment, and delivery tracking.
IMPORTANCE OF COMPUTATIONAL THINKING IN COMPUTER SCIENCE
Problem Formulation:
It allows computer scientists to express problems in a way that a computer can understand
and execute.
System Design:
It is used in designing systems and understanding how complex processes can be broken
down and managed.
Solution Development:
It enables the creation of efficient and effective solutions for software development, data
science, and other computing-related fields.
Broad Applicability:
While rooted in computer science, the ability to think computationally is a valuable skill in
virtually every aspect of modern life, from education to everyday problem-solving.
NUMBER SYSTEM
1. Binary Number System
2. Decimal Number System
3. Octal Number System
4. Hexadecimal Number System
NUMBER SYSTEM CONVERSIONS
Example: Convert (1011)₂ to Decimal
Step 1: Write the binary number with place values
Binary digits (bits) have place values based on powers of 2:
(1011)2=(1×23)+(0×22)+(1×21)+(1×20)
Step 2: Calculate powers of 2
23=82^3 = 823=8
22=42^2 = 422=4
21=22^1 = 221=2
20=12^0 = 120=1
Step 3: Multiply each bit by its place value
(1011)2=(1×8)+(0×4)+(1×2)+(1×1) =8+0+2+1
Step 4: Add them up
(1011)2=(11)10
Example: Convert (25)₁₀ to Binary
Method → Repeated Division by 2 (keep remainders).
Step 1: Divide by 2 until quotient = 0
Division Step Quotient Remainder
25 ÷ 2 12 1
12 ÷ 2 6 0
6÷2 3 0
3÷2 1 1
1÷2 0 1
Step 2: Write remainders from bottom to top
2510=11001225_{10} = 11001_22510=110012
Example 1: Binary to Octal
Convert (110101)₂ to Octal.
Step 1: Group binary digits into sets of 3 (from right to left).
110101=110 101110101 = 110\ 101110101=110 101
Step 2: Convert each group to decimal (0–7).
1102=68110₂ = 6₈1102=68
1012=58101₂ = 5₈1012=58
Step 3: Write result.
(110101)2=(65)8
Example 2: Binary to Hexadecimal
Convert (110101)₂ to Hexadecimal.
Step 1: Group binary digits into sets of 4 (from right to left).
110101=0011 0101110101
Step 2: Convert each group to decimal/hex (0–15 → 0–F).
00112=3160011₂ = 3_{16}00112=316
01012=5160101₂ = 5_{16}01012=516
Step 3: Write result.
(110101)2=(35)16
Example 1: Octal to Binary
Convert (57)₈ to Binary.
Step 1: Write each octal digit in 3-bit binary form
58=10125₈ = 101₂58=1012
78=11127₈ = 111₂78=1112
Step 2: Combine them
(57)8=(101111)2
Example 2: Hexadecimal to Binary
Convert (2F)₁₆ to Binary.
Step 1: Write each hex digit in 4-bit binary form
216=001022_{16} = 0010₂216=00102
F16=11112F_{16} = 1111₂F16=11112
Step 2: Combine them
(2F)16=(00101111)2
WHAT IS LOGIC?
Logic – Meaning
Logic is the science of reasoning and thinking systematically.
It deals with making correct decisions, drawing valid conclusions, and solving problems
based on rules.
In computer science, logic usually means:
Using true/false values (1 or 0, yes or no).
Applying logical operations (AND, OR, NOT, etc.) to process data and make
decisions.
🔹 Types of Logic
1. General / Philosophical Logic
o Studies reasoning, arguments, and conclusions.
o Example: All humans are mortal. Socrates is a human. Therefore, Socrates is
mortal.
2. Mathematical / Boolean Logic (used in computers)
o Uses binary values (0 and 1).
o Developed by George Boole.
o Example:
1∧1=11 \land 1 = 11∧1=1 (True AND True = True)
1∨0=11 \lor 0 = 11∨0=1 (True OR False = True)
🔹 In Simple Words
Logic is the foundation of problem solving → both in human reasoning and computer
operations.
Computers use Boolean logic to control decision-making, circuits, and programming
conditions.
✅ Example in real life:
Traffic light → If signal is green (True), then Go; else Stop.
Programming → if (marks >= 40) then "Pass" else "Fail".
BOOLEAN LOGIC
Boolean Logic is a system of logic based on two values:
1 (True / Yes)
0 (False / No)
It was developed by George Boole in the mid-1800s and is the foundation of digital
electronics, circuits, and programming.
Computers use Boolean operations (AND, OR, NOT, etc.) to make decisions and perform
calculations.
🔹 Basic Boolean Operations and Truth Tables
1. AND ( ∧ )
Output is True (1) only if both inputs are True.
A B A AND B
0 0 0
0 1 0
1 0 0
1 1 1
2. OR ( ∨ )
Output is True (1) if any one input is True.
A B A OR B
0 0 0
0 1 1
10 1
1 1 1
3. NOT ( ¬ or overline )
Flips the input.
If input is 1 → output is 0.
If input is 0 → output is 1.
A NOT A
0 1
1 0
🔹 Other Useful Operations
4. NAND (NOT AND)
Opposite of AND.
A B A NAND B
0 0 1
0 1 1
1 0 1
1 1 0
5. NOR (NOT OR)
Opposite of OR.
A B A NOR B
0 0 1
0 1 0
1 0 0
1 1 0
6. XOR (Exclusive OR)
Output is True (1) only if inputs are different.
A B A XOR B
0 0 0
0 1 1
1 0 1
1 1 0
✅ Summary:
Boolean Logic uses 1 (True) and 0 (False).
It is the basis of logic gates, circuits, and programming conditions.
Example 1: Expression → F=A⋅BF(AND)
A B F = A AND B
0
0 0
0 1 0
1 0 0
1 1 1
✅ F = 1 only when both A and B are 1
Example 2: Expression → F=A+BF(OR)
A B F = A OR B
0 0 0
0 1 1
1 0 1
1 1 1
✅ F = 1 if at least one input is 1
Example 3: Expression → F=A‾F (NOT)
A F = NOT A
0 1
1 0
✅ Flips the input
Example 4: Expression → F=A⋅B‾F (A AND NOT B)
A B NOT B F = A AND NOT B
0 0 1 0
0 1 0 0
1 0 1 1
1 1 0 0
✅ F = 1 only when A=1 and B=0
Example 5: Expression → F=A⊕BF (XOR)
A B F = A XOR B
0 0 0
0 1 1
1 0 1
1 1 0
✅ F = 1 only when inputs are different
APPLICATIONS OF PROPOSITIONAL LOGIC
1. Digital Circuits & Computer Hardware
Logic gates (AND, OR, NOT, NAND, NOR, XOR) are built using propositional
logic.
Example: Designing CPUs, memory units, and control circuits.
2. Programming & Algorithms
Conditional statements in programming (if, else, while, etc.) are based on
propositional logic.
Example: if (marks >= 40 AND attendance >= 75) → Pass.
3. Artificial Intelligence & Expert Systems
Used to represent knowledge and perform automated reasoning.
Example: AI chatbots, medical diagnosis systems (e.g., "If patient has fever AND
cough → possible flu").
4. Database Queries
SQL uses propositional logic in conditions.
Example: SELECT * FROM Students WHERE Age > 18 AND Grade = 'A';
5. Mathematical Proofs & Theorems
Propositional logic is used to prove mathematical theorems systematically.
Example: Proof by contradiction, logical equivalences.
6. Network Security & Cryptography
Firewalls and security policies rely on logical rules.
Example: “Allow access if (user authenticated AND not blacklisted).”
7. Software Testing & Verification
Ensures correctness of programs by checking logical conditions.
Example: Verifying that a program never enters an invalid state.
8. Search Engines & Information Retrieval
Boolean operators (AND, OR, NOT) are used in search queries.
Example: "machine learning" AND "applications" retrieves results containing both.
✅ In summary:
Propositional logic is the backbone of digital electronics, computer programming, AI,
databases, mathematics, and security systems.