(INDIRA) Call Girl Pune Call Now 8250077686 Pune Escorts 24x7
2.1_Workbook.pptx
1. GCSE J277 Unit 2.1 | Algorithms Craig’n’Dave
Name:
Specification & learning objectives
By the end of this topic you will have studied:
• Principles of computational thinking: Abstraction, Decomposition, Algorithmic thinking
• Identify the inputs, processes, and outputs for a problem
• Structure diagrams
• Create, interpret, correct, and refine algorithms using: Pseudocode, Flowcharts, Reference language/high-level programming language
• Identify common errors
• Trace tables
• Standard searching algorithms: Binary search, Linear search
• Standard sorting algorithms: Bubble sort, Merge sort, Insertion sort
Resources
We recommend the OCR endorsed text book from PG Online for use during your GCSE studies.
Craig'n'Dave videos for SLR 2.1
2. GCSE J277 Unit 2.1 | Algorithms Craig’n’Dave
Abstraction
Abstraction means: GCSE J277 Unit 2.1 | Including the necessary details and leaving out the unnecessary details when solving problem
Example of an abstraction:
Real aeroplane: Paper aeroplane:
quick to construct
Wings size
shape
Necessary features of a paper aeroplane:
Windows
Seats
pilot
Unnecessary features of a paper aeroplane:
3. GCSE J277 Unit 2.1 | Algorithms Craig’n’Dave
Abstraction
Dog: Dog icon:
Nose shape
Necessary features of the icon:
Fur
Legs
Colour
bodu
Unnecessary features of the icon:
Rabbit: Rabbit icon:
Ears shape
Face shape
Necessary features of the icon:
Fur
Body
Colour
legs
Unnecessary features of the icon:
Cat: Cat icon:
Ears
Eye shape
whisker
Necessary features of the icon:
Colour of eyes
Body
Fur?
colour
Unnecessary features of the icon:
4. GCSE J277 Unit 2.1 | Algorithms Craig’n’Dave
Abstraction
City Latitude (N)
Dublin 53.3498
London 51.5074
Oslo 59.9139
Paris 48.8566
Madrid 40.4168
A computer program that outputs whether a capital city in Europe is north or south of another capital city in Europe only needs to know the latitude of the two
cities. The other detail is unnecessary. This is an example of abstraction: including the necessary detail and not including the unnecessary detail.
Program:
City=input(“enter a city”)
Latitude=float(input(“enter latitude”)
if latitude<51.5074
print(“The city is South of London”)
else:
print(“The city is north of London”)
endif
5. GCSE J277 Unit 2.1 | Algorithms Craig’n’Dave
Decomposition
Decomposition means: Breaking problems down into smaller sub programs to make them easier to solve/
Examples of problem decomposition in every-day life:
1.Place toast in toaster
2.Select temperature
3.Push down toaster lever to begin toasting
4.After toast pops up,remove from toaster and put
on plate
5.Spread butter on toast
1.Preheat the oven to 180C/350F/Gas 4 and line 2 x
12-hole fairy cake tins with paper cases.
2.Cream the butter and sugar together in a bowl
until pale. Beat in the eggs, a little at a time, and stir
in the vanilla extract.
3.Fold in the flour using a large metal spoon. Add a
little milk until the mixture is a soft dropping
consistency and spoon the mixture into the paper
cases until they are half full.
4.Bake in the oven for 8-10 minutes, or until golden-
brown on top and a skewer inserted into one of the
cakes comes out clean. Set aside to cool for 10
minutes, then remove from the tin and cool on a
wire rack.
5.For the icing, sift the icing sugar into a large
mixing bowl and stir in enough water to create a
smooth mixture. Stir in the food colouring.
6.To ice the fairy cakes, drizzle the icing over the
cakes, sprinkle with decorations and set aside until
the icing hardens.
Making toast: Making a fairy cake:
[Picture of toast
here]
[Picture of fairy
cake here]
6. GCSE J277 Unit 2.1 | Algorithms Craig’n’Dave
Decomposition and structure diagrams
Advantages of decomposition include:
1.Different people can work on different parts of the problem,reducing development time
2.Parts of the program can be reused in other programs
3.It is easier to understand .
Example of problem decomposition in making costume jewellery: Calculate how many beads is needed by calculating length of chain and each
bead.
2.Multiply the number of red beads by the cost of the red beads
3.Multiply the number of purple beads by the cost of purple beads.
4.Add cost of both beads and the chain
Red beads
Purple beads
Chain
7. GCSE J277 Unit 2.1 | Algorithms Craig’n’Dave
Decomposition and structure diagrams
Wages program
Calculate
Deductions
Calculate Tax
Calculate
National
Insurance
Calculate Wage
Calculate basic
wage
Calculate
overtime
Print wage slip
The advantages of using structure diagrams when designing a solution are:
Programs are easier to write-the answer can be developed quicker.
Easier to test
More than one programmer can work on different parts
8. GCSE J277 Unit 2.1 | Algorithms Craig’n’Dave
Decomposition and structure diagrams
Structure diagram for a “Manage pupils details” program:
9. GCSE J277 Unit 2.1 | Algorithms Craig’n’Dave
Identify the input, processes and outputs for a problem
An input is: Data which enters the computer
A process is: Data which runs or where something is calculated
An output is: Data which leaves the computer.
Title of program What does it do? Inputs Processes Outputs
Swimming pool volume Calculates the total volume
of a swimming pool
width : real
length : real
depth : real
Volume = width * length *
depth
volume : real
10. GCSE J277 Unit 2.1 | Algorithms Craig’n’Dave
Algorithmic thinking
Decomposition of pick up sticks:
1.Set the number of sticks to 27
2.Set player number to 1
3.While sticks>1
1.Output whose turn it is
2.Output number of sticks left
3.Set the number of sticks chosen to 0
4.while the player has not chosen 1,2 or 3 sticks
5.Put the number of sticks to pick up
6.Subtract the number of sticks picked up from the pile
7.If the number of sticks is less than 1 player loses otherwise change
player number
8.Output who won the game
Program:
Sticks = 27
Player = 1
While sticks > 0
Print()
Print("Player", player, "it's your turn. ")
Print ("There are", sticks, "sticks")
Chosen = 0
While chosen <1 or chosen >3:
chosen int(input(Enter the number of sticks to pick up:"))
Sticks = sticks - chosen
If player == 1:
player = 2
Else:
player = 1
Print("Player",player, "wins")
11. GCSE J277 Unit 2.1 | Algorithms Craig’n’Dave
Algorithmic thinking
Decomposition of noughts and crosses:
1.Draw the board
1.Two horizontal lines
2.Two vertical lines
2. While no player has won and it is not a draw:
While player has not chosen a square or an invalid square has been chosen
input the square for the player move
3. Draw the player move on the board
If nine moves have not been made calculate the next player's move
A) if the player can win on their next move, choose the square to block them
B) Elseif the middle square is free, choose the middle square
C) ElseIf a corner square is free,
choose the corner square
D) Elseif choose any free square
4. Draw Player 2 choice on the board
5. Check if a player has won
A) Check the horizontal line
B) Check the vertical line
C)Check the diagonal line
6. Check if Player 2 has won
A) Check the horizontal line
B) Check the vertical line
C)Check the diagonal line
7. If there is a winner, output who
8. Check if it is a draw
12. GCSE J277 Unit 2.1 | Algorithms Craig’n’Dave
Linear search
Explanation of a linear search: Starting at the beginning of a list,each item is checked in turn to see if it is the one being searvhed for
Steps to find the Geography
book on the shelf using a
linear search:
1.Check if Archaeology is Geography -
no.
2.Check if Art is Geography - no.
3.Check if Biology is Geography – no
4.Check if chemistry is geography-no
5.Check if Computing is Geography - no.
:6.Check if English is Geography - no.
7.Check if French is Geography - no.
8.Check if Geography is Geography -
Yes.
9.Book found
Pseudocode of the linear
search algorithm:
book = ["Archaeology", "Art", "Biology", "Chemistry", "Computing", "English", "French",
"Geography", "History", "Maths", "Psychology"]
Found = False
Number = 0
Find = "Geography"
While Found == False AND number < LEN(Book):
IF book{number]==find:
found = True
number = number +1
IF found == True:
Print "True"
ELSE:
Print "False"
END
13. GCSE J277 Unit 2.1 | Algorithms Craig’n’Dave
Binary search
Explanation of a binary search:
Calculate the midpoint. Check if it is the item to find. If, not, if it is
lower than the midpoint, repeat on the lef half of the list, or repeat
on the right half of the list.
Steps to find the Geography
book on the shelf using a
binary search:
1.Calculate the midpoint::
1.11 books divided by 2 =5.5.
2.Round down to 5
2.Check if the fifh book is the item:
Geography. 5=Computing.
3.Not found. Geography is > Computing
A to Z , so find the mid point of the right
hand list 6/2=3
4.Check the 8
book (5+3)
5. Geography
6.Book found
Special condition for a binary search to work: The data set must be in order
In most cases, the quicker search is performed by the: Binary search algorithm. However, this is not true if the first item in the list is the one you want to find.
If the item you want to find is first in the list then the Linear search algorithm would be quicker.
14. GCSE J277 Unit 2.1 | Algorithms Craig’n’Dave
Pseudocode of the binary
search algorithm:
book = ["Archaeology", "Art", "Biology", "Chemistry", "Computing",
"English", "French", "Geography", "History", "Maths", "Psychology"]
found = False
left = 0
right = LEN(book)-1
find = "Geography"
WHILE found == false and left <=right:
mid = (left + right) //2
IF book(mid)==find:
found = True
ELSE:
IF find>book(mid):
left = mid +1
ELSE:
right = mid -1
IF found ==True:
print("True")
ELSE
print("False")
Binary search
15. GCSE J277 Unit 2.1 | Algorithms Craig’n’Dave
How a bubble sort works:
Bubble sort
Note how 32 has “bubbled” to the top.
This is how the bubble sort got its name.
The algorithm has been optimised so it does not check the
numbers already bubbled to the top. It can also stop if no
swaps are made after all the numbers are checked.
32
2
16
8
24
2
32
16
8
24
Check 2
and 32.
Swap
Check 32
and 16.
Swap.
2
16
32
8
24
Check 32
and 8.
Swap.
2
16
8
32
24
Check 32
and 24.
Swap.
2
16
8
24
32
Check 2
and 16.
No swap.
2
16
8
24
32
Check 16
and 8.
Swap.
2
8
16
24
32
Check 16
and 24.
No swap.
2
8
16
24
32
Check 2
and 8.
No swap.
2
8
16
24
32
Check 8
and 16.
No swap.
2
8
16
24
32
Check 2
and 8.
No swap.
16. GCSE J277 Unit 2.1 | Algorithms Craig’n’Dave
Merge sort
How a merge sort works:
38
27
43
3
9
82
38
27
43
3
9
82
27
38
3
43
9
82
3
27
38
43
9
82
3
9
27
38
43
82
Original list. Merge adjacent
lists together.
Until all lists are
merged.
17. GCSE J277 Unit 2.1 | Algorithms Craig’n’Dave
bubble sort
How a merge sort works:
2
32
16
8
24
Split into
adjacent sub-
lists of up to two
numbers.
2
32
8
16
24
Swap numbers
if necessary in
each sub list.
8 and 16 swap.
2
8
16
32
24
Merge adjacent lists together
by comparing the first number
in each list, moving the
smaller number into a new
list, one number at a time.
Merge adjacent lists together
by comparing the first number
in each list, moving the
smaller number into a new
list, one number at a time.
2
8
16
24
32
Original
list.
2
32
16
8
24
18. GCSE J277 Unit 2.1 | Algorithms Craig’n’Dave
Insertion sort
How an insertion sort works:
32
2
16
8
24
32
2
16
8
24
16
8
24
32
2
8
24
16
32
2
24
8
16
32
2
32
8
16
24
Yellow dotted box:
unsorted data in the list:
Green solid box:
sorted data in the list:
? inserted
in place.
? inserted
in place.
? inserted
in place.
? inserted
in place.
? inserted
in place.
19. GCSE J277 Unit 2.1 | Algorithms Craig’n’Dave
Flow diagram symbols
Terminal
Process
Decision
Input/Output
Sub Routine
Line
Start or stop
Data that enteres or leaves the
program
Data whichj has been worked out
or calculated.
if statementtor Flow of data
A process symbol where it
performs a specific task.
20. GCSE J277 Unit 2.1 | Algorithms Craig’n’Dave
How to produce algorithms using flow diagrams
An algorithm for an RPG game
displays 3 choices from a menu and
allows the user to enter their choice.
1. Play game
2. Change character
3. Quit
The user input is validated so only
the numbers 1-3 can be entered.
21. GCSE J277 Unit 2.1 | Algorithms Craig’n’Dave
Interpret, correct, refine or complete algorithms.
An algorithm for an RPG game
displays 3 choices from a menu and
allows the user to enter their choice.
1. Play game
2. Change character
3. Quit
The user input is validated so only
the numbers 1-3 can be entered.
do
print("1. Play game")
print("2. Change character")
print("3. Quit")
input(int(choice))
until choice<1 OR choice>3
22. GCSE J277 Unit 2.1 | Algorithms Craig’n’Dave
How to produce algorithms using pseudocode (OCR reference language)
An algorithm for an RPG game
handles a battle between two player
characters.
Each character has an attack and
defence attribute that must be input
by the user before an engagement.
When the two characters engage, a
random number between 1 and 12 is
generated for each player.
The attack attribute plus the defence
attribute is added to the player's dice
roll.
If player 1’s total is greater than
player 2’s total, player 1 wins
otherwise player 2 wins.
The winner is output.
input int(p1attack)
input int(p1defence)
input int(p2attack)
input int(p2defence)
dice = random(1,12)
total1 = dice + p1attack + p1defence
dice = random(1,12)
total2 = dice + p2attack + p2defence.
if total1 > total2 then
print("Player 1 wins")
print("Player 2 wins")
End if
23. GCSE J277 Unit 2.1 | Algorithms Craig’n’Dave
Interpret, correct, refine or complete algorithms.
An algorithm for an RPG game
generates a list of random caverns
into which objects will be placed.
Caverns are numbered 1-50.
The number of caverns to return is n.
function randomcaverns(n)
caverns = []
for c = 1 to n
valid = FALSE
while valid = FALSE
r = random(1,50)
valid = TRUE
for i = 0 to caverns.LENGTH
if caverns[i] = r then valid = FALSE endif
next i
endwhile
caverns[c] = r
next c
return caverns
endfunction
24. GCSE J277 Unit 2.1 | Algorithms Craig’n’Dave
How to produce algorithms using flow diagrams
An RPG game allows a player to input
their next move by entering N, E, S
or W. The valid moves are stored in
a list like this: move = [0,1,0,1]
Zero means the move is not possible.
One means it is possible. The
possibilities are stored in the list in
the order: N, E, S, W.
A function takes two parameters:
m is the move: “N”, “E”, “S” or “W”;
vm is a list of the valid moves.
Assuming a zero indexed list/array.
25. GCSE J277 Unit 2.1 | Algorithms Craig’n’Dave
Identifying common errors and suggesting fixes
The error in this is on line: 13
01: input (int(p1attack))
02: input (int(p1defence))
03: input (int(p2attack))
04: input (int(p2defence))
05:
06: dice = random(1,12)
07: total1 = dice + p1attack + p1defence
08:
09: dice = random(1,12)
10: total2 = dice + p2attack + p2defence
11:
12: if total1 > total2 then
13: print(Player 1 wins)
14: else
15: print("Player 2 wins")
16: endif
syntax
Print(“Player 1 wins”)
The type of error is:
In order to fix this error:
26. GCSE J277 Unit 2.1 | Algorithms Craig’n’Dave
Identifying common errors and suggesting fixes
The error in this is on line: Line 12
01: input (int(p1attack))
02: input (int(p1defence))
03: input (int(p2attack))
04: input (int(p2defence))
05:
06: dice = random(1,12)
07: total1 = dice + p1attack + p1defence
08:
09: dice = random(1,12)
10: total2 = dice + p2attack + p2defence
11:
12: if total1 < total2 then
13: print("Player 1 wins")
14: else
15: print("Player 2 wins")
16: endif
Logic error
The type of error is:
In order to fix this error:
If total1>total2 then
27. GCSE J277 Unit 2.1 | Algorithms Craig’n’Dave
Identifying common errors and suggesting fixes
The error in this is on line: 09,06
01: input (int(p1attack))
02: input (int(p1defence))
03: input (int(p2attack))
04: input (int(p2defence))
05:
06: dice = random(1 12)
07: total1 = dice + p1attack + p1defence
08:
09: dice = random(1 12)
10: total2 = dice + p2attack + p2defence
11:
12: if total1 > total2 then
13: print("Player 1 wins")
14: else
15: print("Player 2 wins")
16: endif
syntax
The type of error is:
In order to fix this error:
Dice=random(1,12)
28. GCSE J277 Unit 2.1 | Algorithms Craig’n’Dave
Trace tables
Assuming that the when this program is run the user enters the values…
• x = 2 in line one
• y = 7 in line two
…complete trace table for this program is as follows:
01: x = int(input("Enter a number: "))
02: y = int(input("Enter another number: "))
03:
04: total = x
05:
06: for counter = 1 to y
07: total = total * x
08: print(total)
09: next counter
X=2 Y=7 total counter
0 1
2 2
6 3
8 4
10 5
12 6
true 14 7
14
29. GCSE J277 Unit 2.1 | Algorithms Craig’n’Dave
Assessment Target: Overall grade:
Minimum expectations by the end of this unit
You should have learnt terms 134-151 from your GCSE Level Key Terminology during this unit.
You have completed all the pages of the workbook
Score 80% in the end of unit test.
Feedback
Breadth Depth Understanding
All aspects complete Excellent level of depth All work is accurate
Most aspects complete Good level of depth Most work is accurate
Some aspects complete Basic level of depth shown Some work is accurate
Little work complete Little depth and detail provided Little work is accurate
Comment & action Student response
30. GCSE J277 Unit 2.1 | Algorithms Craig’n’Dave
Reflection & Revision checklist
Confidence Clarification
I can explain what is meant by the term abstraction.
I can explain why abstraction is helpful when we are designing a solution to a problem.
I can explain what decomposition is and how it is useful.
I can explain what is meant be ‘algorithmic thinking’.
I can identify inputs, processes and outputs for a problem.
I can use structure diagrams to help design a solution to a problem.
I can identify common errors.
I can explain what trace tables are and how to use them.
I can explain how a binary search works.
I can explain how a linear search works.
I can explain how a bubble sort works.
I can explain how a merge sort works.
I can explain how an insertion sort works.
I can explain how to produce pseudocode to describe an algorithm and why it is needed.
I can explain how to produce a flow diagram to describe an algorithm.
I can interpret, correct, refine and complete a range of algorithms using algorithms, flowcharts and the OCR reference language.
My revision focus will need to be:
Editor's Notes
Activity…
Explain what abstraction means in the context of computational thinking.
Source a picture of a real civilian aeroplane and a paper aeroplane.
Using the following source, identify the necessary and unnecessary features of a paper aeroplane: https://www.paperplane.org/copy-of-books
Make a paper aeroplane and test it against a partner. Whose plane can fly the furthest? What was the most essential detail?
A veterinary surgery wants to expand its website so pet owners can download care sheets for animals. The user interface will have icons that can be clicked to select the animal.
Source a picture of a cat, dog and rabbit.
Draw an icon for each animal using a graphics application.
Explain the necessary features of the icon so it is identifiable.
Explain the unnecessary features of the icon when compared to the picture of the real animal.
Write a program in the OCR reference language that asks the user to enter the name of a city in Europe and its latitude. It should output whether the city is north or south of London.
Describe the steps to making toast.
Research and describe the steps to making fairy cakes.
State 3 advantages of applying decomposition to programming solutions to problems.
Show how problem decomposition could be applied to calculating the cost of making a necklace from red and purple beads.
SUPER CHALLENGE: Return to your program that outputs whether a city in Europe is north or south of London. Can you apply the skills of problem decomposition and abstraction to extend the program to handle a city anywhere in the world, including those south of the equator?Could it be further extended to handle east and west?
Complete the top box and outline the characteristics of using a structured programming approach.
Complete the second box and outline the advantages of adopting a structured programming approach.
A school wants a program to manage its pupils details.
In one part of the program the school will keep a record of all pupils in the school, when they joined, when they applied, and the removal of the pupil when they leave the school.
In another part of the program the school wants to keeps a record of each pupils attendance on a daily basis.
In a third part, the school wants to be able to keep track of the funds it received from the LEA for each pupil and where the money is being spent.
Using Smart Art (Insert tab -> SmartArt -> Hierarchy) produce a structure diagram to show a top-down design of the computer program
Complete the definition of problem inputs, processes and outputs in the top three boxes.
Choose three different programs you have written during this course and using the table provided identify the inputs, processes and outputs for the programs you have chosen. The first row shows an example already completed.
In “pick up sticks”, two players take turns to pick up 1, 2 or 3 matchsticks from a pile of 27 matchsticks. The player who picks up the last matchstick loses.
Apply decomposition to break the problem down showing the steps needed to program the game.
Apply algorithmic thinking to write the program for two human players.
Replace the second human player with a computer that picks a random number 1-3 to pick up sticks.
SUPER CHALLENGE: Research the problem and create an algorithm that allows the computer to play a winning strategy: http://blogs.britannica.com/2007/05/math-and-winning-strategies/
Google noughts and crosses. There should be a game you can play against the computer in the Google search results: built into the Google engine! Play a couple of games.This is a great example of abstraction because how the board looks doesn’t matter to the computer, just how the board is stored in memory!
If you were going to write a noughts and crosses program, write the steps needed to program the game against a computer.
SUPER CHALLENGE: Create the program using a programming language. You will need to think about how you can store the board in memory.
Explain what a linear search is.
Using the illustration of the bookshelf, identify the steps to find the book, “Geography”.
Write the pseudocode to output True if a book is in the list, or False if it is not.
Write the program to check your pseudocode.
Using the data for the latitude and longitude of capital cities in Europe, write a program that asks the user for the name of a city. The program outputs the latitude and longitude of the city using a linear search.
SUPER CHALLENGE: Make sure you have adequate validation. Can you extend the program to allow the user to add and remove a capital city with a menu to present the different options?
Explain what a binary search is.
Using the illustration of the bookshelf, identify the steps to find the book, “Geography”.
State the characteristic of the list for a binary search to work.
State which algorithm is quicker: linear or binary search.
Complete the pseudocode to output True if a book is in the list, or False if it is not. Here is some handy code to help you with the complicated bits:The right pointer starts at: len(book)-1The middle of the list is calculated by: (left+right)//2 (// means round down the division, also known as integer division)
SUPER CHALLENGE: Create the program using a programming language.
Show the sequence of steps of a bubble sort algorithm.Highlight the numbers being checked and swapped.The highest number should be at the top, the lowest number should be at the bottom. Start by comparing the numbers at the bottom: 32 and 2.
SUPER CHALLENGE: Given a list of numbers: list = [32, 2, 16, 8, 24] write a program to perform a bubble sort.
Show the sequence of steps of a merge sort algorithm.Highlighted numbers indicate a comparison and swap if necessary.
Show the sequence of steps of a bubble sort algorithm.Highlight the numbers being checked and swapped.
Show the sequence of steps of an insertion sort algorithm.Highlight the numbers being checked and added to the sorted list at each stage.
Label each flowchart symbol in the middle of the symbol.
State what the symbol is used to represent in the blue box.
Create the flowchart for the algorithm described.
The pseudocode for the problem would not run as expected. Correct the errors in the pseudocode. (The code has been written in the OCR reference language)
Create the program using a programming language.
The program could be improved by preventing accepting character and symbol inputs and then rejecting them. One way to achieve this is to accept the input as a string, convert into ASCII and check that the number is in range. Modify the program to achieve this.
Create the pseudocode for the algorithm described using the OCR reference language.
Create the program using a programming language.
The algorithm does not run as expected in two ways:- It always returns caverns 1, 2 and 3 when asked for 3 caverns.- It sometimes returns duplicate caverns.- Identify and correct the errors in the pseudocode.
SUPER CHALLENGE: Create a “dungeon master” toolkit program. It should allow the user to roll an x sided dice y times.It could also include the program on this slide to produce a set of unique caverns.It could also keep track of a player’s name, character type, health, attack and defence capabilities.This is an open-ended task.
Create the flowchart for the algorithm described.
Study the code presented in the top box which contains an error, it has been written using the OCR reference language which you will see in the exams.
State what line the error is on.
State what type of error it is, either syntax error or logic error.
State how you would correct the code.
Study the code presented in the top box which contains an error, it has been written using the OCR reference language which you will see in the exams.
State what line the error is on.
State what type of error it is, either syntax error or logic error.
State how you would correct the code.
Study the code presented in the top box which contains an error, it has been written using the OCR reference language which you will see in the exams.
State what line the error is on.
State what type of error it is, either syntax error or logic error.
State how you would correct the code.
Complete the trace table based on the assumptions shown on the screen. Only add a new entry under a column if the value of that variables changes while tracing the program.