1. Limited time only! Sign up for a free 30min personal tutor trial with Chegg Tutors
    Dismiss Notice
Dismiss Notice
Join Physics Forums Today!
The friendliest, high quality science and math community on the planet! Everyone who loves science is here!

Converting flowchart to pseudocode

  1. Jan 16, 2013 #1
    1. The problem statement, all variables and given/known data
    The problem I am having trouble with has to do with pseudocode and flowcharts. We were told that indeed any pseudocode can be represented by flowcharts; however, our professor said that due to the rules that he gave us for this class, it is possible to represent a flowchart that cannot be converted into pseudocode. I am having trouble seeing this, so perhaps you guys can help.

    Here are the rules pertaining to the flowcharts:
    atomic actions are represented by rectangular boxes. There is one arrow in and one arrow out.
    Start and Stop has one arrow out and one arrow in, respectively. They are represented by oval boxes.
    Diamond boxes denote choices/conditions. It says there can be one arrow in and two out (true/false).
    Bullets can have one or more arrow in and one arrow out; purely presentational.

    3. The attempt at a solution
    I have tried numerous combinations but it seems that I am able to convert them all into pseudocode given these rules. Any ideas?
     
  2. jcsd
  3. Jan 16, 2013 #2

    jedishrfu

    Staff: Mentor

    The only thing I can think of is that its related to the halting problem or if an atomic operation has some sort of side-effect.
     
  4. Jan 16, 2013 #3
    Yeah, this is the last question and it certainly has me stumped. He has yet to talk about said "halting problem" or any possible adverse side-effects exhibited by atomic actions.

    I can do the opposite; that is, I could develop pseudocode that cannot be represented by the flowcharts (with his set of rules) easily. For example, if I did a pseudocode that had a choice branch that had more than two options it would require more than two arrows to leave the diamond. However, working from flowcharts to the pseudocode appears to be more difficult.
     
  5. Jan 16, 2013 #4

    rcgldr

    User Avatar
    Homework Helper

    It seems that this would require an arbitrary restriction on pseudcode that wasn't applied to flowcharts in your class.

    Note that there are programs like AllClear that generate flowcharts based on a psuedocode like language that the user inputs into a text file, so I'm not sure of the point your professor is trying to make.
     
  6. Jan 16, 2013 #5

    gneill

    User Avatar

    Staff: Mentor

    If the pseudocode language forbids GOTO with labeled destinations, then I imagine you could lay out a flow chart with jumps into and out of overlapping loop structures that would be pretty hairy to render into pseudocode.
     
  7. Jan 16, 2013 #6
    I'm not sure what point he is trying to make either. He explicitly points out that all flowcharts can be represented by pseudocode (opposite true as well), but he says that given the rules presented in topic 2 (which I have shared with you guys already) it is possible to build a flowchart that cannot be represented by pseudocode. I might just have to take an L on this one.
     
  8. Jan 16, 2013 #7

    jedishrfu

    Staff: Mentor

    Be creative and come up with something perhaps mix quantum entanglement into the picture or fuzzy logic. You might still get a laugh and a better grade and you just might disover what he's alluding to.

    One thing I noticed is that interrupts don't seem to be included so that basically the atomic action occurs and can't be interrupted. Also what about exceptions when the atomic operation fails. These two states would require a receive interrupt arrow and transmit interupt arrow.
     
  9. Jan 16, 2013 #8

    jedishrfu

    Staff: Mentor

    what if you tied the output of the if to the input of the if? How would you represent that as programmable psuedo code?
     
  10. Jan 16, 2013 #9
    Right, that makes sense. No where in the rules does he specify rules pertaining to the different types of choice blocks that there is; hence, if you had an if block that had the true connected to very same if block, it wouldn't able to be converted to pseudocode.

    What about an atomic action looped to itself? Essentially there would be no end. With pseudocode, this would have to be repetition and therefore a choice block. Does that make sense?
     
  11. Jan 16, 2013 #10

    rcgldr

    User Avatar
    Homework Helper

    As a while loop

    Code (Text):

        while(interrupt_occurred == false)
        endwhile
     
    or with a label and goto

    Code (Text):

    wait_for_interrupt:
        if(interrupt_occurred == false)
            goto wait_for_interrupt
     
     
  12. Jan 16, 2013 #11

    gneill

    User Avatar

    Staff: Mentor

    Much depends upon what control structures are available in the given pseudocode language. Are GOTOs permitted? Recursion?
     
  13. Jan 16, 2013 #12
    There is nothing mentioned of GOTOs or recursion. This is a course in C++ and it is intended for students who have never programmed before. This is the second week of classes, and therefore, the programming language itself has barely crept its way into lectures.
     
  14. Jan 16, 2013 #13

    gneill

    User Avatar

    Staff: Mentor

    The elements of the pseudo code language were not presented? How can one claim that something cannot be implemented in a language that is not specified? :confused:
     
  15. Jan 16, 2013 #14
    Very minimal was stated about pseudocode. Here is the only information presented:
    "It is quite common, in textbooks and research reports, to see algorithms written in a hybrid
    of plain language and a programming language throughout Computer Science; we call these
    hybrid descriptions “pseudocode” (pseudo- is a prefix that means “fake”). The idea behind
    pseudo-code is to use the best of both languages. We will use plain English to describe actions
    that do not need to be expressed with pin-point precision, and use programming language constructs
    when the actions require precision. Do not be too concerned at this point if you don’t feel
    you can tell the difference yet; it is something that comes with experience and practice.
    In this course, we will focus on using language to communicate algorithms, but we’ll also
    use diagrams called flow charts from time to time to help clarify our explanations."

    From this description he immediately goes into applying pseudocodes to flowcharts. The question specifically states that we can answer that question based on the rules that we have for the flowcharts. It even directs me to the slide that the rules are on (which I have given).

    Furthermore, for the example one can use abstract components; they need not to have meaning.
     
    Last edited: Jan 16, 2013
  16. Jan 16, 2013 #15

    gneill

    User Avatar

    Staff: Mentor

    So, the flowchart rules, as given, do not place any limit on the number of STARTs?
     
  17. Jan 16, 2013 #16
    Yeah, it does say only one of each. Thought I had that in there but I missed that. I just double checked the rest is essentially word for word:

    atomic actions are represented by rectangular boxes. There is one arrow in and one arrow out.
    Start and Stop has one arrow out and one arrow in, respectively. They are represented by oval boxes, and there is only one of each
    Diamond boxes denote choices/conditions. It says there can be one arrow in and two out (true/false branches).
    Bullets can have one or more arrow in and one arrow out; purely presentational; they have no function.
     
  18. Jan 16, 2013 #17

    rcgldr

    User Avatar
    Homework Helper

    Bullets would be the equivalent of labels in pseudocode. Again, since some flowchart tools like AllClear use pseudocode to create flowcharts, I don't see why your professor is claiming that some flow charts don't have a pseudocode equivalent.
     
  19. Jan 16, 2013 #18
    Are arrows obliged to connect two elements, or can you just leave them dangling?
     
  20. Jan 16, 2013 #19
    It doesn't say anything about that, but if there are no atomic actions/conditions left to be executed it is assumed one goes to "stop"
     
  21. Jan 16, 2013 #20
    Page 19 in the textbook sets out the constraints of an algorithm. It must be unambiguous, executable and terminating. Infinite loop violates this.
     
Know someone interested in this topic? Share this thread via Reddit, Google+, Twitter, or Facebook




Similar Discussions: Converting flowchart to pseudocode
  1. Logarithm flowchart (Replies: 3)

  2. Pseudocode help (Replies: 0)

  3. Pseudocode problem (Replies: 5)

  4. Flowcharts Help (Replies: 3)

Loading...