0% found this document useful (0 votes)
17 views2 pages

Tutorial 3

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)
17 views2 pages

Tutorial 3

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/ 2

Data Structure & Algorithms 1 (DSA1)

Tutorial 3 - Algorithmic Formalism and Problem Solving


2024 - 2025

13 October 2024

OBJECTIVES
• Algorithm Structure:
– Constants, Variables
– Basic statements: Assignment, Expressions, Input/Output

Exercise 1
A builder requires an application (program) to calculate and display the area of a rectangular floor based on
its measurements in meters. Additionally, the application should determine the total cost of tiling the floor,
considering the price per square meter of the tile.
Develop an algorithm to solve the builder’s problem.

Exercise 2
Write an algorithm to calculate and display the volume of a cylinder, given the cylinder’s radius (r) and
height (h). The volume can be calculated using the formula πr2 h.

Exercise 3
Develop an algorithm to calculate and display the sum of the first n numbers:
n
X
i = 1 + 2 + 3 + ... + n
i=1

The value of n should be introduced by the user.

Exercise 4
Write an algorithm that prompts the user to enter two values, stores them in two variables, swaps the content
of the two variables, and then displays the content of both variables before and after the swap. Propose two
distinct solutions to this problem.

1
Exercise 5
Write an algorithm that calculates and displays the commission amount of a salesperson. The commission
is determined by multiplying the salesperson’s sales amount by 10%.
Modify your algorithm to enable the user to enter the commission rate in decimal form.

Exercise 6
Write an algorithm that computes and displays the percentage of the total points contributed by a basketball
player to their team’s final score. The player will provide data on two-point baskets, three-point baskets,
and free throw points made by their team, as well as their own individual statistics for these categories.
Write an algorithm that displays the player’s name along with a comprehensive statistical report detailing
their contribution points.

Exercise 7
An Employee receives 52 paychecks annually, depositing a fixed percentage of her/his gross pay into her/his
savings account. Additionally, the employee receives a bonus check exceeding 25000 DA at the end of the
year, of which she/he deposits 15000 into her/his savings account. The Employee wants a program that
calculates and displays the total amount she/he deposited during the year.
Develop an algorithm to solve the employee’s problem.

You might also like