0% found this document useful (0 votes)
26 views9 pages

Topic 4.2.6 - Construct Pseudocode To Represent An Algorithm

The document outlines an algorithm that prompts users to input five integer values, which are then stored in an array. It checks whether the values are sorted in ascending or descending order and displays the appropriate message. The pseudocode provided illustrates the logic for determining the order of the array elements based on user input.
Copyright
© © All Rights Reserved
We take content rights seriously. If you suspect this is your content, claim it here.
Available Formats
Download as PPTX, PDF, TXT or read online on Scribd
0% found this document useful (0 votes)
26 views9 pages

Topic 4.2.6 - Construct Pseudocode To Represent An Algorithm

The document outlines an algorithm that prompts users to input five integer values, which are then stored in an array. It checks whether the values are sorted in ascending or descending order and displays the appropriate message. The pseudocode provided illustrates the logic for determining the order of the array elements based on user input.
Copyright
© © All Rights Reserved
We take content rights seriously. If you suspect this is your content, claim it here.
Available Formats
Download as PPTX, PDF, TXT or read online on Scribd
You are on page 1/ 9

Topic 4

Computational thinking, problem-


solving and programming

IB Computer Science
Topic 4.2

Connecting computational
thinking and program design
IB Computer Science
Topic 4.2: 4.2.1 - 4.2.9

Connecting computational
thinking and program design
IB Computer Science
Topic 4: 4.2.6

Construct pseudocode to
represent an algorithm.
Topic 4: 4.2.6
The following algorithm asks the user to enter five
integer values. Then, the values are stored in an array
and it is determined if the values entered are in
ascending or descending order. The program displays
a message indicating whether and how the elements
are ordered.
Topic 4: 4.2.6
I=0 output "The array is:"
SORTEDA = 1 loop I from 0 to 4
SORTEDD = 1 output SAMPLE[I]
SAMPLE = new Array() end loop
loop I from 0 to 4 if SORTEDA = 1 then
SAMPLE[I] = input("Enter the measurement“) output "The array is sorted in ASCENDING order“
end loop else
loop I from 0 to 3 output "The array is not sorted in ASCENDING order"
if SAMPLE[I] > SAMPLE[I+1] then end if
SORTEDA = 0 if SORTEDD = 1 then
end if output "The array is sorted in DESCENDING order"
if SAMPLE[I] < SAMPLE[I+1] then else
SORTEDD = 0 output "The array is not sorted in DESCENDING order"
end if end if
end loop
Topic 4: 4.2.6
User enters: 3, 5, 6, 4, 4.
Output 1:
The array is:
3
5
6
4
4
The array is not sorted in ASCENDING order
The array is not sorted in DESCENDING order
Topic 4: 4.2.6
User enters: 6, 5, 3, 2, 1.
Output 2:
The array is:
6
5
3
2
1
The array is not sorted in ASCENDING order
The array is sorted in DESCENDING order
Topic 4: 4.2.6
User enters: 2, 4, 78, 89, 99.
Output 3:
The array is:
2
4
78
89
99
The array is sorted in ASCENDING order
The array is not sorted in DESCENDING order

You might also like