Thanks to visit codestin.com
Credit goes to www.scribd.com

0% found this document useful (0 votes)
3 views13 pages

Introduction To Problem Solving

Uploaded by

borehalliumesh
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)
3 views13 pages

Introduction To Problem Solving

Uploaded by

borehalliumesh
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
You are on page 1/ 13

Introduction to Problem Solving

1. What is the first step in problem-solving as per the textbook?


A) Testing the solution B) Coding the algorithm
C) Analyzing the problem D) Debugging the program
2. What is an algorithm?
A) A set of exact steps to solve a problem B) A programming language

C) A type of computer hardware D) A method of debugging


3. What does the term "computerization" refer to?

A) The use of computers to develop software for automating tasks


B) The physical components of a computer system
C) The process of debugging a program D) The network connectivity of computers
4. Which of the following is NOT a characteristic of a good algorithm?

A) Precision B) Uniqueness C) Infinite steps D) Finiteness


5. What does the process of 'coding' involve?
A) Writing an algorithm B) Testing the program

C) Converting the algorithm into a format understood by the computer


D) Debugging the code
6. What shape is used to represent a process in a flowchart?
A) Parallelogram B) Rectangle C) Diamond D) Circle

7. In a flowchart, which symbol represents the start or end?


A) Diamond B) Rectangle C) Oval D) Parallelogram
8. What is the purpose of developing an algorithm before writing code?
A) To debug the program B) To convert it into machine language
C) To have a clear solution plan D) To test the program
9. Which step comes immediately after developing an algorithm?

A) Debugging B) Testing C) Coding D) Analyzing the problem


10. What does GIGO stand for?
A) Garbage In, Garbage Out B) Good Input, Good Output
C) Great Input, Great Output D) Generated Input, Generated Output
11. What does 'finiteness' in an algorithm mean?
A) The algorithm stops after a finite number of steps B) The algorithm has infinite steps
C) The algorithm has unique steps D) The algorithm processes data infinitely
12. Which of the following is an essential skill for a computer science student?

A) Problem-solving B) Debugging C) Coding D) All of the above


13. What is the output of an algorithm?
A) Input data B) A set of instructions C) The result of the process D) A debugging report
14. What does the parallelogram symbol in a flowchart represent?
A) Process B) Decision C) Input/Output D) Start/End
15. Which of the following steps is NOT part of the problem-solving process mentioned in the textbook?
A) Analyzing the problem B) Developing an algorithm
C) Compiling the code D) Testing and debugging
16. What should be done after finalizing the algorithm?
A) Debugging B) Testing C) Coding D) Analyzing the problem
17. Why is it important to textbook the coding procedures?
A) To make the code run faster B) To understand the logic at a later stage

C) To avoid writing an algorithm D) To reduce the size of the program


18. What is the role of testing in the problem-solving process?
A) To analyze the problem B) To write the algorithm
C) To check if the program meets user requirements D) To convert the algorithm into code
19. Which of the following is a key component of analyzing a problem?
A) Writing the program code B) Listing the principal components of the problem

C) Testing the solution D) Debugging the program


20. What is the primary purpose of using an algorithm?
A) To debug the program B) To test the program
C) To increase reliability, accuracy, and efficiency D) To compile the program
21. What does the diamond shape in a flowchart represent?
A) Process B) Decision C) Input/Output D) Start/End

22. Which programming language can be used to write a program after developing an algorithm?
A) Only Python B) Any high-level language C) Only Java D) Only C++
23. What must be done if the program generates incorrect output?
A) Analyze the problem B) Develop a new algorithm
C) Check for logical errors D) Ignore the output
24. Why is a roadmap important for a programmer?

A) To debug the program B) To clearly visualize the instructions to be written


C) To reduce the size of the program D) To increase the speed of the program
25. What is the function of a 'terminator' symbol in a flowchart?
A) To represent a decision point B) To indicate the start or end of the process
C) To show data input/output D) To represent a process or action
26. What should be done after coding the algorithm?
A) Analyzing the problem B) Testing and debugging
C) Developing the algorithm D) Writing the problem statement
27. Why is precision important in an algorithm?
A) To reduce the number of steps B) To ensure the steps are clearly stated and defined
C) To make the algorithm run faster D) To avoid using high-level language
28. Which step in problem-solving involves identifying the logical steps to reach a solution?

A) Analyzing the problem B) Developing the algorithm


C) Coding D) Testing and debugging
29. Which shape in a flowchart represents input or output data?
A) Oval B) Rectangle C) Parallelogram D) Diamond
30. Why is uniqueness important in an algorithm?
A) To ensure each step is uniquely defined B) To make the algorithm run faster

C) To reduce the number of steps D) To avoid using high-level language


31. What is the primary objective of problem-solving in computer science?
A) To debug the program B) To automate tasks efficiently
C) To reduce the size of the program D) To increase the speed of the program
32. In a flowchart, what is used to represent a decision?
A) Oval B) Rectangle C) Diamond D) Parallelogram

