Algorithms

P23

New member
Joined
Jan 19, 2017
Messages
3
I am trying to help someone with some math homework and have hit a stumbling block. The first one is when a problem asks what the algorithm is returning - I am not always seeing the pattern and wondered if there are set rules for determining this type of answer.
Also, I thought I had this one figured out, but I was wrong :smile:
Thank you for any help you might be able to give me.

Consider this algorithm:

Input: Two integers a and b
Output: the difference of a and b
(1) Return a-b
Find the output of the algorithm for the input a:=7 and b:=-7 Answer:
Find the output of the algorithm for the input a:=14 and b:=19 Answer:
Find the output of the algorithm for the input a:=0 and b:=4 Answer:
 
Last edited by a moderator:
I am trying to help someone with some math homework and have hit a stumbling block. The first one is when a problem asks what the algorithm is returning - I am not always seeing the pattern and wondered if there are set rules for determining this type of answer.
Also, I thought I had this one figured out, but I was wrong :)
Thank you for any help you might be able to give me.

Consider this algorithm:

Input: Two integers a and b
Output: the difference of a and b
(1) Return a-b
Find the output of the algorithm for the input a:=7 and b:=-7 Answer:
Find the output of the algorithm for the input a:=14 and b:=19 Answer:
Find the output of the algorithm for the input a:=0 and b:=4 Answer:
What were your answers?
 
Answers: 14, 5 and 4


I am trying to help someone with some math homework and have hit a stumbling block. The first one is when a problem asks what the algorithm is returning - I am not always seeing the pattern and wondered if there are set rules for determining this type of answer.
Also, I thought I had this one figured out, but I was wrong :)
Thank you for any help you might be able to give me.

Consider this algorithm:

Input: Two integers a and b
Output: the difference of a and b
(1) Return a-b
Find the output of the algorithm for the input a:=7 and b:=-7 Answer:
Find the output of the algorithm for the input a:=14 and b:=19 Answer:
Find the output of the algorithm for the input a:=0 and b:=4 Answer:
 
Last edited:
I am trying to help someone with some math homework and have hit a stumbling block. The first one is when a problem asks what the algorithm is returning - I am not always seeing the pattern and wondered if there are set rules for determining this type of answer.
Also, I thought I had this one figured out, but I was wrong :)
Thank you for any help you might be able to give me.

Consider this algorithm:

Input: Two integers a and b
Output: the difference of a and b
(1) Return a-b
Find the output of the algorithm for the input a:=7 and b:=-7 Answer:
Find the output of the algorithm for the input a:=14 and b:=19 Answer:
Find the output of the algorithm for the input a:=0 and b:=4 Answer:
Answers:

14 = correct

5 =incorrect = a - b = 14 - 19 = -5

4
=incorrect = a - b = 0 - 4 = - 4

 
Top