Location via proxy:   [ UP ]  
[Report a bug]   [Manage cookies]                
0% found this document useful (0 votes)
340 views

1 Algorithm Practice

1. The document provides algorithms for various tasks including: calculating speed from distance and time, determining the day of the week from a number, converting between binary and decimal numbers, calculating Fibonacci sequences and factorials, determining if a number is an Armstrong number, generating Unicode codes from personal details, calculating discounts on purchases over a threshold, and determining the number of days in February based on whether it is a leap year. 2. It also provides algorithms for tasks such as: arranging items by size, calculating age given birth year and current year encodings, determining if sports teams are compatible based on player rankings, identifying the lowest prices and vendors for various products, finding maximum scores in assessment courses, determining the best position in a line

Uploaded by

Atharv Halmadge
Copyright
© © All Rights Reserved
Available Formats
Download as DOCX, PDF, TXT or read online on Scribd
0% found this document useful (0 votes)
340 views

1 Algorithm Practice

1. The document provides algorithms for various tasks including: calculating speed from distance and time, determining the day of the week from a number, converting between binary and decimal numbers, calculating Fibonacci sequences and factorials, determining if a number is an Armstrong number, generating Unicode codes from personal details, calculating discounts on purchases over a threshold, and determining the number of days in February based on whether it is a leap year. 2. It also provides algorithms for tasks such as: arranging items by size, calculating age given birth year and current year encodings, determining if sports teams are compatible based on player rankings, identifying the lowest prices and vendors for various products, finding maximum scores in assessment courses, determining the best position in a line

Uploaded by

Atharv Halmadge
Copyright
© © All Rights Reserved
Available Formats
Download as DOCX, PDF, TXT or read online on Scribd
You are on page 1/ 4

1.

“Brain Storm” a popular matriculation school in your place is conducting a