33. What should be the next step if an algorithm is not producing the correct output?
A) Ignoring the error B) Rewriting the problem statement
C) Revising the algorithm to check for logical errors D) Converting it into a flowchart
33. Why is it necessary to document the coding process?
A) To write more complex code B) To ensure the code is understandable and maintainable
C) To reduce the size of the code D) To avoid using high-level language

35. What role does testing play in the problem-solving process?


A) To identify any logical errors in the algorithm B) To write the final algorithm
C) To analyze the problem statement D) To convert the algorithm into code
36. What is the purpose of a flowchart?
A) To represent an algorithm visually B) To write the code
C) To debug the program D) To test the solution
37. Which of the following is NOT a step in the problem-solving process?
A) Analyzing the problem B) Writing the program
C) Testing and debugging D) Developing the algorithm
38. What is 'finiteness' in the context of an algorithm?
A) The algorithm must have a finite number of steps B) The algorithm must run indefinitely
C) The algorithm should have unique steps D) The algorithm must have infinite steps

39. Why is it necessary to debug a program?


A) To increase the size of the code B) To ensure the program runs without errors
C) To write the algorithm D) To develop the problem statement
40. What does a rectangle represent in a flowchart?
A) Decision B) Input/Output C) Start/End D) Process
41. Which step involves checking if a program meets user requirements?

A) Analyzing the problem B) Developing the algorithm C) Coding D) Testing


42. What is the outcome of an algorithm?
A) Analyzing the problem B) Writing the program
C) Producing a result D) Debugging the program
43. What is the significance of 'precision' in an algorithm?
A) To reduce the number of steps B) To ensure each step is clearly defined

C) To make the algorithm faster D) To avoid using high-level language


44. Why is it important to develop an algorithm before coding?
A) To reduce the size of the program B) To have a clear solution plan
C) To debug the code D) To increase the speed of the program
45. What is the role of testing in programming?

A) To analyze the problem B) To write the code


C) To identify and fix errors D) To develop the algorithm
46. What shape represents the start or end in a flowchart?
A) Rectangle B) Parallelogram C) Oval D) Diamond
47. Which of the following best describes 'uniqueness' in an algorithm?
A) Each step is distinct and clearly defined B) The algorithm has infinite steps
C) The algorithm runs indefinitely D) The algorithm is written in a high-level language
48. What should be done if a program produces unexpected results?
A) Ignore the results B) Re-analyze the problem
C) Debug and test the program D) Write a new algorithm
49. What does the term 'coding' refer to in problem-solving?
A) Writing the problem statement

B) Converting the algorithm into a programming language


C) Testing the program D) Analyzing the problem
50. Why is 'debugging' an essential part of problem-solving in programming?
A) To write the algorithm B) To fix errors in the code
C) To reduce the size of the program D) To develop the problem statement

1. Define an algorithm.
An algorithm is a finite set of instructions or a step-by-step procedure for solving a problem or performing a
task.

2. What is pseudocode?
Pseudocode is a non-formal language that helps programmers to write algorithms. It is a detailed description of
instructions that a computer must follow in a particular order and is intended for human reading.

3. Explain the term "flowchart.


A flowchart is a graphical representation of the steps in an algorithm or a process, using various symbols to
denote different types of actions or steps.

4. Explain the steps involved in Problem Solving.


Analyzing the Problem:
 Understand the problem thoroughly before seeking a solution.
 Carefully read and analyze the problem statement.
 List the principal components and decide the core functionalities of the solution.

 Identify the inputs and expected outputs.

Developing an Algorithm:
 Devise a solution plan represented in natural language, called an algorithm.
 Refine the algorithm until it captures all aspects of the desired solution.
 Select the most suitable algorithm if multiple solutions are possible.

Coding:
 Convert the finalized algorithm into a format understood by the computer using a high-level programming
language.
 Record coding procedures and document the solution for future reference and maintenance.

Testing and Debugging:


 Test the program to ensure it meets user requirements and responds within the expected time.
 Verify that the program generates correct output for all possible inputs.
 Fix any syntactical or logical errors encountered during testing.
 Follow standard testing methods like unit, integration, system, and acceptance testing to ensure the software
meets all business and technical requirements.
 Debug the program to rectify any defects found during testing.

5. Characteristics of a good algorithm


• Precision — the steps are precisely stated or defined.
• Uniqueness — results of each step are uniquely defined and only depend on the input and the result

of the preceding steps.


• Finiteness — the algorithm always stops after a finite number of steps.
• Input — the algorithm receives some input.
• Output — the algorithm produces some output.
EXERCISES (CHAPTER END QUESTIONS)
Question 1: Write pseudocode that reads two numbers and divides one by another and displays the
quotient.
Answer 1:
Start
Input number1
Input number2
If number2 is not 0, then

Set quotient = number1 / number2


Print quotient
Else
Print "Division by zero is not allowed."
End

