Transcription of UNIT 1: PROBLEM SOLVING - Pearson
1 1 ANSWERSUNIT 1: PROBLEM SOLVING1 UNDERSTANDING ALGORITHMSACTIVITY 1 There is no single correct solution to this activity, since every student s walk to school will be unique. It is intended to highlight the need for instructions to be specific, precise and in a logical order. Encourage them to identify instances of repetition and selection, Keep walking until you get to the end of the street. Next cross the road, providing no cars are coming. ACTIVITY 2 Encourage students to use all the symbols shown in Figure in their 3 This flowchart incorporates selection and iteration.
2 Students may simply identify a sequence of processes in their bubble bathTurn down hot tapTurn down cold tapGet in bathNOEnoughwater?Too hot?TemperatureOK?Turn o tapsPut in plugTurn on tapsACTIVITY 4 Students must be familiar with Pearson Edexcel pseudocode, which will be used to frame some of the exam questions on Paper 2, but they don t have to use it themselves. Z06 IGCSE Computer Science SB2 Global 10220 UNIT1 116/05/20 3:39 PM2 ANSWERSACTIVITY 5 SEND Enter first number. TO DISPLAYRECEIVE firstNumb FROM KEYBOARDSEND Enter second number.
3 TO DISPLAYRECEIVE secondNumb FROM KEYBOARDSET thirdNumb TO firstNumb * secondNumbSEND thirdNumb TO DISPLAYACTIVITY 6 Ask the user to enter their until an existing username is ask the user to enter their until the correct password is two slicesof white breadButter two slices ofbrown breadPlace cheese on one sliceof bread (butter side up)Put second slice of breadon top (buttered side down)Spread pickle on topof cheeseCut sandwich in half diagonallyto make trianglesSlice cheesePickle? checkpoint S1 The specifics of this algorithm should reflect the procedure for borrowing books at the student s own local library or school library.
4 S2 Table describes the function of each of the arithmetic operators. S3 and S4 Variables and constants are explained on page 9. C1 Z06 IGCSE Computer Science SB2 Global 10220 UNIT1 216/05/20 3:39 PM3 ANSWERSC2 SEND Enter first number. TO DISPLAYRECEIVE firstNumb FROM KEYBOARDSEND Enter second number. TO DISPLAYRECEIVE secondNumb FROM KEYBOARDSEND Enter third number. TO DISPLAYRECEIVE thirdNumb FROM KEYBOARDSET average TO (firstNumb + secondNumb + thirdNumb)/3 SEND average TO DISPLAY2 CREATING ALGORITHMSACTIVITY 7 Here s the algorithm expressed as a Too high!
5 Your guess must bebetween 1 and 10. StartEndYESNO guess > 10?NOguess =mystNumb?mystNumb = 3 Input guessOutput Bad luck!The correct number is + mystNumbOutput Well done!You guessedcorrectly. YESHere s the same algorithm expressed as mystNumb TO 3 SEND Please enter a number between 1 and 10. TO DISPLAYRECEIVE guess FROM KEYBOARDIF guess > 10 THEN SEND Too high! Your guess must be between 1 and 10. TO DISPLAYZ06 IGCSE Computer Science SB2 Global 10220 UNIT1 316/05/20 3:39 PM4 ANSWERSELSE IF guess = mystNumb THEN SEND Well done!
6 You have guessed correctly. TO DISPLAY ELSE SEND Bad luck! The correct number is & mystNumb TO DISPLAY END IFEND IFACTIVITY 8 SCOREOUTPUT91A56D78 BCHECKPOINT S1 The activities in this chapter provide plenty of examples that students can use to illustrate their Enter your height (in metres). TO DISPLAYRECEIVE height FROM KEYBOARDSEND Enter your weight (in kilograms). TO DISPLAYRECEIVE weight FROM KEYBOARDSEND Your body mass index (BMI) is: & weight/height^2 TO DISPLAY(Reminder: height^2 means height to the power of 2 , height2.)
7 See Arithmetic operators on page 9 of the Student Book.)Z06 IGCSE Computer Science SB2 Global 10220 UNIT1 416/05/20 3:39 PM5 ANSWERS3 SORTING AND SEARCHING ALGORITHMSACTIVITY 9 The variable length is used to store the length of the list. The variable switch is initially set to at the beginning of the list, successive pairs of items are compared and swapped round if the first item is bigger than the second item. When a swap occurs the value of switch changes from 0 to 1. This process is repeated until the end of the list is boiler onYESTime 08:00 23:00?
8 YESS witch boiler o YEST emperature< 22 ?YEST emperature< 20 ?NONONONONONOS witch boiler onYESW eekday?Temperature> 10 ?Boiler on?Switch boiler onTime 06:00 08:30 OR17:30 20:00? C2 Encourage students to devise appropriate test data to check that the algorithm produces the right IGCSE Computer Science SB2 Global 10220 UNIT1 516/05/20 3:39 PM6 ANSWERSIf at the end of a pass through the list the value of switch hasn t changed from 0 to 1, this indicates that no swaps have taken place, meaning that the list is now sorted.
9 The algorithm then 1048 20 9 17 13 21 28 6048 20 9 17 13 21 28 6048 20 9 17 13 21 28 6048 20 9 17 13 21 28 6048 20 17 9 21 13 60 2848 20 17 9 60 28 21 1360 48 28 21 20 17 13 9 ACTIVITY 113 9 13 15 21 24 27 30 36 39 42 54 693 9 13 15 21 243 9 1313 checkpoint S1 The difference between the bubble sort and merge sort algorithms is described on page 19. S2 The way in which a binary search algorithm finds the search item is explained on page 20. C1 The efficiency of a linear search as compared to a binary search is described on page 21, which includes mention of when it might be better to use the former rather than the DECOMPOSITION AND ABSTRACTIONACTIVITY 12 Inputs: when to start a new game number and names of players when to spin the wheel a player s selected answer whether players want to play : A message to inform a player when it is their turn.
10 A message to inform the player of the outcome of spinning the wheel (question category). A question plus four possible answers. A message to inform the player whether their answer is correct or IGCSE Computer Science SB2 Global 10220 UNIT1 616/05/20 3:39 PM7 ANSWERS A message to inform the player that they can have another go. A message to inform the player how many points they have scored. A message at the end of each round to inform each player of their total score. A game over message.