Current Affairs updated daily
KalviGavaniKalviGavani

CBSE Class 11 Computer Science Chapter 4 Notes: Introduction to Problem Solving

Complete NCERT-aligned guide for CBSE Class 11 Computer Science Chapter 4 — Introduction to Problem Solving covering algorithms, flowcharts, pseudocode, step-by-step problem solving with exam tips and revision notes.

Updated 11 June 202616 min read

Exercise Solutions Available

Step-by-step answers for all textbook questions in this chapter

View Solutions →

CBSE Class 11 Computer Science Chapter 4: Introduction to Problem Solving

Chapter Introduction

Computers are powerful tools, but they cannot solve problems on their own. Before a computer can execute a solution, a human must first figure out how to solve the problem and express that solution in a form the computer can understand. This chapter teaches you the fundamental methodology of problem solving in computer science.

You will learn how to break down a problem, design a solution using algorithms, represent that solution visually with flowcharts, describe it in structured pseudocode, and verify that your solution works correctly. These skills form the foundation for all programming you will do in later chapters.

By the end of this chapter, you should be able to approach any computational problem systematically, write clear algorithms, draw correct flowcharts, write structured pseudocode, and identify errors in your solutions.


Key Definitions

TermDefinition
Problem SolvingThe process of identifying a problem, designing a solution, and implementing it
AlgorithmA step-by-step procedure to solve a problem in a finite number of well-defined steps
FlowchartA pictorial representation of an algorithm using standard symbols connected by arrows
PseudocodeAn informal, high-level description of an algorithm using structured English-like statements
Syntax ErrorAn error caused by violating the grammatical rules of a programming language
Logical ErrorAn error where the program runs but produces incorrect results due to flawed logic
Runtime ErrorAn error that occurs during program execution, causing the program to crash or behave unexpectedly
DebuggingThe process of finding and fixing errors (bugs) in a program
TestingThe process of running a program with various inputs to verify it produces correct output

Detailed Concepts

1. Steps in Problem Solving

Problem solving in computer science follows a structured methodology. Skipping steps leads to incorrect or inefficient solutions. The six standard steps are:

Step 1: Understanding the Problem

Before writing any code, you must fully understand what the problem is asking. Read the problem statement carefully. Identify the given inputs, the required outputs, and any constraints.

Questions to ask yourself:

  • What data is given?
  • What result is expected?
  • Are there any restrictions or special conditions?
  • What are the boundary cases?

Example: "Write a program to find the largest of three numbers." Here, the input is three numbers and the output is the maximum among them.

Step 2: Analysing the Problem

Break the problem into smaller parts. Identify the logic needed. Consider different approaches and choose the most efficient one.

For the "largest of three numbers" problem:

  • Compare the first number with the second
  • Compare the larger of those with the third
  • The result is the largest number

Step 3: Designing the Solution

Develop the algorithm. Write the steps clearly and in the correct order. You can express the solution as an algorithm, a flowchart, or pseudocode.

Step 4: Coding the Solution

Translate the algorithm or pseudocode into an actual programming language (Python in the CBSE curriculum). Follow the syntax rules of the language.

Step 5: Testing and Debugging

Run the program with different inputs to check for correctness. If errors are found, debug and fix them. Test with:

  • Normal inputs
  • Boundary inputs (minimum, maximum, zero)
  • Invalid inputs (if applicable)

Step 6: Maintenance

After deployment, programs may need updates due to changing requirements, bug fixes, or performance improvements.


2. Algorithms

Definition

An algorithm is a well-defined, step-by-step procedure that takes some input and produces a definite output in a finite number of steps. It is language-independent — it describes the logic, not the code.

Properties of a Good Algorithm

PropertyMeaningWhy It Matters
FinitenessThe algorithm must terminate after a finite number of stepsAn infinite loop is not a valid algorithm
DefinitenessEach step must be clear and unambiguousAmbiguous steps lead to different interpretations
InputAn algorithm may have zero or more inputsSome algorithms work on fixed data (no input needed)
OutputAn algorithm must produce at least one outputAn algorithm with no output serves no purpose
EffectivenessEach step must be basic enough to be carried out exactlyA step that cannot be performed is useless

Example 1: Algorithm to Find the Sum of Two Numbers

