Home › Forums › IB Pseudo Code › Pseudo Code on Collection 16 Sep Past paper part a
- This topic has 7 replies, 6 voices, and was last updated 3 years, 12 months ago by
Shiva Chandnani.
- AuthorPosts
- September 16, 2021 at 3:57 am #6635
Eamonn
KeymasterShare your pseudo code solution for moving the collection names into 2 arrays past paper 2021 (Q13 Part a) link here
September 16, 2021 at 4:44 am #6644girwan
ParticipantFIRST_NAME = 0
LAST_NAME = 0
i = 0
//assumes the first element is always the last name and second element is first name
NAMES.resetNext()
loop while NAME.hasNext() = True
LAST_NAME[i] = NAMES.getNext() //stores the item from collection in index i of array LAST_NAME
FIRST_NAME[i] = NAMES.getNext()
i = i + 1
end loopSeptember 16, 2021 at 5:05 am #6645Shiva Chandnani
ParticipantSURNAME = 0
FIRSTNAME = 0
i = 0
NAMES.resetNext() //restarts to the beginning of the collection
loop while NAMES.hasNext() = True //looping throught he collection using a while loop
SURNAME[i] = NAMES.getNext(). //storing the Surnames into a seperate array
FIRSTNAME[i] = NAMES.getNext(). // Storing the First Names into a other array
i=i+1 //allows us to add the names into the next space in the arrays
end loopSeptember 16, 2021 at 5:13 am #6648joshua7
ParticipantSet SURNAME to 0
Set FIRSTNAME to 0
i = 0
NAMES.resetNext()
loop while NAMES.hasNext() = True //looping through using a while loop
SURNAME[i] = NAMES.getNext(). //stores the Surnames in a different array
FIRSTNAME[i] = NAMES.getNext(). // stores the First Names in a different array
i = i + 1
end loopSeptember 16, 2021 at 5:13 am #6649Sang
Participanti=0
Names.reset.Next()//assume first element is surname and second element is first name
loop while Names.has.next() = True
surname[i]=Names.getnext()
firstname[i]=Names.getnext()// storing names in different array
i=i+1
end loopSeptember 16, 2021 at 5:18 am #6651Irfan
Participant//It is assumed first names and surnames can be distinguised from each other.
`SURNAME = (…)
FIRSTNAME = (…)
Loop x though NAMES while NAMES.HasNext()
NAMES[Firstname] = NAMES.GETNEXT(surname)
NAMES[Surname] = NAMES.GETNEXT(firstname)
end loop
print(SURNAME)
print(FIRSTNAME)September 16, 2021 at 5:29 am #6652Irfan
Participant//It is assumed first names and surnames can be distinguised from each other.
`SURNAME = (…)
FIRSTNAME = (…)
Loop x though NAMES while NAMES.HasNext()
SURNAME(x) = NAMES.GETNEXT(surname)
FIRSTNAME(x) = NAMES.GETNEXT(firstname)
end loop
print(SURNAME)
print(FIRSTNAME)September 16, 2021 at 5:30 am #6653Shiva Chandnani
Participant - AuthorPosts
- You must be logged in to reply to this topic.