Ex 3) Trace the following flowchart for when input values are −10,1,3,2,−11,−13,−1,1,−3,2,0 and complete the trace table. Also, write pre- post-conditions for this flowchart. Ex 4) Trace the following flowchart for when input values are 12, -2, -3, 6, -11, 3, 1, -1 and complete the trace table. Also, write pre- post-conditions for this flowchart.
F. COMPUTATIONAL THINKIG Part 1: This part must be done in teams of two. (By the permission of the TA, only one team can be in team of three if the lab population is odd.) If you have done it at home, you are required to discuss it with a peer from your lab before you show your final solution to your TA. In Exercises 1 to 5, you verify the correctness of all algorithms by tracing them with some sample inputs. If an algorithm ends without using all inputs, re-run it for the remaining inputs. You also write pre- and post- conditions for each algorithm. In Exercise 6, you devise an algorithm that calls two sub-algorithms. In that Exercise you trace your new sub-algorithms for some sample inputs. Note that terms algorithm, sub-algorithm, function, method, programs are used interchangeably, yet they have subtle differences. For each exercise, take one picture of all your trace tables and pre- post-conditions, including your name. By end of this lab, both you and your teammate should submit these pictures to eClass as img_\{01,02,03,04,05,06\}.jpg files, where img_x is the picture for exercise x below. Make sure the size of each image is less than 500KB, e.g. by reducing the resolution of your camera. IMPORTANT: You are required to provide preconditions and postconditions for each solution you provide. Ex 1) Trace the following flowchart for when input is 15 and complete the trace table. Also, write pre- postconditions for this flowchart. Ex 2) Trace the following flowchart for when input values are 12, 3, 5, -2, 11, 15, 1, 1, and complete the trace table. Also, write pre- post-conditions for this flowchart.
Ex 5) This exercise uses sub-algorithms. Trace it for when input value is 6 and complete the trace tables. Also note that there are two variables name num, one in the main algorithm and another in the sub-algorithm. Write pre- post-conditions for each of these algorithms (the main one and the sub-algorithm). Ex 6) Devise an algorithm to receive a positive number, n, and output all prime numbers that are smaller than n and have a digit 7 . For example, if n is 100 , the program should output 7,17,37,47,67,71,73,79, and 97. Your solution should have a main algorithm and two sub-algorithms, let's call them prime (num) and has7 (num). You may reuse the prime sub-algorithm of Ex 5. You do not need to verify (e.g. by tracing) it though because you did it in Ex 5. You need to trace your has7 algorithm. You should provide pre- and post-conditions for all your 3 (sub)algorithms.