Advanced CompSci Sample Pages Combined REDUCED
Advanced CompSci Sample Pages Combined REDUCED
Feature include:
• Plain English language
• Diagrams and illustrations for all key concepts
• Examination style questions with answers for all topics
• Use of IB style pseudocode, as well as actual working code in the Java
Programming Language
• A complete and efficient working Java solution that addresses a real life scenario
• One-to-one reference to the assessment statements in the IB Computer Science
This book allows both students and teachers to follow the wide-ranging IB Computer
Science syllabus in such a way that they can be confident that all aspects of theory and
practical exercises have been covered.
Further details about the book, including errata and programming code, can be obtained at
the following website: http://www.expresspublishing.co.uk/ibadvancedcomputerscience
ISBN 978-1-4715-5233-5
Advanced_ComputerScience_001-150.qxp_Advanced_ComputerScience 10/10/16 3:58 PM Page 1
Advanced_ComputerScience_001-150.qxp_Advanced_ComputerScience 10/10/16 3:58 PM Page 2
Made in EU
All rights reserved. No part of this publication may be reproduced, stored in a retrieval system, or
transmitted in any form, or by any means, electronic, photocopying, or otherwise, without the prior
written permission of the publishers.
ISBN 978-1-4715-5233-5
Advanced_ComputerScience_001-150.qxp_Advanced_ComputerScience 10/10/16 3:58 PM Page 3
Topic 7—Control
7.1 Control
Centralized control systems
7.1.1 Discuss a range of control systems.
7.1.2 Outline the uses of microprocessors aand sensor input in control system m s.
7.1.3 Evaluate different input devices for the collection of data in specified situations.
7.1.4 Explain the relationship between a se ensor, the processor and an output transducer.
Advanced_ComputerScience_001-150.qxp_Advanced_ComputerScience 10/10/16 3:58 PM Page 4
D—Object-oriented programming
D.4 Advanced program development
D.4.1 Define the term recursion.
D.4.2 Describe the application of recursive algorithms.
D.4.3 Construct algorithms that use recursion.
D.4.4 Trace recursive algorithms.
D.4.5 Define the term object reference.
D.4.6 Construct algorithms that use reference mechanisms.
D.4.7 Identify the features of the abstract data type (ADT) list.
D.4.8 Describe applications of lists.
D.4.9 Construct algorithms using a static implementation of a list.
D.4.10 Construct list algorithms using object references.
D.4.11 Construct algorithms using the standard library collections included in JETS.
D.4.12 Trace algorithms using the implementations described in assessment statements D.4.9–D.4.11.
D.4.13 Explain the advantages of using library collections.
D.4.14 Outline the features of ADT’s stack, queue and binary tree.
D.4.15 Explain the importance of style and naming conventions in code.
Advanced_ComputerScience_001-150.qxp_Advanced_ComputerScience 10/10/16 3:58 PM Page 5
Advanced_ComputerScience_001-150.qxp_Advanced_ComputerScience 10/10/16 3:58 PM Page 6
Advanced_ComputerScience_001-150.qxp_Advanced_ComputerScience 10/10/16 3:58 PM Page 7
To my son DDiim
mitris andd m
my daughter Eli
Elliaanaa..
Never fo
f rget thhat I lovee youu..
!
!
"
#
$%
&
'
())(
*
"
"
+
$
' ,
- .
+
%
&
&
'
/&'0
+
2
#
%
"
"
#
+ 3
+
#
&
&' $%
& *
#
#
+
()14
#
+
*
+ # # $%
#
$%
#
+
#
$
+ #
# #15 6 7 8 & /())40 *
6 #
$ %
$%$ 3
1
6 7 8 & /())40 *
6 # $ %
$%$ 3
Advanced_ComputerScience_001-150.qxp_Advanced_ComputerScience 10/10/16 3:58 PM Page 10
#$
%
! ) # (
+
&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&& ),
)& (
+
&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&& ),
?@
?11 $
?@
?1( &#
>;
?1; D
>?
?14 #
>>
7 >A
?1< 7 9 /90>A
?1? = ?1> 9
C
@(
?1@
9
@<
?1A 9
" @>
" C
@A
' (
&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&& -
! * #
&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&& -"
*&
&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&& -"
*
A<
>11 &
A<
Advanced_ComputerScience_001-150.qxp_Advanced_ComputerScience 10/10/16 3:58 PM Page 12
>1( +
1 1)1
>1;
1 1);
>14 + #
1 1)4
>1< + #
1 1)?
>1?
#
1
1)?
#
1
1)A
>1> *
#
1 1)A
>1@ +
1
111
" C
1 11<
' (
&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&
4; *
1 1(@
44 +
1 1(A
4< #!
1 1;)
4? *
1 1;;
4> $
&#
+ /&+0 1 1;>
4@
#
1 14)
4A *
1 144
41) *
#!
1 1<(
411 *
#
6+ 1 1?1
41( +
#
4AE411 1
1?>
41; "
#
1 1>1
414 9
&+H
C
# 1 1>;
41< "
1 1>;
" C
1 1>>
' (
&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&
,
$
$ # 3 4 5 &&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&
,"
&1
ArrayList
(
(@<
&( B
ArrayList
( (@>
Advanced_ComputerScience_001-150.qxp_Advanced_ComputerScience 10/10/16 3:58 PM Page 13
'
!/
" . $
!($
! $!$ !(:!:(6
$%
#
" # #
2
5
'==&%
& ==*"-*-=% = = &'
+ "
#
+
"
#
;
/
#
&$%%
%
$%%
%
' $
#(
%
7
' 8 ' 2 '
3
+&
7 2
'
3
+
%
& ! 2 +'
% &
$
#
"
+ "& !' !9 <
+
1
$ %
9 /()1(0 $% *
:
(
+ /()1< I# 1> >0
0 $
7 145)
);
I# 1> ()14 5JJ J J+ KK
Advanced_ComputerScience_001-150.qxp_Advanced_ComputerScience 10/10/16 3:58 PM Page 14
#
+
$ <1 +
#
5
+
+ #
#
L #
#
# # #
&
& % *
#
/
1 # # #0 &
+ #
& *
#
1
& *
( & %
; * %
4 & *
< % &
? % *
>
& *
Advanced_ComputerScience_001-150.qxp_Advanced_ComputerScience 10/10/16 3:58 PM Page 15
+
#
/0
# / 0
# /0 #
/
"0 +
#E
/
" 0
#
/& % *0
M 1N
$
1
7
+
#
#
?
Advanced_ComputerScience_001-150.qxp_Advanced_ComputerScience 10/10/16 3:58 PM Page 16
method koch_fractal(n)
if (n == 0) then
pen.goForward(size)
else
koch_fractal(n-1)
pen.turnLeft(60)
koch_fractal(n-1)
pen.turnRight(120)
koch_fractal(n-1)
pen.turnLeft(60)
koch_fractal(n-1)
end if
end method
output Draw_Koch_fractal(N)
Advanced_ComputerScience_001-150.qxp_Advanced_ComputerScience 10/10/16 3:58 PM Page 17
+
+ 6
.
+
+ &
+
addIntUpTo(n) n>0
#
n 1 ' "" addIntUpTo(4)
#5 4 + 3 + 2 + 1 = 10
method
d addIntUpTo(n)
i
if (n == 1) then
return 1
e
else
return n + addIntUpTo(n-1)
end if
e
ethod
end me
+
9
# / addIntUpTo
n-10 n-1
n = 1
+
+ 6 6
&
L #
N
metho
od foo(n)
if (n <= 1) then
return 1
se
els
return foo(n-1) + foo(n-2)
d if
end
method
end m
ut foo(5)
outpu
& 5 8
+
+ 6 ? 6
&
L #
N
metho
od foo(n, m)
if (n <= 1) OR (m <= 1) then
return 2
"
Advanced_ComputerScience_001-150.qxp_Advanced_ComputerScience 10/10/16 3:58 PM Page 18
else
return foo(n-1, m) + foo(n, m-2)
end if
end method
output foo(5,4)
& 5 30
+
+ 6 6
&
L #
N
method foo(n, m)
output "value of n=", n, "value of m =", m
if (n <= 1) OR (m<=1) then
return 2
else
return foo(n-1, m-n)+foo(n, m-2)
end if
end method
& 5
value of n= 3 value of m = 2
value of n= 2 value of m = -1
value of n= 3 value of m = 0
Output is 4
+
+ 6 " 6
&
L #
N
method Foo(X,Y)
if X < Y then
return Foo(X+1,Y-2)
else if X = Y then
return 2*Foo(X+2,Y-3)-3
else
return 2*X+3*Y
end if
end method
output "Output is", Foo(3,12)
& 5
Output is 47
)
ADVANCED_COMPUT_SCIENCE_COVER.qxp_COMPUTER_Science_COVER 10/10/16 4:32 PM Page 1
Feature include:
• Plain English language
• Diagrams and illustrations for all key concepts
• Examination style questions with answers for all topics
• Use of IB style pseudocode, as well as actual working code in the Java
Programming Language
• A complete and efficient working Java solution that addresses a real life scenario
• One-to-one reference to the assessment statements in the IB Computer Science
This book allows both students and teachers to follow the wide-ranging IB Computer
Science syllabus in such a way that they can be confident that all aspects of theory and
practical exercises have been covered.
Further details about the book, including errata and programming code, can be obtained at
the following website: http://www.expresspublishing.co.uk/ibadvancedcomputerscience
ISBN 978-1-4715-5233-5