UMBC CS 104
UMBC CMSC 104 * CSEE | 104 | current 104

Practice Problem Set ( Algorithms )


Definitions:

  • 1.) An Algorithm is a finite set of unambiguous executable instructions that directs a terminating activity.
  • 2.) A generic algorithm will work with any values for input. For example, any integer, any sentence, any set of numbers.

    Problems:


    a.) First solve each of the following problems.

    b.) Then write an algorithm for each problem. Either English sentences OR pseudocode is acceptable.


    1.) A car radiator contains 8 quarts of water. How much of the water should be drained and replaced with pure Anti-Freeze in order that the resultant mixture will contain 60% Anti-Freeze?

    * The algorithm should allow for any radiator capacity.

    * The algorithm should allow for any percent of AntiFreeze

    2.) A store holding a clearance sale advertises that all prices have been discounted 20%. If a certain item is on sale for $28.00. , what was its price before the sale?

    * The algorithm should allow for the item to be at any sale price.

    * The algorithm should allow for any percent discount.

    3.) It costs a toy company ( 1000. + 2x ) dollars to manufacture x Big Bertha dolls. Each doll sells for $5.00 How many dolls must be sold to make $10,000 profit?

    * The algorithm should allow for different sale prices for the dolls

    * The user should be able to specify the amount of money to be made.

    4.) A student in a C programming course has test scores of 75, 82, 71, and 84. What score on the next test will raise the students average to 80? All tests are of equal value.

    * Allow the user to input different test scores

    * Allow the user to specify a different number of tests each time.

    5.) A newspaper boy has 125 coins, consisting of nickels and pennies. If the total amount is $4.25 how many coins of each type does he have?

    6.) The pressure acting at a certain depth in a liquid is directly proportional to the distance form the surface of the liquid to that depth. In a certain oil tank the pressure at a depth of 2 feet is 118 pounds per square foot. Find the pressure at a depth of 5 feet.

    * The algorithm should allow for different liquids. ie, different pressures of the liquid at a given depth.

    * The algorithm should allow for different depths to be measured.

    7.) A manufacturer sells a certain article to dealers at a rate of $20. each if less than 50 are ordered. If 50 or more are ordered, the price of each article is reduced 50 cents. What is the total cost of 100 units?

    * The algorithm should allow for changes in the $20 price, for purchases under 50 units.

    * The algorithm should allow for changes in the 50 cents reduced rate.