science exhibition. Alex needs your help to present his project named as
“Simple Calculator”. Help him to write an algorithm to create a simple
calculator that performs basic arithmetic operations (add, subtract, multiply
and divide).
2. Tony crosses a street that is ‘x’ m long in 'y' minutes. Write an algorithm to
compute his speed in km per hour, given x and y.
Hint: speed=distance/time
3. Mrs. Jessy teaches her 7-year-old daughter to tell the day of a week when
Jessy tells a number between 1 to 7. Implement this scenario and generate
an algorithm for the same.
4. Raj wants to convert binary number to decimal number system. Binary
number system is a base 2 number system. It uses only 2 symbols to
represent all its numbers i.e. 0 and 1. Build an algorithm for this conversion.
5. The first two terms in the Fibonacci series are 0 and 1, respectively, and each
subsequent term is the sum of the previous two. Using this definition, to
calculate the first several terms in the sequence, we get:
0, 1, 1, 2, 3, 5, 8, 13, 21, 34, 55, 89, ...
Build an algorithm for the same.
6. Factorial of any number n is represented by n! and is equal to 1*2*3*....*(n-
1)*n.
Write an algorithm to find the factorial of any given number.
7. A three digit number is called an Armstrong number if the sum of the cube of
its digits is equal to the number itself. Write an algorithm for the same.
8. A passport office at Gurgaon decides to generate a Unicode for every
applicant who applies for passport and to mail the same to the applicants. The
passport service will get rendered only when an applicant provides his own
Unicode number that was sent to him. The Unicode is generated in a tricky
way. It is the year of birth of the applicant summed up followed by the area
code reversed.
Year entered must contain four digits; otherwise display – ‘Unable to generate
Unicode’. If the year entered is greater than the current year or less than or
equal to zero, display the message – ‘Unable to generate Unicode’. If the area
code entered is less than or equal to zero, display the message – ‘Invalid area
code’.
Build an algorithm for the same.
9. A grocery shop gives discount of 10% on a particular product if the cost of the
quantity purchased crosses 1000. The price of one piece of this product is
Rs. 100. Write an algorithm to calculate the price a person will have to pay,
given the quantity he purchased.
10. A computer teacher wants his students to find the number of days in the
month of February depending on whether it is a leap year or not. Build an
algorithm for the same.
11. To decide on an employee's work allotment, the manager asks for his/her
age, sex (M or F), marital status (Y or N). He then applies the following rules
to decide on their place of service:
If the employee is a female and is married, then she will work in urban areas.
If the employee is a male, married and if the age is between 20 and 40, then
he could be put to work anywhere.
If employee is a male, unmarried and if the age is between 40 and 60, then he
will work in urban areas.
Write an algorithm for the same.
12. Jane and James are friends and both are really interested in learning new
aspects and new things in a programming language. One day, they planned
to find out the best algorithm to count the frequency of each digit in any given
number. Help them find out the best algorithm to do the same.
13. If a factor of a number is a prime number then it is its prime factor. Write an
algorithm to find the prime factor of a number.
14. Mr.William buys a new Audi car. During the vehicle registration, he needs a
fancy number like both the number and its reverse are the same. Generate an
algorithm to find that fancy number.
15. JeanStone an online shopping portal introduces jeans for women. Assume 10
model pictures are given with different sizes. Write an algorithm to arrange
them in the catalog, based on their size from big to small.
16. A private bank comes up with a requirement to check the age of a person
who wants to open an account in their bank. They approach you to create an
algorithm to calculate the age when the birth year and the current year are
given. Both the years should be encoded with last two digits.
For example, if the birth year is 1990, then the user will enter only "90". You
will have to determine, if a two digit value such as "62" corresponds to a year
in the 20th century ("1962”). If the user gives "00", this will be considered as
year 2000. Assume that the age should always between 18 and 100
(inclusive) and the current year to be 2018.
17. A big state level tournament is coming up. A sports academy is preparing
their students for the same and has formed two groups, namely Group A and
Group B. Each group contains 6 players. Both the teams are said to be
compatible if they are of the same size and if the player in ith position in group
A is greater than the player in ith position in group B, for all i. Write an
algorithm for the same.
18. A grand discount sale is announced by 3 vendors - Flipkart, Amazon and
Snapdeal for the products - mobile, laptop, speakers, power bank and USB.
Ms. Grace wants to identify which vendor supplies each product for the least
price. For example, if a laptop is sold for 45000, 42000, and 46000 by the
three vendors, then she must be able to identify that the laptop from Amazon
has the least price of Rs.42000. This has to be done for all the 5 products.
Help Grace with an algorithm that displays the least price of each product
along with the vendor that sells it. The flow has to terminate abruptly
displaying – ‘Invalid Input’, if a price entered is negative.
19. You are the class representative and your class adviser wants you to prepare
the result analysis after every internal assessment. Given the scores of ‘N’
students in the class for 6 courses, one of the tasks in the analysis is to find
the maximum mark scored in each course. Write an algorithm for the same.
Marks cannot be negative or greater than 100. On such erroneous input, stop
the flow deliberately displaying – ‘Invalid input’.
20. The captain of the ship INS Chakra wants to select someone from his crew for
help. Everyone seems eligible and so he decides to test their intelligence with
a game and pick the one that wins. The members will have to stand in a line
and they will be numbered in the order in which they stand, starting from 1.
The point is - in his first pass, the captain will remove all the members
standing in the odd position. This process of removal will continue for several
passes until there is just one person left. The captain gives them just 30
seconds to line up. Imagine yourself to be a crew member and design an
algorithm that will help you choose the perfect place to stand in the line so
that you win!
Hints :
Members are numbered in the order - 1,2,3,4,5,6,7,8
After the first pass, members in these positions are safe - 2,4,6,8
After the second pass, members in these positions are safe - 4,8
The winner is at the position - 8 !

21. As a result of the final year on-campus, Tekno School of Computing wants to
select the students, who have performed well in the interview. The report
given is in the matrix format. Now nominees for the post “placement
coordinators” are to be selected. The students with highest interview score is
the one to be nominated. The total number of inputs can be calculated using
(m*n+2). The first input integer corresponds to m, the number of rows in the
matrix( i.e. number of students) and the second integer corresponds to n, the
number of columns(number of interview rounds). The remaining integers
correspond to the elements in the matrix. The elements are read in row wise
order, first row first, then second row and so on. Assume that the maximum
value of m and n to be 10.

For ex: Consider in a 3x3 matrix, 9 values to be filled.

round1 round2 round3

student1 1 4 5

student2 6 4 1

student3 2 4 3

For this scenario, the total number of inputs is 11 calculated using


formula(m*n+2). Here, ((3*3+2) =11). The input integers are
3,3,1,4,5,6,4,1,2,4,3. Here, first integer represents 3 rows, second integer
represents 3 columns, the remaining integers are scores. (highest scores
values can be calculated as follows (1+4+5), (6+4+1), (2+4+3). Here, The
nominee with highest score 11 is student 2). If two or more students with
same score, then they can be the nominated. Write a Pseudo code for this
scenario.
22. In a class room, students are seated in the form of a square matrix of order
n*n. A nominee for the post of class representative is to be selected from
each row. The student with the highest mark in each row is the one nominated
from that row. Given the marks of the students in the row wise order of their
seating, can you write an algorithm that displays the positions of the nominees
in each row?
23. A matrix is said to be row dominant if the sum of the elements along any row
in the matrix is greater than the sum of the elements along every column in
the matrix. Write an algorithm to determine whether the given matrix is row
dominant or not.
24. A new employee has joined a company. He is allocated projects during his
probation. He is given a score for each project he finishes. Assume that the
number of projects will not exceed 10. The project manager who is notified
every project score, checks for the average of scores. If the average is above
80 he is allocated with the real project, else he is given more assignments.
Write an algorithm for the same.
25. A parade is arranged for Independence Day celebrations in your campus. A
line of students are arranged in odd and even positions. Now the students in
the odd positions are to be sorted in the descending order and the students in
the even position are to be sorted in ascending order, given a 1 D array. The
maximum length of the line is 20. Display – ‘Invalid Size’, if the input specified
is zero or negative.
Write an algorithm to implement the above scenario.
26. George is given a task by his mathematics professor. His task is to merge 2
arrays and get the result sorted in ascending order. The sorted array must not
contain duplicates. Write an algorithm for the same.

27. In FUN Mall, Mirchi FM has arranged for a thriller game. Mr.Stev who is the
organizer for this event, calls one of the participant and ask him to pick a
number. If the participant picks positive number he has to enter into angel
house or if he picks zero or negative number he has to enter into ghost house.
Write a program to display to which house the participant has to be entered.
Given the following algorithm ,Choose the correct sequence.
28. A famous music director is now composing a pop album. To speed up his
composition of generating unpredictable rhythms, he wants the list of prime
numbers available in a range of numbers.
Can you help him out by choosing the correct algorithm?

You might also like