0% found this document useful (0 votes)
1 views15 pages

CHAPTER 4- Introduction to Promblem Sloving

Chapter 4 introduces problem solving in computer science, emphasizing the need for precise algorithms and systematic approaches to identify and solve problems. It outlines the steps of problem solving, including analyzing the problem, developing algorithms, coding, and testing, while also discussing the importance of flowcharts and pseudocode for algorithm representation. Additionally, it highlights the significance of verifying algorithms and comparing them based on time and space complexity.
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)
1 views15 pages

CHAPTER 4- Introduction to Promblem Sloving

Chapter 4 introduces problem solving in computer science, emphasizing the need for precise algorithms and systematic approaches to identify and solve problems. It outlines the steps of problem solving, including analyzing the problem, developing algorithms, coding, and testing, while also discussing the importance of flowcharts and pseudocode for algorithm representation. Additionally, it highlights the significance of verifying algorithms and comparing them based on time and space complexity.
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

CHAPTER 4: INTRODUCTION TO PROBLEM SOLVING

INTRODUCTION

➢ Computers are used for various tasks in a faster and more accurate manner (e.g., online train ticket
booking).
➢ Computerisation: Use of computers to develop software to automate routine human tasks efficiently.
➢ Computers themselves cannot solve problems; they require precise step-by-step instructions.
➢ Computer Science is a science of abstraction — creating the right model for a problem and devising
appropriate mechanizable techniques to solve it.
➢ Problem solving is the process of:
➢ Identifying a problem
➢ Developing an algorithm
➢ Implementing the algorithm as a program
STEPS FOR PROBLEM SOLVING
➢ The mechanic will analyse the problem to identify the source of the noise, make a plan about the
work to be done and finally repair the vehicle in order to remove the noise.
➢ A systematic approach is required for solving complex problems.
➢ Problem solving begins with the precise identification of the problem and ends with a complete
working solution in terms of a program or software.
➢ GIGO (Garbage In Garbage Out)-The correctness of the output that a computer gives depends upon
the correctness of input provided.
Steps

Analysing the problem

Developing an algorithm

Coding

Testing and Debugging

Analysing the Problem


➢ It is important to clearly understand a problem before we begin to find the solution for it.
➢ To read and analyse the problem statement carefully in order to list the principal components of the
problem and decide the core functionalities that our solution should have.
➢ By analysing a problem, we would be able to figure out
• what are the inputs that our program should accept
• the outputs that it should produce.
Developing an Algorithm

➢ It is essential to device a solution before writing a program code for a given problem.
➢ The solution is represented in natural language and is called an algorithm.
➢ A set of exact steps which when followed, solve the problem or accomplish the required task is know
as Algorithm.
➢ Should be refined until it captures all aspects of the desired solution.
➢ Multiple algorithms possible; choose the most suitable.
Coding

➢ Convert algorithm into understood by the computer to generate the desired solution, so code should
be program using a high-level programming language such as C++,Java, python.
➢ Document the coding procedure for future reference.

Testing and Debugging

➢The program created should be tested on various parameters


➢The program should meet the requirements of the user.
➢It must respond within the expected time.
➢It should generate correct output for all possible inputs.
➢In the presence of syntactical errors, no output will be obtained.
➢Software industry follows standardised testing methods like unit or component testing, integration
testing, system testing, and acceptance testing while developing complex applications.
➢ The errors or defects found in the testing phases are debugged or rectified and the program is again
tested. This continues till all the errors are removed from the program.
ALGORITHM
A finite sequence of steps to accomplish a task and get desired output.
Example: Steps for riding a bicycle.
1) remove the bicycle from the stand,
2) sit on the seat of the bicycle,
3) start peddling,
4) use breaks whenever needed and
5) stop on reaching the destination.
Algorithm has a definite beginning and a definite end, and consists of a finite number of steps.
Note: The origin of the term Algorithm is traced to Persian astronomer and mathematician, Abu Abdullah
Muhammad ibn Musa Al-Khwarizmi (c. 850 AD) as the Latin translation of AlKhwarizmi was called
‘Algorithmi’

