0% found this document useful (0 votes)
135 views2 pages

Trace Table - Bubble Sort 3

This flowchart takes in a whole number as input. It uses the INT function to get the integer part of the number divided by 2 at each step. It counts the number of steps (C) until the input number equals the result of INT(Number/D). It outputs C. For example, it would take 3 steps to reach 1 for an input of 8, outputting 3.

Uploaded by

Judah Bajela
Copyright
© © All Rights Reserved
We take content rights seriously. If you suspect this is your content, claim it here.
Available Formats
Download as PDF, TXT or read online on Scribd
0% found this document useful (0 votes)
135 views2 pages

Trace Table - Bubble Sort 3

This flowchart takes in a whole number as input. It uses the INT function to get the integer part of the number divided by 2 at each step. It counts the number of steps (C) until the input number equals the result of INT(Number/D). It outputs C. For example, it would take 3 steps to reach 1 for an input of 8, outputting 3.

Uploaded by

Judah Bajela
Copyright
© © All Rights Reserved
We take content rights seriously. If you suspect this is your content, claim it here.
Available Formats
Download as PDF, TXT or read online on Scribd
You are on page 1/ 2

1 This flowchart inputs a whole number. The function INT returns the integer value of a number.

For
example, INT (7.5) is 7

An input of -1 ends the routine.

START

INPUT Number

IS Number Yes
END
= –1?
No

C 0
D INT(Number/2)

IS
INT(Number/D) Yes
= Number/D?

No
C C + 1

D D – 1

No IS D =
1?

Yes

Yes IS C =
0?
No

OUTPUT C
(a) Complete the trace table for the given algorithm using this input data:
7, 6, 5, 4, –1, 12, 34

Number C D OUTPUT

[6]

(b) Describe the purpose of this algorithm.

...................................................................................................................................................

...................................................................................................................................................

...................................................................................................................................................

............................................................................................................................................. [2]

(c) (i) Describe the problem that occurs if a whole number smaller than 4 and not equal to –1
is input.

...........................................................................................................................................

...........................................................................................................................................

...........................................................................................................................................

..................................................................................................................................... [2]

(ii) Explain how to change the flowchart to prevent this problem occurring.

...........................................................................................................................................

...........................................................................................................................................

...........................................................................................................................................

..................................................................................................................................... [2]

You might also like