CMSC 104, Algorithms

 

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:

  • First solve each of the following problems.
  • Then write an algorithm for each problem. Either English sentences OR pseudocode is acceptable.

    1. 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?

    1. 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?

    1. 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.
    1. A merchant wishes to mix peanuts costing $1.50 per pound with cashews costing $4.00 per pound, obtaining 50 pounds of a mixture costing $2.40 per pound. How many pounds of each type of nut should be used?

    1. 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.
    1. 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?
    1. One Train leaves San Francisco heading for Santa Barbara going 50 miles per hour. At the same time, another Train leaves Santa Barbara heading for San Francisco going 25 miles per hour. Both trains travel on the same 200 miles of track between the two cities. How many hours does it take for the two trains to meet?
    1. Tickets for a Rolling Stones Concert sold for $4.00 per ticket. Anyone who attended and purchased a ticket at the door had to pay $5.00 a ticket. A total of 480 people attended and the revenue from ticket sales was $2,100.00 How many people bought tickets in advance and how many people bought tickets at the door?
    1. In a community of 416 people, each person owns a Chevy or a Ford or both. If there are 316 people who at least own a Chevy, and 280 people who at least own a Ford. How many of the Chevy owners own no Ford?
    1. What is the temperature in a freezer (in degrees C) given the elapsed time of 1 hour since a power failure. Assume the temperature (T) is given by:

      T = ( 4 * t * t / ( t + 2) ) - 20 (deg C)

      where: t is the time since the power failure in hours.