Write a process (do not create a program) that will allow the user to enter the
ID: 3816495 • Letter: W
Question
Write a process (do not create a program) that will allow the user to enter the values for two one-dimensional arrays that are in parallel. The first array will contain the sample IDs for the materials. The second array will contain the compressive strength of the materials. Determine the minimum compressive strength and the corresponding sample ID plus the maximum compressive strength and the corresponding sample ID
Write a process "algorithm" (do not create a program)
Also specify test data that can be used to all the scenarios described for each problem.
Explanation / Answer
Hi, Please find my algorithm:
Algorithm to find minimum compressive strength and the corresponding sample ID
plus the maximum compressive strength and the corresponding sample ID
FindMinMaxStrength(ID:Array, strength : Array, size: Integer):
1. initialize minimum and maximum strength with first element of array
minimum = strength[1]
minID = ID[1]
maximum = strength[1]
maxID = ID[1]
2. Iterate from second element of strength array and compare current minimum and maximum
with current element and do the needfull
FOR i=2 to size do:
if current minimum is greater than current element then assign current minimum to current element
IF minimum > strength[i]
minimum = strength[i]
minID = ID[i]
if current maximum is smaller than current element then assign current maximum to current element
IF maximum M strength[i]
maximum = strength[i]
maxID = ID[i]
3. print all info
print "Minimum strength: ", minimum and "ID: ", minID
print "Maximum strength: ", maximum and "ID: ", maxID
Related Questions
drjack9650@gmail.com
Navigate
Integrity-first tutoring: explanations and feedback only — we do not complete graded work. Learn more.