Step 1: START Step 2: Read the first number, A Step 3: Read the second number, B Step 4: Calculate SUM = A + B Step 5: Display SUM Step 6: STOP

Example 2: Algorithm to Find the Maximum of Three Numbers

Step 1: START Step 2: Read three numbers A, B, C Step 3: Set MAX = A Step 4: If B > MAX, then set MAX = B Step 5: If C > MAX, then set MAX = C Step 6: Display MAX Step 7: STOP

Example 3: Algorithm to Check if a Number is Even or Odd

Step 1: START Step 2: Read the number N Step 3: Calculate REMAINDER = N MOD 2 Step 4: If REMAINDER = 0, then display "Even" Step 5: Else, display "Odd" Step 6: STOP

Example 4: Algorithm to Calculate the Factorial of a Number

Step 1: START Step 2: Read the number N Step 3: Set FACT = 1, Set I = 1 Step 4: Repeat Steps 5-6 while I <= N Step 5: Set FACT = FACT * I Step 6: Set I = I + 1 Step 7: Display FACT Step 8: STOP

3. Flowcharts

Definition

A flowchart is a visual representation of an algorithm. It uses standard geometric symbols connected by arrows (flow lines) to show the sequence of operations. Flowcharts make it easy to understand the logic at a glance.

Standard Flowchart Symbols

SymbolShapePurposeExample Use
TerminalOval / Rounded rectangleStart or End of the programSTART, STOP
ProcessRectangleProcessing or calculation stepSUM = A + B
Input/OutputParallelogramReading input or displaying outputRead A, Display SUM
DecisionDiamondConditional check with Yes/No branchesIs A > B?
Flow LineArrowDirection of flow between stepsConnects symbols
ConnectorSmall circleConnects parts of a flowchart across pagesUsed in large flowcharts
Predefined ProcessRectangle with double side edgesCall to a sub-procedure or functionCALL Sort_Array

Rules for Drawing Flowcharts

1. Always start with a START terminal symbol and end with a STOP terminal symbol. 2. The flow direction should generally be top-to-bottom or left-to-right. 3. Only one flow line should enter a decision symbol, but two flow lines (Yes and No) should exit it. 4. Only one flow line should come out of a process symbol. 5. Flow lines must not cross each other. If they must, use connectors. 6. Every decision symbol must have two outgoing paths (Yes and No). 7. The flowchart must be complete — every path must lead to the STOP symbol. 8. Keep the flowchart simple and readable. Avoid too many crossing lines.

Example 1: Flowchart for Sum of Two Numbers

[START] | [/Read A, B/] | [SUM = A + B] | [/Display SUM/] | [STOP]

Step-by-step description: 1. Begin at the START oval 2. Read two numbers A and B (parallelogram) 3. Calculate SUM = A + B (rectangle) 4. Display the result SUM (parallelogram) 5. End at the STOP oval

Example 2: Flowchart for Finding Maximum of Three Numbers

[START] | [/Read A, B, C/] | [MAX = A] | <B > MAX?> / \ Yes No | | [MAX = B] | | | +----+------+ | <C > MAX?> / \ Yes No | | [MAX = C] | | | +----+------+ | [/Display MAX/] | [STOP]

Step-by-step description: 1. Start the program 2. Read three numbers A, B, C 3. Assume A is the maximum (MAX = A) 4. Check if B is greater than MAX. If yes, update MAX = B 5. Check if C is greater than MAX. If yes, update MAX = C 6. Display the value of MAX 7. Stop the program

Example 3: Flowchart for Even or Odd Check

[START] | [/Read N/] | [R = N MOD 2] | <R = 0?> / \ Yes No | | [/Display [/Display "Even"/] "Odd"/] | | +----+------+ | [STOP]

4. Pseudocode

Definition

Pseudocode is an informal way of describing an algorithm using a structured English-like language. It is not actual code — it does not follow the syntax of any specific programming language. However, it uses programming constructs (IF-THEN-ELSE, WHILE, FOR) to make the logic clear and easy to translate into real code.

Writing Conventions for Pseudocode

