Login

Welcome, Guest. Please login or register.

May 10, 2025, 04:18:25 pm

Author Topic: Pseudocode help  (Read 4459 times)  Share 

0 Members and 1 Guest are viewing this topic.

Jacko1394

  • Victorian
  • Adventurer
  • *
  • Posts: 5
  • Respect: 0
Pseudocode help
« on: May 30, 2012, 04:06:36 pm »
0
Alright, so I'm all good with the coding we do at school.
Only problem is my teacher is the worst and BARELY went over how to do pseudocode.
Would anyone here be able to help me and my class out, and help us do what we call 'pseudes'
thanks :)

Mod-edit: Removed all-caps from thread title :) - laseredd
« Last Edit: May 30, 2012, 05:01:28 pm by laseredd »

Lasercookie

  • Honorary Moderator
  • ATAR Notes Legend
  • *******
  • Posts: 3168
  • Respect: +326
Re: Pseudocode help
« Reply #1 on: May 30, 2012, 04:56:59 pm »
+1
Pseudocode is basically just for designing code, you're basically writing out code in written English. It's a good stepping stone from going from your original algorithm idea to actually writing out the code. Given pseudocode, you should be able to figure out the algorithm and vice versa.

The problem with pseudocode is that there isn't one set convention, so it's best to take a look at the past exams, you'll see a few examples of it - especially important to know what VCAA expects you to understand - e.g. the notation where you have assignment as . Often you might come across pseudocode that's a lot less structured, e.g. the example that Mark Kelly provides on VCEIT: http://www.vceit.com/designtools/pseudocode.htm. (I prefer this looser pseudocode, it seems a bit more logical as pseudocode is a way for you to design code, but we have to do what VCAA wants us to do). What your teacher expects for SACS might also vary a bit to what you're expected to interpret on the exams.

VCAA 2010, Short Answer Question 9 (page 18) had a example of pseudocode for password validation:
http://www.vcaa.vic.edu.au/vcaa/vce/studies/infotech/softwaredevel/pastexams/2010/2010itsoftdev-w.pdf

Most exams, including last years and the sample exam for this study design have had some form of pseudocodelike this, but I think this one is a good one to use to learn it initially (fairly simple what's going on here):

Quote from: VCAA 2010
Begin
   Get Password
   Charcount 1
   PasswordChar 1st Character of Password
   ValidPassword True
   
   Repeat
      PasswordChar Next Character of Password
      Charcount Charcount +1
            If (PasswordChar is Not Numeric) Or (PasswordChar is Not Alphabetic) Then
                ValidPassword False
            EndIf
   Until Charcount = length(password)

   If ValidPassword = False Then
          Print ‘Password rejected’
   Else
          Print ‘Password accepted’
   EndIf
End

Have a go at trying to read this (if you're unsure of any steps here, let me know). Things like "Charcount 1" is assigning the value 1 to a variable named Charcount (representing the direction of data, I guess); Repeat is a loop that keeps going until the condition is met etc. Also note the Begin...End kind of structure.
 
Now this doesn't represent all the possibilities you might see with pseudocode, if you look in the textbook/other exams, you'll notice a lot more other things, things like For ... EndFor, While...EndWhile - if you have the textbook there's a list of all that stuff. There's also stuff for naming procedures (functions) etc.

There's also this worksheet by Mark Kelly (the vceit.com guy) and another teacher:
Pseudocode Questions: http://www.edulists.com.au/sofdev/exams/SD%20pseudocode%20error%20questions-mk.doc
Suggested Solutions: http://www.edulists.com.au/sofdev/exams/2011/Pseudocode%20Answers%20-nm.pdf

Might be worthwhile having a shot at those. You could also try looking at some code you've written and writing out the pseudocode for that.

Also, just as an aside for future reference, avoid using all capital letters in thread titles, I've fixed it up here for you now.

edit: fixed indentation in code example (sort of, it's still out of alignment a bit)
« Last Edit: May 30, 2012, 05:06:05 pm by laseredd »