Hey there! Sign in to join this conversationNew here? Join for free
x Turn on thread page Beta
    • Thread Starter
    Offline

    2
    ReputationRep:

    Don't really understand the steps in the question. What do you do from Step 4 onwards? 😕


    Sent from my iPhone using Tapatalk
    Offline

    22
    ReputationRep:
    SeanFM might be able to help here, I don't do Decision, unfortunately, sorry!
    • Very Important Poster
    Offline

    21
    ReputationRep:
    Very Important Poster
    (Original post by TSRforum)

    Don't really understand the steps in the question. What do you do from Step 4 onwards? 😕


    Sent from my iPhone using Tapatalk
    Have you followed it up to Step 3?

    What do you think it's doing in Step 4?
    Offline

    13
    ReputationRep:
    (Original post by TSRforum)

    Don't really understand the steps in the question. What do you do from Step 4 onwards? 😕


    Sent from my iPhone using Tapatalk

    step 2 sets up the following array 1 2 3 4 5 step 3 sets j as 1

    Step 4 generates a random number in the range 1 to 5 see note (a) in the question. The number generated is 3 and r now equals 3
    It swaps the array element j ie. element 1 with element r ie element 3. After this point element 1 holds the number 3 and element 3 holds the number 1.
    j is now increased by 1 to give j as 2
    one is subtracted from n to give n = 4
    as n does not equal j the loop is repeated ie. control passes back to the beginning of step 4
    • Thread Starter
    Offline

    2
    ReputationRep:
    (Original post by maggiehodgson)
    step 2 sets up the following array 1 2 3 4 5 step 3 sets j as 1

    Step 4 generates a random number in the range 1 to 5 see note (a) in the question. The number generated is 3 and r now equals 3
    It swaps the array element j ie. element 1 with element r ie element 3. After this point element 1 holds the number 3 and element 3 holds the number 1.
    j is now increased by 1 to give j as 2
    one is subtracted from n to give n = 4
    as n does not equal j the loop is repeated ie. control passes back to the beginning of step 4

    Anything I did wrong here? (Mind the 2 arrows pointing to 4 in perm(2))


    Sent from my iPhone using Tapatalk
    Offline

    13
    ReputationRep:
    (Original post by TSRforum)

    Anything I did wrong here? (Mind the 2 arrows pointing to 4 in perm(2))


    Sent from my iPhone using Tapatalk
    Sorry for the delay in reply. And now I'm back on TSR I can't read your workings properly. I'll try again.
    Offline

    13
    ReputationRep:
    (Original post by TSRforum)

    Anything I did wrong here? (Mind the 2 arrows pointing to 4 in perm(2))


    Sent from my iPhone using Tapatalk
    I got the same up to the last step. I imagine that you're doing it right and I'll have made an error on the last line somewhere.

    However, I think that the array is called Perm. Perm is a special type of variable that can hold 5 different values at the same time. Each element of the array is accessed by an index that is the position in the array. So I think that labelling the rows as Perm(1), Perm(2).. etc was a bit mis-leading for me.

    So I set my work out like this (see the attachment).
    Attached Images
  1. File Type: pdf Scan0008.pdf (139.7 KB, 44 views)
    • Thread Starter
    Offline

    2
    ReputationRep:
    (Original post by maggiehodgson)
    I got the same up to the last step. I imagine that you're doing it right and I'll have made an error on the last line somewhere.

    However, I think that the array is called Perm. Perm is a special type of variable that can hold 5 different values at the same time. Each element of the array is accessed by an index that is the position in the array. So I think that labelling the rows as Perm(1), Perm(2).. etc was a bit mis-leading for me.

    So I set my work out like this (see the attachment).
    Your answer is right though why is there three step 4's? And why is step 3 blank with j=1? Also what about r=5 doesn't that get used? 😣


    Sent from my iPhone using Tapatalk
    Offline

    13
    ReputationRep:
    (Original post by TSRforum)
    Your answer is right though why is there three step 4's? And why is step 3 blank with j=1? Also what about r=5 doesn't that get used? 😣


    Sent from my iPhone using Tapatalk
    The only change to the variables in step 3 is when j gets set to 1. None of the others get changed so whatever they were in previous steps remain on earlier rows.

    Step 4 is a loop and many things happen in it. Array elements get swapped and j and r change so they are all on the line called Step4. I suppose you could have split that line into many lines with only one row header but I didn't. At the end of the loop, control returns to the first instruction in Step 4.

    Now, in my work, I did have an extra line that had r = 5 but the end result of that did not match yours whilst all the others did. I assumed that I would be wrong so folded over my last line before scanning.

    In a previous post I did say that the way to present you table could well vary from exam board to exam board so my workings with all of Step4 being on one line might not be right for you. You would have to check that with your school.

    Hope my explanation is OK for you.
 
 
 
Reply
Submit reply
Turn on thread page Beta
Updated: February 14, 2016
Poll
Do you like carrot cake?
Useful resources

Make your revision easier

Maths

Maths Forum posting guidelines

Not sure where to post? Read the updated guidelines here

Equations

How to use LaTex

Writing equations the easy way

Student revising

Study habits of A* students

Top tips from students who have already aced their exams

Study Planner

Create your own Study Planner

Never miss a deadline again

Polling station sign

Thinking about a maths degree?

Chat with other maths applicants

Can you help? Study help unanswered threads

Groups associated with this forum:

View associated groups

The Student Room, Get Revising and Marked by Teachers are trading names of The Student Room Group Ltd.

Register Number: 04666380 (England and Wales), VAT No. 806 8067 22 Registered Office: International House, Queens Road, Brighton, BN1 3XE

Write a reply...
Reply
Hide
Reputation gems: You get these gems as you gain rep from other members for making good contributions and giving helpful advice.