Question 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?
Answer 2:
Start
Initialize player1_wins to 0
Initialize player2_wins to 0
For i from 1 to 5 do
Input flip_result

If flip_result is 1 then
Increment player1_wins
Else If flip_result is 2 then
Increment player2_wins
End If
If player1_wins is 3 then

Print "Player 1 wins the cake"


Exit
Else If player2_wins is 3 then
Print "Player 2 wins the cake"
Exit
End If
End For

End

Question 3: Write the pseudocode to print all multiples of 5 between 10 and 25 (including both 10 and
25).Answer 3:
Start

For number from 10 to 25 do


If number mod 5 is 0 then
Print number
End If
End For
End

Question 4: Give an example of a loop that is to be executed a certain number of times.


Answer 4:
Start
For i from 1 to 10 do
Print "This is iteration number " + i
End For
End

Question 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.
Answer 5:
Start
Initialize total_collected to 0
While total_collected < 200 do

Input amount_given
If amount_given is 10 or 20 or 50 then
total_collected = total_collected + amount_given
End If
End While
Print "Total collected: " + total_collected
End

Question 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.
Answer 6:
Start

Input price
Input quantity
Set total_bill = price * quantity
Set gst = total_bill * 0.05
Set bill_gst = total_bill + gst
Print "Total Bill: " + total_bill

Print "Bill after GST: " + bill_gst


End

Question 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.
Answer 7:
Start
Input computer_science_marks

Input mathematics_marks
Input physics_marks
Set aggregate_marks = computer_science_marks + mathematics_marks + physics_marks
Set percentage_marks = (aggregate_marks / 300) * 100
Print "Aggregate Marks: " + aggregate_marks
Print "Percentage Marks: " + percentage_marks

End
Question 8: Write an algorithm to find the greatest among two different numbers entered by the user.
Answer 8:
Start
Input number1

Input number2
If number1 > number2 then
Print "The greatest number is " + number1
Else
Print "The greatest number is " + number2
End

Question 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.
Answer 9:
Start

Input number
If number >= 5 and number <= 15 then
Print "GREEN"
Else If number > 15 and number <= 25 then
Print "BLUE"
Else If number > 25 and number <= 35 then

Print "ORANGE"
Else
Print "ALL COLOURS ARE BEAUTIFUL"
End

Question 10: Write an algorithm that accepts four numbers as input and find the largest and smallest of
them.
Answer 10:
Start
Input number1
Input number2
Input number3
Input number4
Set largest = number1
Set smallest = number1

If number2 > largest then


Set largest = number2
If number3 > largest then
Set largest = number3
If number4 > largest then
Set largest = number4
If number2 < smallest then
Set smallest = number2
If number3 < smallest then
Set smallest = number3
If number4 < smallest then
Set smallest = number4

Print "Largest number is " + largest


Print "Smallest number is " + smallest
End

Question 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.
Answer 11:
Start
Input units_consumed
Set meter_charges = 75
If units_consumed <= 100 then

total_bill = units_consumed * 5
Else If units_consumed <= 250 then
total_bill = (100 * 5) + ((units_consumed - 100) * 10)
Else
total_bill = (100 * 5) + (150 * 10) + ((units_consumed - 250) * 20)

End If
total_bill = total_bill + meter_charges
Print "Total Water Bill: " + total_bill
End

Question 12: What are conditionals? When are they required in a program?
Answer 12: Conditionals are statements that perform different actions based on whether a given condition is
true or false. They are required in a program to make decisions and execute certain sections of code depending
on specific conditions.

Question 15: Write a pseudocode to calculate the factorial of a number. (Hint: Factorial of 5, written as 5!
= 5 × 4 × 3 × 2 × 1).
Answer 15:
Start

Input number
Set factorial = 1
For i from 1 to number do
factorial = factorial * i
End For
Print "Factorial of " + number + " is " + factorial

End

Question 17: Following is an algorithm to classify numbers as “Single Digit”, “Double Digit” or “Big”.
Verify for (5, 9, 47, 99, 100, 200) and correct the algorithm if required.
Answer 17:

INPUT Number
IF Number < 10 then
Print "Single Digit"
Else If Number < 100 then
Print "Double Digit"
Else
Print "Big"
End If
Verification:
For 5, 9, 47, 99, 100, 200:

5 and 9 should be classified as "Single Digit"


47 and 99 should be classified as "Double Digit"
100 and 200 should be classified as "Big"

Question 18: For some calculations, we want an algorithm that accepts only positive integers up to 100.
INPUT Number
IF (0 < Number) AND (Number <= 100) then
ACCEPT
Else
REJECT
End If
a) On what values will this algorithm fail?
b) b) Can you improve the algorithm?

c) Answer 18: a) This algorithm will fail for the value 0 because 0 is not considered a positive integer. b)
Improved algorithm:
INPUT Number
IF (Number > 0) AND (Number <= 100) then
ACCEPT
Else
REJECT
End If

You might also like