MedVision ad

Algorithm (PSEUDOCODE HELP) (1 Viewer)

higherpeak

New Member
Joined
Sep 7, 2017
Messages
1
Gender
Male
HSC
2018
For software homework I need to create a pseudocode algorithm which reads a list of best scores (up to 5) from a sequential file and determines whether the current score (in a game) should be inserted into the list (leaderboard)

USING:
Algorithm from the HSC Past Paper:
Code:
BEGIN swap(x)
  temp = TOPPLAYERS[x]
  TOPPLAYERS[x] = TOPPLAYERS[x-1]
  TOPPLAYERS[x-1] = temp
END swap

IF newscore > TOPPLAYERS[10].totalscore THEN
  TOPPLAYERS[10].totalscore = newscore
  TOPPLAYERS[10].name = newname
  found = false
  x =10
  WHILE found = false AND x > 1
     IF TOPPLAYERS(x).totalscore > TOPPLAYERS[x – 1].totalscore THEN
         swap(x)
          x = x – 1
     ELSE 
          found = true 
     ENDIF 
   ENDWHILE
ENDIF

And the Standard Sequential File Algorithms (via Course Specifications page 65-66)

https://www.boardofstudies.nsw.edu..../software-design-development-course-specs.pdf
 

Users Who Are Viewing This Thread (Users: 0, Guests: 1)

Top