ITI 1220 Fall 2005 - Assignment 5

Available: Friday October 7
Due: Monday October 17, noon

Instructions

This assignment is to be done in TEAMS OF TWO PEOPLE. The assignment should be submitted only once by a member of your team, but please ensure that the identification material contains the information for both team members. Follow the instructions in the lab manual for submitting assignments.

Your algorithms should be developed using the format used in class. Your algorithm traces should use the format shown in class; a separate table is to be used for each call to each algorithm. Programs should be based on the template file, and should follow good coding practices as described in the course lab manual.

Marking Scheme (total 100 marks)

  • Regulations and Standards: 10 marks
  • Question 1: 40 marks
  • Question 2: 25 marks
  • Question 3: 25 marks

Question 1 (40 marks)

A 60 kilogram object is to be hung from the end of a rigid 3 metre horizontal pole of negligible mass, as shown in the figure below.  The pole is attached to a wall by a pivot and is supported by a 3 metre cable which is attached to the wall at a higher point.

 

The tension on the cable is given by the following equation:

 

 

where:

  • T is the tension on the cable, measured in Newtons (1 N = 1 kg ∙ m/s2)
  • M is the mass of the object, in kilograms (kg)
  • g is the gravitational constant, 9.8 metres per second-squared (m/s2)
  • lc is the length of the cable, in metres (m)
  • lp is the length of the pole, in metres (m)
  • d is the distance from the wall to the attachment point of the cable, in metres (m)

 

Part a) (20 marks)

 

Design an algorithm to determine the distance d at which to attach the cable to the pole in order to minimize the tension on the cable.  To do this, the algorithm should calculate the tension at 0.05 metre intervals from d = 0.5 metres to d = 2.5 metres, and keep track at which of those points that the tension had the minimum value. 

 

The GIVENS for your algorithm should be the mass of the object, and the lengths of the cable and the pole.

 

Your algorithm should have as RESULTS the distance d at which the minimum tension occurs, as well as the tension T at that distance.

 

Part b) (20 marks)

 

Translate your algorithm from Question 1 part a) to Java.

 

Question 2 (25 marks total)

Part a) (15 marks)

 

Design an algorithm that will determine whether or not an array A of length N is sorted in increasing order.  This means that within the array, if you compare the values in two consecutive array positions, the value at the lower array index is less than or equal to the value at the higher array index.

 

Your algorithm should immediately terminate the loop if it is discovered that the array is not sorted.

 

Part b) (10 marks)

 

Trace your algorithm using this array:  { 5, 8, 8, 7, 12 }

 

Question 3 (25 marks total)

Part a) (15 marks)

 

Design an algorithm that will copy the values from a section of AnArray to a new array SubArray, where the section of AnArray to copy is from index Lower to index Upper inclusive.  That is, SubArray [0] receives a copy of the value in AnArray[Lower], SubArray [1] receives a copy of AnArray[Lower+1] and so on until the final value that is copied is AnArray[Upper].

 

 

Part b) (10 marks)

 

Trace your algorithm using the following GIVENS:

 

AnArray = { 20, 19, 18, 17, 16,  15, 14, 13, 12, 11, 10 }

Lower = 3

Upper = 5