1. Use uppercase for keywords: IF, THEN, ELSE, WHILE, FOR, REPEAT, ENDIF, ENDWHILE 2. Use indentation to show the structure (nested blocks) 3. Use assignment with the equals sign or arrow: SUM = A + B or SUM <- A + B 4. Write one statement per line 5. Use meaningful variable names 6. Use READ for input and DISPLAY or PRINT for output 7. End control structures with ENDIF, ENDWHILE, or ENDFOR

Example 1: Pseudocode for Sum of Two Numbers

READ A READ B SUM = A + B DISPLAY SUM

Example 2: Pseudocode for Maximum of Three Numbers

READ A, B, C MAX = A IF B > MAX THEN MAX = B ENDIF IF C > MAX THEN MAX = C ENDIF DISPLAY MAX

Example 3: Pseudocode for Factorial of a Number

READ N FACT = 1 I = 1 WHILE I <= N DO FACT = FACT * I I = I + 1 ENDWHILE DISPLAY FACT

Example 4: Pseudocode for Even or Odd Check

READ N IF N MOD 2 = 0 THEN DISPLAY "Even" ELSE DISPLAY "Odd" ENDIF

Example 5: Pseudocode for Finding the Sum of First N Natural Numbers

READ N SUM = 0 FOR I = 1 TO N DO SUM = SUM + I ENDFOR DISPLAY SUM

5. Comparison: Algorithm vs Flowchart vs Pseudocode

AspectAlgorithmFlowchartPseudocode
FormText-based, step-by-stepDiagram with symbolsStructured English-like text
Ease of understandingModerateHigh (visual)Moderate to High
Ease of writingEasyTime-consuming (drawing)Easy
ModificationEasy to modifyDifficult to redrawEasy to modify
Language dependencyNoneNoneNone (but close to code)
Best used forSimple logicComplex branching logicQuick design before coding
StandardisationNo fixed formatStandard symbols (ANSI)No fixed format
Translation to codeModerate effortModerate effortEasy (closest to code)

When to use what:

  • Use an algorithm when the logic is simple and you want to describe it in plain language.
  • Use a flowchart when the logic involves complex decisions and loops, or when you need to communicate the logic visually.
  • Use pseudocode when you want to quickly sketch the logic before writing actual code.

6. Debugging and Testing

What is Debugging?

Debugging is the process of identifying, analysing, and removing errors from a program. The term comes from an actual bug (a moth) found in a Harvard Mark II computer in 1947.

Types of Errors

Error TypeWhen It OccursCauseExampleDetection
Syntax ErrorDuring compilation or before executionViolating language grammar rulesMissing colon, unmatched parentheses, wrong keywordCompiler or interpreter reports the error with line number
Logical ErrorDuring execution; program runs but gives wrong outputFlawed algorithm or incorrect logicUsing > instead of >=, wrong formulaCareful testing with known inputs and expected outputs
Runtime ErrorDuring execution; program crashes or stops unexpectedlyOperation that cannot be performedDivision by zero, accessing invalid array index, running out of memoryProgram stops with an error message

How to Debug a Program

1. Reproduce the error: Run the program with the same input that caused the problem 2. Locate the error: Use print statements or a debugger to trace variable values step by step 3. Analyse the cause: Understand why the error occurs at that point 4. Fix the error: Modify the code to correct the logic or syntax 5. Retest: Run the program again with the same and additional inputs to verify the fix

Types of Testing

TypeDescriptionExample
Unit TestingTesting individual functions or modulesTesting a sort function with various inputs
Integration TestingTesting how multiple modules work togetherTesting a program that uses input, processing, and output modules
Black-box TestingTesting based on input and output without looking at codeGiving test inputs and checking if output is correct
White-box TestingTesting based on knowledge of internal code structureChecking every branch and loop path executes correctly
Stress TestingTesting with extreme or large inputsFinding factorial of a very large number

Test Case Design

A good test case includes:

  • Input: The data provided to the program
  • Expected Output: What the correct result should be
  • Actual Output: What the program actually produces
ResultPass or Fail

Example test cases for "maximum of three numbers":

Test CaseInput (A, B, C)Expected OutputPurpose
15, 3, 88Third number is largest
210, 7, 210First number is largest
34, 9, 69Second number is largest
45, 5, 55All equal
5-3, -7, -1-1Negative numbers
60, 0, 00All zeros

Common Mistakes