Why do we need an Algorithm?

Provides a roadmap before writing code.


Increases reliability, accuracy, and efficiency.
Examples: Search engines, messaging, online banking, games.

REPRESENTATION OF ALGORITHMS
There are two common methods of representing an algorithm —flowchart and pseudocode.
Either of the methods can be used to represent an algorithm while keeping in mind the following:
• it showcases the logic of the problem solution, excluding any implementational details
• it clearly reveals the flow of control during execution of the program

Flowchart — Visual Representation of Algorithms


A flowchart is a visual representation of an algorithm.
A flowchart is a diagram made up of boxes, diamonds and other shapes, connected by arrows.

Example: Write an algorithm to find the square of a number.

Algorithm

Step 1: Input a number and store it to num

Step 2: Compute num * num and store it in square (square = num*num)

Step 3: Print square

4.4.2 Pseudocode

A pseudocode (pronounced Soo-doh-kohd) is another way of representing an algorithm.


Non-formal language for writing algorithms.
Human-readable, not executable directly.
The word “pseudo” means “not real,” so “pseudocode” means “not real code”.
Keywords: INPUT, COMPUTE, PRINT, INCREMENT, DECREMENT, IF/ELSE, WHILE, etc.
Example Find the sum of two numbers

INPUT num1

INPUT num2

COMPUTE Result = num1 + num2


PRINT Result

Flowchart:

Example 4.4: Area and perimeter of rectangle

INPUT length

INPUT breadth

COMPUTE Area = length * breadth

PRINT Area

COMPUTE Perim = 2 * (length + breadth)


PRINT Perim

Benefits of Pseudocode:

➢ Helps represent basic functionality before coding.


➢ Safeguards against missing steps.
➢ Easier for non-programmers to review.

4.5 FLOW OF CONTROL

➢ The flow of control depicts the flow of events as represented in the flow chart.
➢ The events can flow in a sequence, or on branch based on a decision or even repeat some part for a
finite number of times.
Three types:
Sequence
➢ The statements are executed one after another, i.e., in a sequence.
➢ Such algorithms where all the steps are executed one after the other are said to execute in sequence.
Selection
➢ Conditionals are used to check possibilities.
➢ The program checks one or more conditions and perform operations (sequence of actions) depending
on true or false value of the condition.
➢ These true or false values are called binary values.

.
Example: Algorithm for a card game called “Dragons and Wizards”.
Make two teams DRAGONS and WIZARDS The rules for the game are as follows:
• If the card drawn is a diamond or a club, Team DRAGONS gets a point
• If the card drawn is a heart which is a number, Team WIZARDS gets a point
• If the card drawn is a heart that is not a number, Team DRAGONS gets a point
• For any other card, Team WIZARDS gets a point
• The team with highest point is the winner
Let us identify the following for a card:
Input: shape, value
Process: Increment in respective team scores by one based on the outcome of the card drawn, as defined in
the rules.
Output: Winning team
Now let us write the conditionals for this game:
IF (shape is diamond) OR (shape is club)
Team DRAGONS gets a point
ELSE IF (shape is heart) AND (value is number)
Team WIZARDS gets a point
ELSE IF (shape is heart) AND (value is not a number)
Team DRAGONS gets a point
ELSE
Team WIZARDS gets a point
Note: Dpoint (for Dragon) and Wpoint (for Wizard) store points scored by the respective teams.
INPUT shape INPUT value
SET Dpoint = 0, Wpoint = 0
IF (shape is diamond) OR (shape is club) THEN
INCREMENT Dpoint
ELSE IF (shape is heart) AND (value is number)THEN
INCREMENT Wpoint
ELSE IF (shape is heart) AND (value is not a number)THEN
INCREMENT Dpoint
ELSE
INCREMENT Wpoint
END IF
If Dpoint > Wpoint THEN
PRINT "Dragon team is the winner"
ELSE
PRINT "Wizard team is the winner"

