Uploaded by 506_Divyansh Sevta

ITPL ASSIGNMENT

advertisement
Q1. What is algorithm?
Ans1. The word Algorithm means “a process or set of rules to be followed in calculations or other
problem-solving operations”. Therefore Algorithm refers to a set of rules/instructions that step-by-step
define how a work is to be executed upon in order to get the expected results . The Algorithm designed
are language-independent, i.e. they are just plain instructions that can be implemented in any
language, and yet the output will be the same, as expected.
Q2. Explain need of an algorithm?
Ans2. The need of an algorithm is as follows:
Need of Algorithm
1. To understand the basic idea of the problem.
2. To find an approach to solve the problem.
3. To improve the efficiency of existing techniques.
4. To understand the basic principles of designing the algorithms.
5. To compare the performance of the algorithm with respect to other techniques.
6. It is the best method of description without describing the implementation detail.
7. The Algorithm gives a clear description of requirements and goal of the problem to the designer.
8. To understand the flow of the problem.
Q3. Write an Algorithm to find the average age of a group of 10 players?
Ans3. Algorithm:
1.
2.
3.
4.
5.
6.
7.
8.
9.
10.
Start
Input ages of 10 players in array A[]
Sum=0
I=0
Repeat steps 6 & 7 while (i<10)
Sum = Sum + A[i]
i=i+1
Avg=Sum/10
Print Avg
Stop
Q4. Write algorithm to this problem: Ramshewak goes to market for buying some fruits and vegetables.
He is having a currency of Rs 500 with him for marketing. From a shop he purchases 2.0 kg Apple priced
Rs. 50.0 per kg, 1.5 kg Mango pniced Rs.35.0 per kg, 2.5 kg Potato priced Rs.10.0 per kg, and 1.0 kg
Tomato priced Rs.15 per kg. He gives the currency of Rs. 500 to the shopkeeper. Find out the amount
shopkeeper will return to Ramshewak. and also tell the total item purchased.
Ans4.
Q5. Find factorial of N?
Ans5. The factorial of a natural number is a number multiplied by “number minus one”,
Then by “number minus two”, and so on till 1 . The factorial of n is denoted as n!
The usual definition of “n factorial” is “n! = n * (n — 1) * (n — 2) *… * 2 * 1,” where 'n' is a positive
integer.
Q6. Explain steps involve in drawing of a flowchart.
Ans6. Flowcharting is a tool for analysing processes. It allows you to break any process down into
individual events or activities and to display these in shorthand form showing the logical relationships
between them. Constructing flowcharts promotes better understanding of processes, and better
understanding of processes is a pre-requisite for improvement.
Steps to Draw flowchart:
There are no hard and fast rules for constructing flowcharts, but there are guidelines which are useful to
bear in mind. Here are six steps which can be used as a guide for completing flowcharts.






Describe the process to be charted
Start with a ‘trigger’ event
Note each successive action concisely and clearly
Go with the main flow (put extra detail in other charts)
Make cross references to supporting information
Follow the process through to a useful conclusion (end at a ‘target’ point)
Q7. Explain uses of Flowchart?
Ans7. Uses of Flowchart:







Planning a new project
Documenting a process
Modeling a business process
Managing workflow
Auditing a process
Mapping computer algorithms
Data management

Chemical and process engineering
Q8. Draw a flowchart to find the sum of first 100 natural numbers.
Ans8.
Q9. Draw a flowchart to find the largest of three numbers x, y and z.
Ans9.
Q10. Draw flowchart for the problem of determining prime number?
Ans10.
Q11. Draw a flowchart which generates first 50 items of the Fibonacci
series:
1, 1,2,3,5,8,...?
Ans11.
Q12. Design an algorithm to convert a decimal number, n, to binary format?
Ans12. Decimal to Binary Conversion Algorithm
o
o
o
o
Step 1: Divide the number by 2 through % (modulus operator) and store the remainder in array
Step 2: Divide the number by 2 through / (division operator)
Step 3: Repeat the step 2 until number is greater than 0
Step 4: Print the array in reverse order now.
For Example:
If the binary number is 10.
Step 1: Remainder when 10 is divided by 2 is zero. Therefore, arr[0] = 0.
Step 2: Divide 10 by 2. New number is 10/2 = 5.
Step 3: Remainder when 5 is divided by 2 is 1. Therefore, arr[1] = 1.
Step 4: Divide 5 by 2. New number is 5/2 = 2.
Step 5: Remainder when 2 is divided by 2 is zero. Therefore, arr[2] = 0.
Step 6: Divide 2 by 2. New number is 2/2 = 1.
Step 7: Remainder when 1 is divided by 2 is 1. Therefore, arr[3] = 1.
Step 8: Divide 1 by 2. New number is 1/2 = 0.
Step 9: Since number becomes = 0. Print the array in reverse order. Therefore the equivalent binary
number is 1010.
.
Download