Professional Documents
Culture Documents
PART- A (2 Marks)
1. What is an algorithm?(Jan-2018)
Algorithm is an ordered sequence of finite, well defined, unambiguous instructions for completing a task. It
is an English-like representation of the logic which is used to solve the problem. It is a step-by-step
procedure for solving a task or a problem. The steps must be ordered, unambiguous and finite in number.
5. Write the pseudocode to calculate the sum and product of two numbers and display it.
INITIALIZE variables sum, product, number1, number2 of type real
PRINT “Input two numbers”
READ number1, number2
COMPUTE sum = number1 + number2
PRINT “The sum is", sum
COMPUTE product = number1 * number2
PRINT “The Product is", product
END program
7. Write the algorithm to calculate the average of three numbers and display it.
GE3151 – Problem Solving and Python Programming Common to all Branches 2021-2022
Step 1: Start
Step 2: Read values of X,Y,Z
Step 3: S = X+Y+Z
Step 4: A = S/3
Step 5: Write value of A
Step 6: Stop
8. Give the rules for writing Pseudocode.
• Write one statement per line.
• Capitalize initial keywords.
• Indent to show hierarchy.
• End multiline structure.
• Keep statements language independent.
9. What is a function?
Functions are named sequence of statements that accomplish a specific task. Functions usually "take in"
data, process it, and "return" a result. Once a function is written, it can be used over and over and over again.
Functions can be "called" from the inside of other functions.
21. Write an algorithm to accept two numbers, compute the sum and print the result.(Jan-2018)
Step1: Read the two numbers a and b.
Step 2: Calculate sum = a+b
Step 3: Display the sum
22. Write an algorithm to find the sum of digits of a number and display it.
Step 1: Start
Step 2: Read value of N
Step 3: Sum = 0
Step 4: While (N != 0)
Rem = N % 10
Sum = Sum + Rem
N = N / 10
Step 5: Print Sum
Step 6: Stop
23. Write an algorithm to find the square and cube and display it.
Step 1: Start
Step 2: Read value of N
Step 3: S =N*N
Step 4: C =S*N
Step 5: Write values of S,C
Step 6: Stop
Recursion is a method of solving problems that involves breaking a problem down into smaller and smaller
subproblems until you get to a small enough problem that it can be solved trivially. Usually recursion
involves a function calling itself. While it may not seem like much on the surface, recursion allows us to
write elegant solutions to problems that may otherwise be very difficult to program.
Example:
defcalc_factorial(x):
if x == 1:
return 1
else:
return (x * calc_factorial(x-1))
num = 4
print("The factorial of", num, "is", calc_factorial(num))
26. Write an algorithm to find minimum in a list. (Jan-2019)
ALGORITHM : To find minimum in a list
Step 1: Start
Step 2: Read the list
Step 3: Assume the first element as minimum
Step 4: Compare every element with minimum. If the value is less than minimum, reassign that value as
minimum.
Step 5: Print the value of minimum.
Step 6: Stop
27. Distinguish between algorithm and program. (Jan-2019)
Algorithm Program
Algorithm is the approach / idea to solve some A program is a set of instructions for the computer
problem. to follow.
It does not have a specific syntax like any of the It is exact code written for problem following all the
programming languages rules (syntax) of the programming language.
28. List the Symbols used in drawing the flowcart. (May 2019)
Flowcharts are usually drawn using some standard symbols
• Terminator
• Process
• Decision
• Connector
• Data
• Delay
• Arrow
29. Give the P to find the minimum among the list of 10 numbers. (May 2019)
numList = []
Read n
for i in range(0, n):
Read x[i]
maxNum = numList[0]
for i in numList:
GE3151 – Problem Solving and Python Programming Common to all Branches 2021-2022
if i > maxNum:
maxNum = i
print Maximum Element of the Given List is maxNum
30. How will you analysis the efficiency of an algorithm? (Nov / Dec 2019)
Time efficiency, indicating how fast the algorithm runs.
Space efficiency, indicating how much extra memory it uses
31. How do algorithm, flowchart and pseudo code use for problem solving? (Nov / Dec 2019)
Algorithm: A process or set of rules to be followed in calculations or other problem – solving operations,
especially by a computer
Flowchart: Flowchart is diagrammatic representation of the algorithm.
Pseudo code: In Pseudo code normal English language is translated into the programming languages to be
worked on.
All are tools for problem solving independent of programming language. Difference is only in the way of
representing the solution.
• Mankind along with the advancement in science and technology is working hard to bring the Vth
Generation of computer.
• These computers will have the capability of thinking on their own like a man with the help of Artificial
Intelligence (AI), the 21st century will be better, faster, smaller and smarter computers.
Input Unit:
Computers need to receive data and instruction in order to solve any problem. Therefore, we need to input
the data and instructions into the computers. The input unit consists of oneor more input devices. Keyboard is
the one of the most commonly used input devices. Other commonly used input devices are the mouse, floppy
disk drive, magnetic tape, etc. All the input devices perform the following functions.
• Supply the converted data to the computer system for further processing.
GE3151 – Problem Solving and Python Programming Common to all Branches 2021-2022
Block Diagram of Computer
Storage Unit:
The storage unit of the computer holds data and instructions that are entered through the input unit, before
they are processed. It preserves the intermediate and final results before these are sent to the output devices. It
also saves the data for the later use.
2. Secondary Storage:
• It stores several programs, documents, data bases etc.
• The programs that run on the computer are first transferred to the primary memory
before it is actually run.
• Whenever the results are saved, again they get stored in the secondary memory.
• The secondary memory is slower and cheaper than the primary memory. Some of the
commonly used secondary memory devices are Hard disk, CD, etc.,
Memory Size:
All digital computers use the binary system, i.e., 0’s and 1’s. Each character or a number is represented by
an 8-bit code. The set of 8 bits is called a byte. A Character occupies 1 byte space. A numeric occupies 2-
byte space. Byte is the space occupied in the memory. The size of the primary storage is specified in KB
(Kilobytes) or MB (Megabyte). One KB is equal to 1024 bytes and one MB is equal to 1000KB. The size of the
primary storage in a typical PC usually starts at 16MB. PCs having 32 MB, 48MB, 128 MB, 256MB memory are
quite common.
GE3151 – Problem Solving and Python Programming Common to all Branches 2021-2022
Output Unit:
The output unit of a computer provides the information and results of a computation to outside world.
Printers, Visual Display Unit (VDU) are the commonly used output devices. Othercommonly used output devices
are floppy disk drive, hard disk drive, and magnetic tape drive.
All calculations are performed in the Arithmetic Logic Unit (ALU) of the computer. It also does
comparison and takes decision. The ALU can perform basic operations such as addition, subtraction,
multiplication, division, etc and does logic operations viz, >, <, =, ‘etc. Whenever calculations are required, the
control unit transfers the data from storage unit to ALU once the computations are done, the results are
transferred to the storage unit by the control unit and then it is send to the output unit for displaying results.
Control Unit:
It controls all other units in the computer. The control unit instructs the input unit, where to store the
data after receiving it from the user. It controls the flow of data and instructions from the storage unit to
ALU. It also controls the flow of results from the ALU to the storage unit. The control unit is generally
referred as the central nervous system of the computer that control and synchronizes it’s working.
10. (a) Write a program to insert a card in a list of sorted cards. (Jan-2019)
Ans: Refer Unit 1 Notes Page No. 36 to 45
b) Write a program to find the minimum number in a list.
Ans: Refer Unit 1 Notes Page No. 36 to 45
11. a) Draw a flow chart to accept three distinct numbers, find the greatest and print the result. (8) (Jan-2018)
GE3151 – Problem Solving and Python Programming Common to all Branches 2021-2022
c) Draw a flow chart to find the sum of the series 1+2+3+……+100. (8) (Jan-2018)
12. Outline the Towers of Hanoi problem. Suggest a solution to the Towers of Hanoi problem with relevant
diagrams. (16) (Jan-2018)
Ans: Refer Unit 1 Notes Page No. 42 to 45
14. (a) What is an algorithm? Summaries the characteristics of a good algorithm. (8) (May 2019)
Ans: Refer Unit 1 Notes Page No. 16 to 17
(b) Outline the algorithm for displaying the first n odd numbers. (May 2019)
GE3151 – Problem Solving and Python Programming Common to all Branches 2021-2022
15. (a) What is a programming language? What are its types? Explain them in detail with their advantages and
disadvantages. (8) (Nov / Dec 2019)
Ans: Refer Unit 1 Notes Page No. 29 to 31
(b) Write a function find index (), which returns the index of a number in the Fibonacci sequence, if the
number is an element of this sequence and returns -1, if the number is not contained in it, call this function
using user input and display the result. (8) (Nov / Dec 2019)
Ans:
16. (a) What is recursive function? What are its advantages and disadvantages? Compare it with iterative
function. (6) (Nov / Dec 2019)
Ans: Refer Unit 1 Notes Page No. 35 to 36
(b) Implement a recursive function in python for the sieve of Eratosthenes. The sieve of Eratosthenes is a
simple algorithm for finding all prime numbers up to a specified integer. It was created by the ancient Greek
mathematician Eratosthenes. The algorithm to find all the prime numbers less than or equal to agiven
integer n: (10) (Nov / Dec 2019)