Repetition
➢ A loop in an algorithm means execution of some program statements repeatedly till some specified
condition is satisfied.
➢ In programming, repetition is also known as iteration or loop.
Example 4.8: Write pseudocode and draw a flowchart to accept 5 numbers and find their average.
Pseudocode will be as follows:
Step 1: Set count = 0, sum = 0
Step 2: While count<5, REPEAT Steps3 to 5
Step 3: INPUT a number to num
Step 4: sum=sum+num
Step 5: count=count+1
Step 6:COMPUTE average=sum/5
Step 7: PRINT average

4.6 VERIFYING ALGORITHMS

Essential to ensure correctness.


Dry run: Simulate with sample inputs.
Helps identify incorrect/missing steps.
Example: Adding time in hours/minutes
required adjustment for minutes ≥ 60.
PRINT value for T1
INPUT hh1 INPUT mm1
PRINT value for T2
INPUT hh2
INPUT mm2
hh_total = hh1 + hh2 (Add hours)
mm_total = mm1 + mm2 (Add mins)
Print T_total as hh_total, mm_total
Now let us verify. Suppose the first example we take is T1 = 5 hrs 20 mins and T2 = 7 hrs 30 mins. On dry
run, we get the result 12 hrs and 50 mins. This looks fine.

Now let us take another example where T1 = 4 hrs 50 mins and T2 = 2 hrs 20 mins, and we end up getting
the result as 6 hrs 70 mins which is not how we measure time. The result should have been 7 hrs 10 mins.
So the modified algorithm will be:
PRINT value for T1
INPUT hh1
INPUT mm1
PRINT value for T2
INPUT hh2
INPUT mm2 hh_
total = hh1 + hh2 (Add hours)
mm_total = mm1 + mm2 (Add mins)
hh_total = hh1 + hh2 (Add hours)
mm_total = mm1 + mm2 (Add mins)
IF (mm_total >= 60) THEN
hh_total = hh_total + 1
mm_total = mm_total - 60
PRINT T_total as hh_total, mm_total

4.7 COMPARISON OF ALGORITHM

Multiple algorithms possible for same problem.


Compare based on:
Time complexity: Processing time
Space complexity: Memory used
Example: Checking prime number (four methods with varying efficiency).

Algorithm (i) requires large number of calculations (means more processing time) as it checks for all the
numbers as long as the divisor is less than the number. If the given number is large, this method will take
more time to give the output.
Algorithm (ii) is more efficient than (i) as it checks for divisibility till half the number, and thus it reduces
the time for computation of the prime number.
Algorithm (iii) is even more efficient as it checks for divisibility till square root of the number, thereby
further reducing the time taken.
Algorithm (iv) uses only the prime numbers smaller than the given number for divisibility, it further reduces
the calculations. But in this method we require to store the list of prime numbers first. Thus it takes
additional memory even though it requires lesser calculations.
Hence, algorithms can be compared and analysed on the basis of the amount of processing time they need to
run and the amount of memory that is needed to execute the algorithm. These are termed as time complexity
and space complexity, respectively
4.8 CODING

Translate algorithm into high-level language (Python, Java, C++, etc.).


Syntax: Rules governing language.
Source code: Program in high-level language.
Requires compiler/interpreter to convert to machine language.
Choice depends on platform (desktop, mobile, web, embedded systems).

4.9 DECOMPOSITION

Breaking complex problem into smaller sub-problems.


Example: Railway reservation system divided into:
Summary

• An algorithm is defined as a step-by-step procedure designed to perform an operation which will lead to
the desired result, if followed correctly.
• Algorithms have a definite beginning and a definite end, and a finite number of steps.
• A good algorithm, which is precise, unique and finite, receives input and produces an output
• In order to write effective algorithms we need to identify the input, the process to be followed and the
desired output.
• A flowchart is a type of diagram that represents the algorithm graphically using boxes of various kinds, in
an order connected by arrows.
• An algorithm where all the steps are executed one after the other is said to execute in sequence.
• Decision making involves selection of one of the alternatives based on outcome of a condition.
• An algorithm may have a certain set of steps, which are repeating for a finite number of times, such an
algorithm is said to be iterative.
• There can be more than one approach to solve a problem and hence we can have more than one algorithm
for a particular problem.
• The choice of algorithm should be made on the basis of time and space complexity.

