Pseudo Code on Collection 16 Sep Past paper part a

Home Forums IB Pseudo Code Pseudo Code on Collection 16 Sep Past paper part a

Viewing 8 posts - 1 through 8 (of 8 total)
  • Author
    Posts
  • #6635
    Eamonn
    Keymaster

    Share your pseudo code solution for moving the collection names into 2 arrays past paper 2021 (Q13 Part a) link here

    • This topic was modified 10 months, 4 weeks ago by Eamonn.
    • This topic was modified 10 months, 4 weeks ago by Eamonn.
    • This topic was modified 10 months, 4 weeks ago by Eamonn.
    • This topic was modified 10 months, 4 weeks ago by Eamonn.
    #6644
    girwan
    Participant

    FIRST_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 loop

    • This reply was modified 10 months, 4 weeks ago by girwan.
    • This reply was modified 10 months, 4 weeks ago by girwan.
    #6645
    Shiva Chandnani
    Participant

    SURNAME = 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 loop

    #6648
    joshua7
    Participant

    Set 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 loop

    #6649
    Sang
    Participant

    i=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 loop

    #6651
    Irfan
    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)

    #6652
    Irfan
    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)

    #6653
    Shiva Chandnani
    Participant
Viewing 8 posts - 1 through 8 (of 8 total)
  • You must be logged in to reply to this topic.
Scroll to Top