1. Skipping the understanding step: Jumping into coding without fully understanding the problem leads to wasted effort. Always read the problem twice and identify inputs, outputs, and constraints.

2. Not checking algorithm properties: Writing an algorithm that does not terminate (infinite loop) violates the finiteness property. Always ensure your algorithm has a clear stopping condition.

3. Using the wrong flowchart symbol: Using a rectangle for input/output or a parallelogram for processing. Memorise the standard symbols — oval for terminal, rectangle for process, parallelogram for I/O, diamond for decision.

4. Incomplete decision branches in flowcharts: Drawing a diamond with only one exit path. Every decision must have two outcomes (Yes and No). Both paths must eventually lead to the STOP symbol.

5. Writing pseudocode like actual code: Pseudocode should be language-independent. Avoid language-specific syntax like print() or scanf(). Use READ and DISPLAY instead.

6. Confusing logical errors with syntax errors: A syntax error prevents the program from running. A logical error allows the program to run but produces wrong results. Know the difference.

7. Not testing with edge cases: Testing only with normal inputs misses boundary conditions. Always test with zero, negative numbers, maximum values, and duplicate values.

8. Overcomplicating simple algorithms: Writing 20 steps when 5 will do. A good algorithm is simple and direct. If your algorithm is getting long, reconsider your approach.


Exam Tips

1. Practise writing algorithms in the standard format: Use Step 1, Step 2, etc. Start with START and end with STOP. This format is expected in board exams.

2. Memorise all six flowchart symbols and their shapes: Questions often ask you to identify or draw specific symbols. Draw them neatly and label them.

3. Draw flowcharts with a pencil and ruler: In the exam, neat flowcharts score better. Use proper shapes — ovals for terminals, diamonds for decisions, straight arrows for flow.

4. Always label decision branches: Write "Yes" and "No" (or "True" and "False") on the two outgoing arrows from a diamond. Unlabelled branches lose marks.

5. Write pseudocode with proper indentation: Indentation shows the structure of IF-ELSE and WHILE blocks. Without it, the examiner cannot follow your logic.

6. Know the difference between the three error types: Questions frequently ask you to classify an error as syntax, logical, or runtime. Practise with examples of each.

7. Prepare at least 5 standard algorithms: Sum of two numbers, maximum of three numbers, even/odd check, factorial, and sum of first N natural numbers. These are the most commonly asked.

8. Use comparison tables for "difference between" questions: When asked to compare algorithm vs flowchart or syntax error vs logical error, a table with 4-5 rows is concise and scores well.

9. Do not forget the ENDIF and ENDWHILE in pseudocode: Every IF must have an ENDIF. Every WHILE must have an ENDWHILE. Missing these is a common mistake that costs marks.

10. Understand the problem solving steps in order: Understanding, Analysing, Designing, Coding, Testing, Maintenance. A question asking "What are the steps in problem solving?" is almost guaranteed.


Quick Revision Notes

  • Problem solving has 6 steps: Understand, Analyse, Design, Code, Test, Maintain.
  • Algorithm must have: Finiteness, Definiteness, Input, Output, Effectiveness.
  • Flowchart symbols: Oval (Start/End), Rectangle (Process), Parallelogram (I/O), Diamond (Decision), Arrow (Flow).
  • Flowchart rules: One entry into diamond, two exits (Yes/No), flow goes top-to-bottom, no crossing lines.
  • Pseudocode uses structured English with keywords: IF-THEN-ELSE-ENDIF, WHILE-DO-ENDWHILE, FOR-TO-ENDFOR.
  • Syntax errors are caught before execution (wrong grammar).
  • Logical errors produce wrong output (wrong formula or condition).
  • Runtime errors occur during execution (division by zero, out of memory).
  • Debugging = find the error, locate it, fix it, retest.
  • Testing types: Unit, Integration, Black-box, White-box, Stress.
  • Always test with boundary cases: zero, negative, maximum, duplicates.
  • Algorithm = text steps, Flowchart = visual diagram, Pseudocode = code-like English.
  • In flowcharts, every path must lead to STOP — no dead ends.
  • Pseudocode is closest to actual code and easiest to translate into a programming language.

Frequently Asked Questions

An algorithm is a step-by-step procedure to solve a problem in a finite number of well-defined steps. It must have a clear input, output, and finite termination.