0% found this document useful (0 votes)
19 views

Programming Techniques - Handout - Day 2

Research paper

Uploaded by

Karthik Jerry
Copyright
© © All Rights Reserved
Available Formats
Download as PDF, TXT or read online on Scribd
0% found this document useful (0 votes)
19 views

Programming Techniques - Handout - Day 2

Research paper

Uploaded by

Karthik Jerry
Copyright
© © All Rights Reserved
Available Formats
Download as PDF, TXT or read online on Scribd
You are on page 1/ 5

Programming Techniques

Assignments Handout - Day 2


Topic Name: Working with Algorithms.

Assignments deliverables: Each solution should have the below-


1. Pseudocode for the problem statement.
2. Appropriate algorithm design for the problem statement.

Foundation Phase
Technical Learning Service

Copyright © 2016, Tech Mahindra. All rights reserved. 1


Guidelines:
1. Associates need to resolve/work on daily assignments independently, completing minimum 50%
of assignments @ per category and per day, but not limited to given %age of completion.
2. Associates needs to work on daily assignments independently, completing minimum of any 5
assignments @ per topic fulfilling the guideline no.1.
3. Please resolve/work on daily assignments using any available online tools or appropriate
available S/W locally.
4. Associates can self-explore on the concepts covered on daily basis to complete your assignments
in a satisfactory manner.

Expectations:
1. You are expected to submit the completed assignments on daily basis for review by the facilitator.
2. You are expected to ensure that facilitator provides appropriate feedback for the assignments
solutions submitted on daily basis.
3. You are expected to save all the completed assignments locally for any future references or for
self-preparing for the associated assessments.
4. You will be expected to resolve/work on daily assignments independently or seek needed
support, wherever required.
5. You will be expected to refrain from using any un-professional means of completing the daily
assignments.
6. You will be expected to work as a team member/collectively/collaboratively, wherever required
to resolve the daily assignments.
7. You will be expected to complete all work assignments by their deadlines except under unusual
circumstances.
8. You will be expected to spend extra time (if required) for completing/ performing the assigned
task satisfactorily.

***********************

Copyright © 2016, Tech Mahindra. All rights reserved. 2


Assignments: Working with Algorithms

Arithmetic based problem statements:


1. Design an algorithm that keeps reading positive numbers until the user enters a zero value, and
determines and outputs the largest number.
2. Design an algorithm that reads an arbitrary number of numbers and outputs their arithmetic
average.
3. Design an algorithm that outputs the ith largest number in a group of n numbers.
4. Write an algorithm that, given a directory path, can count the total number of files that fall under
that directory and all subdirectories.
5. Write a pseudocode algorithm to read a positive integer N followed by N integers. For these N
integer, the algorithm must count and print the number of zero and non-zero values.
6. Write a structured algorithm which prompts a user to enter an integer value which is then stored
in a variable N. The algorithm must then print each integer from 1 to N and its corresponding
square. Each output line must show the integer from 1 to N and its square. You may assume that
the user would enter an integer value.
7. Using 1 mile = 1.85 kilometers, write a structured algorithm that will accept a value in miles as the
speed measured by the car’s speedometer. Convert that measurement to kilometers and alert the
driver if he or she is travelling more than 90 km/hr.
8. Write a algorithm that accepts n amount of passengers on a bus. The program should accept the
fare based on the following. If the age is less 12 [child] then the amount is 20 dollars, If the age is
between 12 and 40 then the adult fare of 60 dollars is applied, otherwise the seniors pay 30
dollars. The algorithm should output the total fare for adults, children and seniors, and the grand
total, that is, Adults + children + seniors.
9. Write a Pseudocode algorithm which prompts the user to enter the price of an item and which
calculates and prints the new price after a discount of 12%.
10. Write an algorithm to read ELEVEN numbers find their average and print it. The algorithm
should also print the number of times 6 occurs in the data. For example, given the input data: 8,
4, 6, 9, 6, 5, 6, 10, 7, 0, 16.

Copyright © 2016, Tech Mahindra. All rights reserved. 3


11. Write an algorithm that takes a set of (x, y) coordinates representing points on a plane, and
outputs the coordinates of two points with the maximal distance. The signature of the algorithm
is Maximal-Distance (X, Y ), where X and Y are two arrays of the same length representing the x
and y coordinates of each point, respectively.
12. Write an algorithm called In-Place-Sort(A) that takes an array of numbers, and sorts the array in-
place. That is, using only a constant amount of extra memory.
13. Write an algorithm Partition(A, k) that, given an array A of numbers and a value k, changes A in-
place by only swapping two of its elements at a time so that all elements that are less than or
equal to k precede all other elements.
14. Write an algorithm called OCURRENCES that, given an array of numbers A, prints all the distinct
values in A each followed by its number of occurrences. For example, if A = (28, 1, 0, 1, 0, 3, 4,
0, 0, 3) the algorithm should output the following five lines (here separated by a semicolon) “28
1; 1 2; 0 4; 3 2; 4 1”. The algorithm may modify the content of A , but may not use any other
memory. Each distinct value must be printed exactly once. Values may be printed in any order.
15. Write an algorithm called Hot-Days (A, t) that takes an array A of daily temperature
measurements for a city and a temperature t, and returns the maximum number of consecutive
days with a recorder temperature above t.

Copyright © 2016, Tech Mahindra. All rights reserved. 4


Version History:
Resources/tools Required
· Windows XP and above
· Any Text editor
· Any browser compatible Online Compilers
References
· “Code complete –A practical handbook of software construction” -Steve McConnell, 2nd
edition, WP Publishers & distributers, Bangalore, 2006
· How to solve it by Computer –Droomy, Pearson, 2005
Version History
# Date Created/Changed by Changes made Reviewed by
1.0 27/08/2015 Saradhi Seshagiri Pankaj Patil
Saradhi Seshagiri / Pankaj
1.1 01/02/2016 Saradhi Seshagiri
Patil
1.3 21/06/2016 Saradhi Seshagiri Saradhi Seshagiri

Copyright © 2016, Tech Mahindra. All rights reserved. 5

You might also like