NCERT EXERCISE SOLUTIONS

1. Write pseudocode that reads two numbers and divide one by another and display the quotient.
2. Two friends decide who gets the last slice of a cake by flipping a coin five times. The first person to win
three flips wins the cake. An input of 1 means player 1 wins a flip, and a 2 means player 2 wins a flip.
Design an algorithm to determine who takes the cake?
3. Write the pseudocode to print all multiples of 5 between 10 and 25 (including both 10 and 25).
4. Give an example of a loop that is to be executed a certain number of times.
5. Suppose you are collecting money for something. You need ₹200 in all. You ask your parents, uncles and
aunts as well as grandparents. Different people may give either ₹10, ₹20 or even ₹50. You will collect till the
total becomes 200. Write the algorithm.
6. Write the pseudocode to print the bill depending upon the price and quantity of an item. Also print Bill
GST, which is the bill after adding 5% of tax in the total bill.
7. Write pseudocode that will perform the following:
a) Read the marks of three subjects: Computer Science, Mathematics and Physics, out of 100
b) Calculate the aggregate marks
c) Calculate the percentage of marks
8. Write an algorithm to find the greatest among two different numbers entered by the user.
9. Write an algorithm that performs the following:
Ask a user to enter a number. If the number is between 5 and 15, write the word GREEN. If the number is
between 15 and 25, write the word BLUE. If the number is between 25 and 35, write the word ORANGE. If
it is any other number, write that ALL COLOURS ARE BEAUTIFUL.
10. Write an algorithm that accepts four numbers as input and find the largest and smallest of them.
11. Write an algorithm to display the total water bill charges of the month depending upon the number of
units consumed by the customer as per the following criteria:
• for the first 100 units @ 5 per unit
• for next 150 units @ 10 per unit
• more than 250 units @ 20 per unit
Also add meter charges of 75 per month to calculate the total water bill.
12. What are conditionals? When they are required in a program?
13. Match the pairs

14. Following is an algorithm for going to school or college. Can you suggest improvements in this to
include other options?
Reach School Algorithm
a) Wake up
b) Get ready
c) Take lunch box
d) Take bus
e) Get off the bus
f) Reach school or college
15. Write a pseudocode to calculate the factorial of a number (Hint: Factorial of 5, written as 5! = 5 × 4 × 3
× 2 × 1).
16. Draw a flowchart to check whether a given number is an Armstrong number. An Armstrong number of
three digits is an integer such that the sum of the cubes of its digits is equal to the number itself. For
example, 371 is an Armstrong number since 3^3 + 7^3 + 1^3 = 371.
17. Following is an algorithm to classify numbers as “Single Digit”, “Double Digit” or “Big”.
Classify Numbers Algo
INPUT Number
IF Number < 9
"Single Digit"
Else If Number < 99
"Double Digit"
Else
"Big"
Verify for (5, 9, 47, 99, 100 200) and correct the algorithm if required
18. For some calculations, we want an algorithm that accepts only positive integers upto 100.
Accept_1to100_Algo
INPUT Number
IF (0<= Number) AND (Number <= 100)
ACCEPT
Else
REJECT
a) On what values will this algorithm fail?
b) Can you improve the algorithm?
QUESTIONS

Multiple Choice Questions (MCQs)


