Hey there! Sign in to join this conversationNew here? Join for free

Can anyone give me and example of a pseudo code or an algorithm please?? Watch

    • Thread Starter
    Offline

    3
    ReputationRep:
    I need to create one for computer Science but i'm stuck. Can anyone please give me an example??

    Thanks
    • TSR Support Team
    Online

    21
    ReputationRep:
    TSR Support Team
    (Original post by bluepearl7)
    I need to create one for computer Science but i'm stuck. Can anyone please give me an example??
    The formatting on TSR keeps going messed up so I've put every other line in red so hopefully it will make more senseIt all depends what you're trying to do with it.Pseudo code is where you write the purpose of your code in structured English.eg.output<--"What is your name?"input<--user inputoutput<--Hello & inputThat's a really bad example sorry but I'm trying to sort my English speaking so I don't have time to think of something better sorry
    • Thread Starter
    Offline

    3
    ReputationRep:
    (Original post by Lemur14)
    It all depends what you're trying to do with it.Pseudo code is where you write the purpose of your code in structured English.eg.output<--"What is your name?"input<--user inputoutput<--Hello & inputThat's a really bad example sorry but I'm trying to sort my English speaking so I don't have time to think of something better sorry
    yeah, i'm trying to write pseudo code for my CA-i need to create a troubleshooting system for phones.
    Oh okay, thanks and good luck with your speaking.
    • TSR Support Team
    Online

    21
    ReputationRep:
    TSR Support Team
    (Original post by bluepearl7)
    yeah, i'm trying to write pseudo code for my CA-i need to create a troubleshooting system for phones.
    Oh okay, thanks and good luck with your speaking.
    I worked that out from your other thread lol. I had to write pseudo code for my CA but I'm with AQA so it's actually surprisingly different. Thanks
    Offline

    15
    ReputationRep:
    https://en.wikipedia.org/wiki/Pseudocode

    I don't know precisely what you need, but the idea behind pseudocode is you write the workflow of your code without adhering to any specific programming protocols. Basically, it is a quick way of drafting out your code in a manner which is far easier for the human eye to read, hence quite complicated algorithms can be more easily worked out and/or communicated.

    As a loose example, if I wanted to write code which prints a given word a certain number of times and then outputs the word in pig latin, it would look like this in python [I know python doesn't use { }, but tabs don't work here - just pretend I've formatted it correctly, mmmkay?]

    def example_function(word, number_of_iterations)
    {
    Word = word_to_convert
    for i in range(0, number_of_iterations)
    {
    print Word
    }
    first_letter = Word[0]
    Word = Word[1:]
    Word = Word + first_letter + "ay"
    return Word
    }

    In pseudocode, this would be written as

    Input: String "original_word", int number_of_iterations_the_user_wa nts
    Output: String "word_converted_to_pig_latin "

    def example function(word_to_convert, number)
    {
    save word_to_convert as a local variable, Word
    for i in range(0, number)
    {
    print Word
    }
    extract first letter from Word, save as variable first_letter
    remove first letter from Word
    append variable first_letter and String "ay" to Word
    return Word
    }

    To be honest, this isn't a great example - not only is it fairly simple, python is a language already geared towards readability, hence the uses of it aren't going to be too apparent. However,if you were to be working with a complex algorithm (think several hundred lines of code, at least) in an older language like C, you can hopefully imagine how it's more practical to first work with pseudocode, then think about how it should be formatted in whatever language.

    Also, I don't work often with pseudocode, so please don't take the way I've written it as a gold standard; it's likely that your course has a specification for the style they want, and what I've done isn't ideal. I'd look at past exam papers, if you can find them, learn the standard way they want for loops/while loops/setting variables/etc. written and conform to that in an exam/coursework setting. I was just getting across the idea that pseudocode is basically writing your code in a style more akin to human languages, making it easier to read.
 
 
 
  • See more of what you like on The Student Room

    You can personalise what you see on TSR. Tell us a little about yourself to get started.

  • Poll
    Would you like to hibernate through the winter months?
    Useful resources

    Study tools

    Rosette

    Essay expert

    Learn to write like a pro with our ultimate essay guide.

    Thinking about uni already?

    Thinking about uni already?

    See where you can apply with our uni match tool

    Student chat

    Ask a question

    Chat to other GCSE students and get your study questions answered.

    Creating

    Make study resources

    Create all the resources you need to get the grades.

    Planner

    Create your own Study Plan

    Organise all your homework and exams so you never miss another deadline.

    Resources by subject

    From flashcards to mind maps; there's everything you need for all of your GCSE subjects.

    Papers

    Find past papers

    100s of GCSE past papers for all your subjects at your fingertips.

    Help out other students

    Can you help? Study help unanswered threads

    Groups associated with this forum:

    View associated groups
  • See more of what you like on The Student Room

    You can personalise what you see on TSR. Tell us a little about yourself to get started.

  • The Student Room, Get Revising and Marked by Teachers are trading names of The Student Room Group Ltd.

    Register Number: 04666380 (England and Wales), VAT No. 806 8067 22 Registered Office: International House, Queens Road, Brighton, BN1 3XE

    Quick reply
    Reputation gems: You get these gems as you gain rep from other members for making good contributions and giving helpful advice.