Back to 课程

Computer Science GCES OCR

0% Complete
0/0 Steps
  1. Cpu Architecture Performance And Embedded Systems Ocr
    5 主题
  2. Primary And Secondary Storage Ocr
    6 主题
  3. Data Storage And Compression Ocr
    12 主题
  4. Networks And Topologies Ocr
    6 主题
  5. Wired And Wireless Networks Protocols And Layers Ocr
    6 主题
  6. Identifying And Preventing Threats To Computer Systems And Networks Ocr
    2 主题
  7. Operating Systems And Utility Software Ocr
    2 主题
  8. Ethical Legal Cultural And Environmental Impact Ocr
    2 主题
  9. Computational Thinking Searching And Sorting Algorithms Ocr
    3 主题
  10. Designing Creating And Refining Algorithms Ocr
    5 主题
  11. Programming Fundamentals And Data Types Ocr
    5 主题
  12. Additional Programming Techniques Ocr
    7 主题
  13. Defensive Design And Testing Ocr
    6 主题
  14. Boolean Logic Diagrams Ocr
    2 主题
  15. Programming Languages And Integrated Development Environments Ides Ocr
    3 主题
  16. The Exam Papers Ocr
    2 主题
  17. Structuring Your Responses Ocr
    3 主题
课 Progress
0% Complete

Exam code:J277

Trace Tables

What is a trace table?

  • A trace table is used to test algorithms and programs for logic errors that appear when an algorithm or program executes

  • Trace tables can be used with flowcharts, pseudocode or program code

  • A trace table can be used to:

    • Discover the purpose of an algorithm by showing output data and intermediary steps

    • Record the state of the algorithm at each step or iteration

  • Each stage of the algorithm is executed step by step.

  • Inputs, outputs, variables and processes can be checked for the correct value when the stage is completed

Trace table walkthrough

  • Below is a flowchart to determine the highest number of ten user-entered numbers

  • The algorithm prompts the user to enter the first number which automatically becomes the highest number entered

  • The user is then prompted to enter nine more numbers.

    • If a new number is higher than an older number then it is replaced

  • Once all ten numbers are entered, the algorithm outputs which number was the highest

  • Example test data to be used is: 4, 3, 7, 1, 8, 3, 6, 9, 12, 10

flowchart question

Trace table: Highest number

Count

Highest

Number

Output

1

 

 

Enter ten numbers

 

4

 

Enter your first number

2

 

3

Enter your next number

3

7

7

 

4

 

1

 

5

8

8

 

6

 

3

 

7

 

6

 

8

9

9

 

9

12

12

 

10

 

10

12 is your highest number

Worked Example

01

 X = 5

02

 Y = 3

03

 while X > 0

04

Y = Y + 6

05

X = X - 1

06

 print (Y)

Complete the following trace table for the given algorithm, the first two lines have been filled in for you

Table showing columns "Line number," "X," "Y," and "PRINT". Row 1: 01, 5, blank. Row 2: 02, blank, 3. Remaining cells are empty.

Answer

Table showing columns for Line Number, X, Y, and Print. Values in the Print column include 33 in the last row. X decreases while Y increases in a pattern.

Responses

您的邮箱地址不会被公开。 必填项已用 * 标注