1. What is the primary purpose of computerisation?
(a) To write algorithms (b) To develop software for automating tasks
(c) To draw flowcharts (d) To test programs
2. Which of the following is the correct sequence of steps in problem solving?
(a) Coding → Testing → Algorithm → Analysis (b) Analysis → Algorithm → Coding → Testing
(c) Algorithm → Analysis → Testing → Coding (d) Testing → Analysis → Coding → Algorithm
3. The term "algorithm" is historically derived from the work of:
(a) Albert Einstein (b) Alan Turing
(c) Abu Abdullah Muhammad ibn Musa Al-Khwarizmi (d) Ada Lovelace
4. Which characteristic of an algorithm ensures it will eventually stop?
(a) Precision (b) Uniqueness (c) Finiteness (d) Input
5. What is the first step a programmer should take after understanding a problem?
(a) Start coding in Python (b) Develop an algorithm
(c) Draw a flowchart (d) Choose a compiler
6. Which of these is NOT a standard step in software testing?
(a) Unit Testing b) Integration Testing (c) Decomposition Testing (d) Acceptance Testing
7. In a flowchart, which symbol is used to represent a process or action step?
(a) Oval (b) Diamond (c) Rectangle (d) Parallelogram
8. What is the main purpose of using pseudocode?
(a) To make the code run faster (b) To represent the logic of an algorithm in a human-readable way
(c) To directly execute the program (d) To draw visual diagrams
9. Which pseudocode keyword is typically used for repetitive execution?
(a) INPUT (b) IF (c) WHILE (d) COMPUTE
10. The flow of control where instructions are executed one after another is called:
(a) Selection (b) Sequence (c) Repetition (d) Decomposition
11. In the context of problem solving, what does "debugging" mean?
(a) Writing the initial algorithm (b) Identifying and removing errors from a program
(c) Drawing a flowchart (d) Analysing the user requirements
12. Which of the following is an example of a selection control structure?
(a) Printing numbers from 1 to 10 (b) Adding two numbers
(c) Checking if a number is positive or negative (d) Finding the sum of an array
13. What is the purpose of a "dry run"?
(a) To execute the final program on a computer
(b) To manually simulate an algorithm with sample data
(c) To write pseudocode (d) To choose a programming language
14. When comparing algorithms, "time complexity" refers to:
(a) The time of day the program is run (b) The amount of processing time required
(c) The date the algorithm was written (d) The lifespan of the software
15. The set of rules that govern the structure of statements in a programming language is called:
(a) Algorithm (b) Logic (c) Syntax (d) Semantics
16. Which of these is a key advantage of high-level programming languages over low-level languages?
(a) They execute faster (b) They are directly understood by the CPU
(c) They are portable and easier to read/write (d) They use only binary digits
17. The problem-solving approach of breaking a complex problem into smaller, manageable parts is called:
(a) Sequencing (b) Selection (c) Iteration (d) Decomposition
18. In the card game example (Dragons and Wizards), when does Team WIZARDS get a point?
(a) When a diamond is drawn (b) When a club is drawn
(c) When a numbered heart card is drawn (d) When a non-numbered heart card is drawn
19. What is the primary goal of the "Analyzing the Problem" step?
(a) To write the final code
(b) To clearly understand inputs, outputs, and requirements
(c) To choose a programming language (d) To test the user interface
20. A flowchart symbol shaped like a parallelogram is used for:
(a) Start/End (b) Decision (c) Input/Output (d) Process
21. Which of these best describes an algorithm?
(a) A programming language (b) A type of computer hardware
(c) A step-by-step procedure to solve a problem (d) A software testing tool
22. What is the final, delivered result of the coding step called?
(a) Algorithm (b) Pseudocode (c) Source Code (d) Flowchart
23. In the example of adding time (4 hrs 50 mins + 2 hrs 20 mins), what was the issue with the initial
algorithm?
(a) It used the wrong formula (b) It did not handle cases where total minutes exceeded 60
(c) It could not accept input (d) It had a syntax error
24. Which of the following is a benefit of decomposing a complex system like railway reservation?
(a) It makes the problem more complicated
(b) It allows different teams to work on different sub-problems
(c) It eliminates the need for testing (d) It reduces the need for algorithms
25. The "WHILE" loop is particularly useful when:
(a) The number of repetitions is known beforehand
(b) The number of repetitions is not known beforehand
(c) Only one condition needs to be checked (d) No repetition is needed
26. What must every algorithm have?
(a) A graphical representation (b) A definite beginning and end
(c) Written in Python (d) More than 10 steps
27. Which factor is LEAST important when choosing an algorithm from several options?
(a) Time Complexity (b) Space Complexity (c) Color of the output (d) Accuracy of the result
28. Maintenance of a software solution may involve:
(a) Only fixing initial bugs b) Fixing problems, answering user queries, and adding new features
(c) Rewriting the entire algorithm (d) Changing the programming language
29. The process of converting an algorithm into a programming language is called:
(a) Analysis (b) Debugging (c) Coding (d) Verification
30. Which of these activities is a real-life example of repetition (iteration)?
(a) Choosing what to wear based on the weather (b) Following a recipe step-by-step
(c) Clapping hands 10 times (d) Identifying the source of a strange noise in a car
31. In the context of algorithm verification, what does a successful "dry run" confirm?
(a) The program is free of syntax errors (b) The algorithm logic works for the tested inputs
(c) The user interface is attractive (d) The program is the fastest possible solution
32. What does the MOD operator do in the algorithm to check for an even number?
(a) Performs multiplication (b) Returns the quotient of division
(c) Returns the remainder of division (d) Performs addition
33. The spirit of problem solving by decomposition is summarized by which phrase?
(a) "Trial and Error" (b) "Divide and Conquer"
(c) "Back to the Drawing Board" (d) "Keep it Simple"
34. What is the main difference between a compiler and an interpreter?
(a) A compiler translates code line-by-line; an interpreter translates all at once.
(b) A compiler translates all code at once; an interpreter translates line-by-line.
(c) A compiler is used for pseudocode; an interpreter is used for flowcharts.
(d) There is no difference.
35. Which step ensures that the program will actually solve the user's original problem?
(a) Writing detailed comments (b) Thorough analysis of the problem
(c) Choosing a popular language (d) Using a fast computer
36. A program that responds within the expected time is meeting which requirement?
(a) Functional Correctness (b) Performance (c) Usability (d) Portability
37. Which of these is a binary value used in conditionals?
(a) Red/Blue (b) Yes/No (c) Large/Small (d) Fast/Slow
38. What is the primary role of a "counter" variable in a loop?
(a) To store the final output (b) To keep track of how many times the loop has executed
(c) To make decisions (d) To connect flowchart symbols
39. The "IF-ELSE" block is used to implement:
(a) Sequence (b) Selection (c) Repetition (d) Decomposition
40. Which of these is an example of a high-level language suited for web applications?
(a) Assembly (b) Machine Language (c) Python (d) Binary
41. In the light bulb problem flowchart, what is the first question asked?
(a) "Is the bulb burnt out?" (b) "Should I call an electrician?"
(c) "Is the bulb switched on?" (d) "Do I have a spare bulb?"
42. What does the arrow represent in a flowchart?
(a) Data Storage (b) The Start Point (c) The Flow of Control (d) A Calculation
43. The correctness of the formula Sum = N(N+1)/2 was verified by:
(a) Consulting an expert (b) Dry running it for small values of N
(c) Writing a program (d) Drawing a flowchart
44. What is a key disadvantage of low-level languages?
(a) They are portable. (b) They are easy for humans to read and write.
(c) They are machine-dependent. (d) They require a compiler.
45. When writing an algorithm, what must be clearly identified first?
(a) The font style for output (b) The programmer's name
(c) Input, Process, and Output (d) The cost of software
46. Which testing phase likely involves the end-user?
(a) Unit Testing (b) Integration Testing (c) System Testing (d) Acceptance Testing
47. In the age categorization example (Child, Teenager, Adult), what output is produced for Age = 13?
(a) Child (b) Teenager (c) Adult (d) Error
48. Which of these is NOT a standard shape for drawing a flowchart?
(a) Oval (b) Triangle (c) Diamond (d) Parallelogram
49. What does the "ELSE IF" construct allow?
(a) Multiple conditions to be checked in sequence (b) Infinite looping
(c) Drawing a diamond shape (d) Skipping input
50. The ultimate goal of problem solving in computer science is to:
(a) Learn many programming languages
(b) Develop a correct and efficient computer program
(c) Draw complex flowcharts (d) Buy the fastest computer
51. Assertion (A): A flowchart is a visual representation of an algorithm.
Reason (R): It uses standardized symbols to depict the flow of steps and decisions.
52. Assertion (A): An algorithm must receive some input.
Reason (R): Without input, an algorithm cannot produce any output.
53. Assertion (A): Decomposition makes it easier to solve complex problems.
Reason (R): It combines multiple small problems into one big, complex problem.
54. Assertion (A): The same problem can often be solved by multiple different algorithms.
Reason (R): The choice of algorithm depends only on the programmer's preference for a language.
55. Assertion (A): Testing and debugging continues even after software is delivered.
Reason (R): Users may encounter new problems or request new features.
Fill in the blnaks
1. The process of identifying a problem, developing an algorithm, and implementing it is called ______.
2. The __________ step in problem solving involves converting an algorithm into a programming language.
3. A set of exact steps which when followed, solve the problem is called an __________.
4. In a flowchart, the __________ symbol is used to ask a yes/no question and branch the flow.
5. The word "pseudo" in pseudocode means __________.
6. The three basic types of flow of control are sequence, selection, and __________.
7. The __________ construct is used in pseudocode to handle situations where the number of repetitions is
unknown.
8. Manually simulating an algorithm with sample data is known as a __________.
9. Algorithms are compared based on their time complexity and __________ complexity.
10. The rules governing the grammar of a programming language are called its __________.
11. Breaking down a complex problem into simpler sub-problems is called __________.
12. A good algorithm has five characteristics: Precision, Uniqueness, Finiteness, Input, and ________.
13. The term algorithm is traced to the Persian scholar __________.
14. In the example of adding time, the algorithm was modified to handle cases where total minutes were
__________.
15. Software __________ involves fixing problems and adding features after delivery.
16. In a flowchart, an arrow represents the __________ between steps.
17. The __________ of a program is its code written in a high-level language.
18. In the Dragons and Wizards game, a heart that is not a number gives a point to team __________.
19. The __________ step ensures we know what the program should accept and produce.
20. A loop that executes a fixed number of times often uses a __________ variable.
21. Programs for devices like digital watches are written for __________ systems.
22. The railway reservation system is an example of a problem solved by __________.
23. The four testing methods mentioned are unit, integration, system, and __________ testing.
24. The values TRUE and FALSE in conditionals are called __________ values.
25. An algorithm must have a definite beginning, a definite end, and a __________ number of steps.
2-MARK QUESTIONS
1. List the four main steps for problem solving using a computer.
2. Define an algorithm. Give a real-life example.
3. What is the purpose of the "decision" symbol in a flowchart?
4. Differentiate between "syntax error" and "logical error".
5. Why is documenting the code important?
6. What is the role of "conditionals" in a program?
7. Give an example of a "sequence" control structure from daily life.
8. What does the MOD operator calculate?
9. State one benefit of using a high-level programming language.
10. What is meant by "space complexity" of an algorithm?
11. What is a "counter" used for in a loop?
12. Why might a software team use decomposition?
13. What is the final output of the "Analyzing the Problem" step?
14. How does a flowchart aid in problem solving?
15. What does the "ELSE" part of an IF-ELSE statement specify?
3-MARK QUESTIONS
1. Explain the characteristics of a good algorithm: Precision, Uniqueness, and Finiteness.
2. Describe with an example how "selection" is used in programming.
3. Write a pseudocode to calculate and print the average of three numbers.
4. What are the advantages of using pseudocode over directly writing code?
5. Explain the concept of "dry run" with its importance.
6. Differentiate between Compiler and Interpreter.
7. Write an algorithm (in steps or pseudocode) to find the greater of two numbers.
8. How does decomposition help in managing a large software project like a "Railway Reservation System"?
9. Why is it said that "computers themselves cannot solve a problem"?
10. List three factors on which the choice of a programming language depends.
5-MARK QUESTIONS
1. Explain the various steps involved in problem solving in detail, with a suitable example.
2. Describe the different ways to represent an algorithm. Compare flowchart and pseudocode methods.
3. Explain with examples the three types of flow of control: Sequence, Selection, and Repetition.
4. Discuss the importance of algorithm verification. Illustrate with the "time addition" example from the
chapter.
5. What is decomposition? Explain its role in solving complex problems using the example of the Railway
Reservation System.

You might also like