⚡0 XP🔥0

Ch 4 · Introduction to Problem Solving | समस्या समाधान

Lesson 4 of 11 ⏱ 3 min read ❓ 5-question quiz ▶ Runs Python

Steps of problem solving, algorithms, flowcharts, pseudocode, decomposition, and errors - syntax, logical and run-time.

Steps#

  1. Analyse the problem (inputs, outputs, constraints).
  2. Develop an algorithm - a finite sequence of clear steps.
  3. Code it in a programming language.
  4. Test and debug.

Decomposition: break a big problem into smaller sub-problems (e.g. a railway reservation system → booking, payment, cancellation).

Representing algorithms#

  • Flowchart symbols: oval (start/stop), parallelogram (input/output), rectangle (process), diamond (decision), arrows (flow).
  • Pseudocode: English-like steps (INPUT, COMPUTE, IF … THEN, WHILE, PRINT).
Pseudocode - largest of three

INPUT a, b, c → IF a ≥ b AND a ≥ c THEN PRINT a ELSE IF b ≥ c THEN PRINT b ELSE PRINT c

हिंदी में समझें

एल्गोरिदम किसी समस्या को हल करने के स्पष्ट और सीमित चरणों का क्रम है। इसे फ़्लोचार्ट (चित्रों से) या स्यूडोकोड (सरल अंग्रेज़ी जैसे वाक्यों से) में दिखाया जाता है। बड़ी समस्या को छोटे भागों में तोड़ना 'डीकम्पोज़िशन' कहलाता है।

Errors#

Error Example
Syntax error missing colon or bracket
Logical error wrong formula - program runs but gives wrong output
Run-time error division by zero, file not found
▶ Try it YourselfPython
Ctrl + Enter to run

Exam tips#

  • Draw flowcharts for even/odd, largest of three, factorial and sum of n numbers.

Quick Quiz

Q1.

A diamond in a flowchart represents

Q2.

A finite sequence of clear steps to solve a problem is

Q3.

Dividing by zero causes a

Q4.

Breaking a problem into smaller parts is

Q5.

A program that runs but gives wrong results has a