Home › Forums › Grade 12 IB › Pseudo Code Review Arrays Level 1
- This topic has 5 replies, 6 voices, and was last updated 3 years, 3 months ago by
joshua7.
- AuthorPosts
- October 27, 2021 at 9:21 am #6945
Eamonn
KeymasterPseudo Code Review Arrays level 1
//==== Checking Lists for Duplicates ====================
// Write a program compares two lists, stored in Arrays,
// output any duplicate names that appear in both lists.
TENNIS = [“Al”,”Bobby”,”Carla”,”Dave”,”Ellen”]
BBALL = [“Lou”,”Dave”,”Hellen”,”Alan”,”Al”]October 28, 2021 at 4:42 am #6970girwan
ParticipantTENNIS = […]
BBALL = […]
LOOP I FROM 0 TO N-1
LOOP J FROM 0 TO N-1
IF TENNIS[I] = BBALL[J] THEN // COMPARES ONE ELEMENT OF TENNIS WITH EACH ELEMENT OF BBALL
OUTPUT TENNIS[I]
END IF
END LOOP
END LOOPOctober 28, 2021 at 4:42 am #6971Shiva Chandnani
ParticipantTENNIS = [“Al”,”Bobby”,”Carla”,”Dave”,”Ellen”]
BBALL = [“Lou”,”Dave”,”Hellen”,”Alan”,”Al”]loop for i from 0 to n-1
loop for j from 0 to n-1
if tennis[I] = Bball[j] then
output tennis[i]
end if
end loop
end loopOctober 28, 2021 at 4:44 am #6972Sang
ParticipantTENNIS = [“Al”,”Bobby”,”Carla”,”Dave”,”Ellen”]
BBALL = [“Lou”,”Dave”,”Hellen”,”Alan”,”Al”]loop i from 0 to n-1
loop j from o to n-1October 28, 2021 at 4:44 am #6973Irfan
ParticipantTENNIS = [“Al”,”Bobby”,”Carla”,”Dave”,”Ellen”]
BBALL = [“Lou”,”Dave”,”Hellen”,”Alan”,”Al”]
duplicate = “0”
ta = “0”
loop ta from 0 to 4
if ta = BBALL
duplicate = TENNIS[ta]
end loopoutput[duplicate]
October 28, 2021 at 4:44 am #6975joshua7
ParticipantTENNIS = [“Al”,”Bobby”,”Carla”,”Dave”,”Ellen”
BBALL = [“Lou”,”Dave”,”Hellen”,”Alan”,”Al”]for Tennis from 0 to n-1
for BBall from 0 to n-1
if TENNIS[] = BBALL[]
Output Tennis[] - AuthorPosts
- You must be logged in to reply to this topic.