Thursday, November 10, 2016

Sorting Algorithm Reflection

Write a human machine language program that: Repeatedly shifts the left hand to the right until it finds a 5 or 6 The program should stop when the left hand is at (or past) the end of the list, or it finds a 5, or it finds a 6.

1
Shift LH right
2
if LHCard EQ 5, jump to line 6
3
if LHCard EQ 6, jump to line 6
4
if LHPosition EQ 7, jump to line 6
5
jump to line 1
6
stop



Find min:


1
jump to line 3 if RHand LT LHand
2
shift RHand right
3
move LHand to RHand if RHand LT LHhand
4
jump to line 1 if RHPos NE 7
5
Stop

When working with your partner in class, what challenges did you face in writing your algorithm? Were you able to solve it? If yes, then How did you solve it?  

     One challenge we had to solve was when our partition algorithm got stuck in a infinite loop. It would keep going through the lower value cards with no stop point. To fix this, we made it so the cards don't go to position 0 if they were smaller than the initial card value, and instead stayed in their original position. That way, we could end the "program" when the left hand reached the card at position 0.

Make connections with our algorithms and previous coding experience we have:
What programming statements have you used in the past that you would use in writing your algorithms?  Have you written similiar programs?  If yes write the programs that you remember writing.(you are not giving me the code just making connections here and remembering what you have done)

     Some statements I would use are if, >, <, =, and while loop. I think I have written a program in the past to sort numbers.


No comments:

Post a Comment