Trouble with figuring out the flowchart to pseudocode problem

Please support our Computer Science advertiser: Learn about neural networks and artificial intelligence.
Thread Solved
Reply

Join Date: Jan 2006
Posts: 24
Reputation: waldis is an unknown quantity at this point 
Solved Threads: 0
waldis's Avatar
waldis waldis is offline Offline
Newbie Poster

Trouble with figuring out the flowchart to pseudocode problem

 
0
  #1
Jan 15th, 2006
Hi, could someone to direct me the right way with this? Here is the problem, which I think I have nailed:

before:

	 A
	 if c then goto X
	 B
	 if d then goto Y
	 C
X:	 D
	 E
Y:	 F

after (in pseudocode):

A
if c then
  D
  E
else
  B
  if not d then
    C
    D
    E
F

Now I have a trouble with the flowchart I have attached.

Here is a pseudocode that I figured out, and I know it is wrong:

A
while c
  B
  if not d
    E
  else
    need to break out of wile loop somehow to get to 'F'
F

Please let me know if the first problem is right, and if you could help me with how to tame the flowchart to get rid of the arrow from d to F...

Thanks in advance,

Waldis
Attached Images
File Type: jpg Homework-002---Problem-4.jpg (4.4 KB, 12 views)
Reply With Quote Quick reply to this message  
Join Date: Jan 2006
Posts: 275
Reputation: f1 fan is an unknown quantity at this point 
Solved Threads: 11
f1 fan f1 fan is offline Offline
Posting Whiz in Training

Re: Trouble with figuring out the flowchart to pseudocode problem

 
0
  #2
Jan 15th, 2006
First 2 are correct. last pseudocode is wrong.
I think it needs to be something like

A
if not c then b
while not d
{
   if not c then c
   D
   E
}
F
Reply With Quote Quick reply to this message  
Join Date: Jan 2006
Posts: 275
Reputation: f1 fan is an unknown quantity at this point 
Solved Threads: 11
f1 fan f1 fan is offline Offline
Posting Whiz in Training

Re: Trouble with figuring out the flowchart to pseudocode problem

 
0
  #3
Jan 15th, 2006
sorry should not be a while loop just another if statement
A
if not c then b
if not d
{
   if not c then c
   D
   E
}
F
Reply With Quote Quick reply to this message  
Join Date: Jan 2006
Posts: 24
Reputation: waldis is an unknown quantity at this point 
Solved Threads: 0
waldis's Avatar
waldis waldis is offline Offline
Newbie Poster

Re: Trouble with figuring out the flowchart to pseudocode problem

 
0
  #4
Jan 15th, 2006
Thanks for your input.

Now I got completely confused... from c down ir TRUE, and from d down is FALSE.

By saying c after 'if not c then' do you mean setting c to TRUE? And by D you mean d, and setting it's value to TRUE?

You made my brain boil, but I didn't get anywhere...

Thanks for your help,

Waldis
Reply With Quote Quick reply to this message  
Join Date: Jan 2006
Posts: 275
Reputation: f1 fan is an unknown quantity at this point 
Solved Threads: 11
f1 fan f1 fan is offline Offline
Posting Whiz in Training

Re: Trouble with figuring out the flowchart to pseudocode problem

 
0
  #5
Jan 15th, 2006
I think we both got confused. I wasnt too sure what A B C etc meant. Are they states in a state machine? Or just processes? also do they run though the flow once or keep repeating? I thought they might be function calls or something . So the if not c then c meant if your c flag hasnt been set then do c.
Reply With Quote Quick reply to this message  
Join Date: Jan 2006
Posts: 275
Reputation: f1 fan is an unknown quantity at this point 
Solved Threads: 11
f1 fan f1 fan is offline Offline
Posting Whiz in Training

Re: Trouble with figuring out the flowchart to pseudocode problem

 
0
  #6
Jan 16th, 2006
I think i am with you now. i was confused between c and C and d and D. i take it A B C D E and F are some processes/functions etc. and c and d are flags?

In which case my pseudocode needs a minor modification i think
A
if not c then B
if not d
{
   if not c then C
   D
   E
}
F
Reply With Quote Quick reply to this message  
Join Date: Jan 2006
Posts: 24
Reputation: waldis is an unknown quantity at this point 
Solved Threads: 0
waldis's Avatar
waldis waldis is offline Offline
Newbie Poster

Re: Trouble with figuring out the flowchart to pseudocode problem

 
0
  #7
Jan 16th, 2006
There is no 'C' or 'D', only 'c' and 'd', which are flags. A, B, E, and F are processes. When 'A' gets down to 'c' and flags it TRUE, it goes to 'B', if FALSE goes to 'F'. If we get to 'B' the next stop is a flag 'd', and if 'd' is TRUE it exits to 'F', if 'd' is FALSE it goes to 'E' and from 'E' goes back to the flag 'c' for another round if 'c' gets flagged TRUE.
The instructions was to modify the flowchart so the pseudocode could be written without GOTOs. And as I see the problem here is either the flag 'c' on the FALSE side or the flag 'd' on the TRUE side.

I hope I'm making sense here... and thanks for bearing with me.
Reply With Quote Quick reply to this message  
Join Date: Jan 2006
Posts: 275
Reputation: f1 fan is an unknown quantity at this point 
Solved Threads: 11
f1 fan f1 fan is offline Offline
Posting Whiz in Training

Re: Trouble with figuring out the flowchart to pseudocode problem

 
0
  #8
Jan 16th, 2006
Ok now i am totally lost. Your initial post had c and C and d and D but now you say there is no C or D? Your initial post also said if c is true to skip B but now you are saying if c is true to do B? Lets start again. I am with you that A B E F are processes and c & d are flags. Where do they get set? does the whole thing repeat?
Reply With Quote Quick reply to this message  
Join Date: Jan 2006
Posts: 24
Reputation: waldis is an unknown quantity at this point 
Solved Threads: 0
waldis's Avatar
waldis waldis is offline Offline
Newbie Poster

Re: Trouble with figuring out the flowchart to pseudocode problem

 
0
  #9
Jan 16th, 2006
There were two problems at the beginning. The first problem was the code with GOTOs and the solution that I wrote was the second code I included. Then I have the second problem, for which I attached the scanned image of the flowchart I'm having problem with. What I'm talking about (with no C and D, only c and d) is this second problem from the flowchart.

And you said that the first problem, as I understood, is correct.
Reply With Quote Quick reply to this message  
Join Date: Jan 2006
Posts: 24
Reputation: waldis is an unknown quantity at this point 
Solved Threads: 0
waldis's Avatar
waldis waldis is offline Offline
Newbie Poster

Re: Trouble with figuring out the flowchart to pseudocode problem

 
0
  #10
Jan 16th, 2006
Ok, here is my solution for it:

A
i=TRUE
while c AND i
  if d then
    i=FALSE
  else
    E
F

All I had to do was add an additional flag where 'c' is, and if 'd' becomes FALSE, just skip 'E' and join the arrow going back to 'c', instead of going straight to 'F'.

I hope I'm making sense...

Waldis
Reply With Quote Quick reply to this message  
Reply

This thread has been marked solved.
Perhaps start a new thread instead?
Message:


Thread Tools Search this Thread



About Us | Contact Us | Advertise | DaniWeb | Acceptable Use Policy | RSS Feed

©2003 - 2009 DaniWeb® LLC