🎧 New: AI-Generated Podcasts Turn your study notes into engaging audio conversations. Learn more

Computational-Thinking-Decomposition.pdf

Loading...
Loading...
Loading...
Loading...
Loading...
Loading...
Loading...

Full Transcript

Computational Thinking Decomposition Divide and One of the traditional ways to solve a problem Conquer Break it into smaller problems Solve each of the smaller problems Combine the solutions to the smaller problems to yield a solution...

Computational Thinking Decomposition Divide and One of the traditional ways to solve a problem Conquer Break it into smaller problems Solve each of the smaller problems Combine the solutions to the smaller problems to yield a solution to the whole problem Example One – Summing several values Analyze the problem We need a place to store the sum The sum needs to be initialized to zero We need to access each of the values We need to add each of the values onto the sum Create and initialize sum Decompose Access each value in turn by the having user enter the values one at a time problem Add each value onto the sum Example Compare the first Two – value to the second Sort two values into ascending If they are out of order order, swap them But, If we copy the second value to the first swapping is not as We overwrite and lose the first value easy as it looks We need to come up with a way of swapping that will preserve the first value We can use a third variable to Swapping store the first value when we overwrite with the second Copy the first value to temp Copy the second value to first Copy temp to the second value Putting it Compare first to second all If they are out of order together Copy first to temp Copy second to first Copy temp to second

Use Quizgecko on...
Browser
Browser