Comp Sci How does Instruction 2 affect the updates in a flow chart for coding?

  • Thread starter Thread starter member 428835
  • Start date Start date
  • Tags Tags
    Charts Code Flow
Click For Summary
SUMMARY

This discussion focuses on the interpretation of Instruction 2 in a coding flow chart exercise, specifically how it modifies Instruction 1. The participant clarifies that Instruction 2 does not replace but modifies Instruction 1, leading to a continuous increment of Box 2 by 2 during each loop iteration. The key takeaway is that the last box number referenced in Instruction 1 is crucial for understanding the flow of operations, resulting in Box 2 increasing from 0 to 2, then to 4, and so on. The exercise emphasizes the importance of tracking the operations and results of each instruction accurately.

PREREQUISITES
  • Understanding of flow chart logic and instruction sequencing
  • Familiarity with basic programming concepts such as loops and variable modification
  • Knowledge of how to interpret and modify pseudocode instructions
  • Experience with problem-solving in coding exercises or interviews
NEXT STEPS
  • Research flow chart design principles and best practices
  • Study loop structures and their impact on variable states in programming
  • Explore common coding interview questions related to instruction modification
  • Practice tracking variable changes through coding exercises
USEFUL FOR

Individuals preparing for coding interviews, educators teaching programming concepts, and software developers looking to enhance their understanding of flow control in algorithms.

member 428835
Homework Statement
See the attached screenshot.
Relevant Equations
nothing comes to mind
I found this as problem 3/42 from here (copied below for viewing convenience). I'm a little confused about Instruction 2. The way I interpret it, upon the first loop, no evaluation is occurring, but instruction 1 now becomes "increase Box 2 by 2". So now the three instructions are
1) increase the last value mentioned in box 2 by 2
2) change instruction 1: Increase the last box number mentioned in it by 2.
3) Is the last box number mentioned in Instruction 1 equal to (number in box 3)?

But this makes me think box 2 will becomes 2 -> 4 ->6... since it is the ONLY, and therefor last, box mentioned. What am I missing?
flow_chart.png
 
Physics news on Phys.org
joshmccraney said:
The way I interpret it, upon the first loop, no evaluation is occurring, but instruction 1 now becomes "increase Box 2 by 2".
I think that the exercise seeks to have you carefully track the operation and result of each instruction.

What number is in box 2 after after instruction 1 is executed?
What is the last number in instruction 1?
Isn't changing that number the only modification that instruction 2 makes to instruction 1?
 
Last edited:
sysprog said:
I think that the exercise seeks to have you carefully track the operation and result of each instruction.

What number is in box 2 after after instruction 1 is executed?
What is the last number in instruction 1?
Isn't changing that number the only modification that instruction 2 makes to instruction 1?
I'll answer your questions as you've asked:
1) 0
2) 2
3) I think not. Doesn't instruction 2 literally change instruction 1, so that we only evaluate the subtraction on the first iteration, and after that we just add 2, since the instruction has changed?
 
3) I think not. Doesn't instruction 2 literally change instruction 1, so that we only evaluate the subtraction on the first iteration, and after that we just add 2, since the instruction has changed?
In this instance "change" doesn't mean 'exchange' or 'replace'; it means modify ##-## instruction 2 says modify instruction 1 so that the last box number in instruction 1 is increased by 2 ##-## the last box number in instruction 1 is the number of the box at which the result of the subtraction is to be stored.
 
Last edited:
  • Like
Likes pbuk
On the first pass through the loop, what is the last box number mentioned in instruction 1? What does instruction 1 say after we increase it by 2?
 
  • Like
Likes sysprog
Oh, note that none of the answers A-D is correct. There are hundreds of these "interview questions" sites, all of them I have seen are useless.
 
pbuk said:
Oh, note that none of the answers A-D is correct.
The question on the site has answers A-E.

1650277490840.png
 
  • Haha
Likes pbuk
sysprog said:
The question on the site has answers A-E.
Oh, sorry for giving the game away!
 
  • Haha
Likes sysprog

Similar threads

  • · Replies 7 ·
Replies
7
Views
2K
  • · Replies 4 ·
Replies
4
Views
2K
  • · Replies 2 ·
Replies
2
Views
4K
  • · Replies 4 ·
Replies
4
Views
3K
  • · Replies 15 ·
Replies
15
Views
2K
Replies
2
Views
8K
Replies
1
Views
4K
  • · Replies 1 ·
Replies
1
Views
1K
  • · Replies 6 ·
Replies
6
Views
2K
  • · Replies 1 ·
Replies
1
Views
2K