Sie sind auf Seite 1von 18

COMPUTER SCIENCE (868)

Aims (Conceptual) (b) how they communicate with the outside


(1) To understand algorithmic problem solving world.
using data abstractions, functional and procedural (3) To create awareness of ethical problems and
abstractions, and object based and object oriented issues related to computing.
abstractions. Aims (Skills)
(2) To understand: (a) how computers represent, To devise algorithmic solutions to problems and to be
store and process data by studying the architecture able to code, validate, document, execute and debug
and machine language of a simple microprocessor the solution using the Java programming system.
and the different levels of abstraction that mediate
between the machine and the algorithmic problem
solving level and
CLASS XI
Therewill be two papers in the subject: algorithms are also good examples for defining
Paper I: Theory- different functions in a class modelling numbers
3 hours.100 marks (when programming is discussed). For addition
Paper II: Practical- and subtraction use the analogy with decimal
3 hours.100 marks numbers, emphasize how carry works (this will be
useful later when binary adders are discussed).
PAPER I-THEORY 2. Encodings
Paper 1 shall be of 3 hours duration and be divided into (a) Binary encodings for integers and real
two parts. numbers using a finite number of bits (sign-
Part I (30 marks): This part will consist of magnitude, twos complement, mantissa-
compulsory short answer questions, testing exponent notation). Basic operations on integers
knowledge, application and skills relating to the entire and floating point numbers. Limitations of finite
syllabus. representations.
Part II (70 marks): This part will be divided into
Signed, unsigned numbers, least and most
three Sections, A, B and C. Candidates are required to
answer three questions out of four from Section A and significant bits. Sign-magnitude
two questions out of three in each of the Sections B representation and its shortcomings (two
and C. Each question in this part shall carry 10 representations for 0, addition requires extra
marks. step); twos-complement representation.
SECTION A Operations (arithmetic, logical, shift), discuss
the basic algorithms used for the arithmetic
Basic Computer Hardware and Software
operations. Floating point representation:
1. Numbers normalized scientific notation, mantissa-
Representation of numbers in different bases and exponent representation, binary point (discuss
interconversion between them (e.g. binary, octal, trade-off between size of mantissa and
decimal, hexadecimal). Addition and subtraction exponent). Single and double precision.
operations for numbers in different bases. Arithmetic operations with floating point
Introduce the positional system of representing numbers. Properties of finite representation:
numbers and the concept of a base. Discuss the overflow, underflow, lack of associativity
conversion of representations between different (demonstrate this through actual programs).
bases using English or pseudo code. These
212
(b) Characters and their encodings (e.g. ASCII, 5. Propositional logic, hardware implementation,
Unicode). arithmetic operations
(a) Propositional logic, well formed formulae,
Discuss the limitations of the ASCII code in truth values and interpretation of well formed
representing characters of other languages. formulae, truth tables.
Discuss the Unicode representation for the Propositional variables; the common logical
local language. Java uses Unicode, so strings connectives ( (not)(negation), _
in the local language can be used (they can
~
(and)(conjunction), _
(or)(disjunction)
,
be displayed if fonts are available) a simple _ (implication),  (equivalence)); definition
table lookup for local language equivalents for of a well-formed formula (wff); representation
Latin (i.e. English) character strings may be of simple word problems as wff (this can be
done. More details on Unicode are used for motivation); the values true
available at www.unicode.org. and
false; interpretation of a wff; truth tables;
satisfiable, unsatisfiable and valid formulae.
3. High level structure of computer
Block diagram of a computer system with details of
(i) function of each block and (ii) 2
interconnectivity and data and control flow 1
between the various blocks 3
Develop the diagram by successive refinement of
blocks till all the following have been covered:
ALU, RAM, cache, the buses (modern computers
have multiple buses), disk (disk controller and
what it does), input/output ports (serial, parallel,
USB, network, modem, line-in, line-out etc.),
devices that can be attached to these ports (e.g
keyboard, mouse, monitor, CDROM, DVD, audio
input/output devices, printer, etc.). Clearly
describe the connectivity and the flow of data and
control signals.

4. Basic architecture of a simple processor and its


instruction set
Simple Hypothetical Computer.
The simple hypothetical computer abbreviated as
(SHC) is meant to introduce the basic structure of a
processor in particular registers, basic
instruction set, structure of an instruction,
program counter addressing modes (immediate,
direct, register, register-indirect). Simple
programs should be written in the SHC
instruction set (e.g. max./min. of set of nos.)
SECTION B 10. Primitive values, wrapper classes, types and
casting
The programming element in the syllabus is aimed at Primitive values and types: int, short, long, float,
algorithmic problem solving and not merely rote double, boolean, char. Corresponding wrapper
learning of Java syntax. The Java version used should classes for each primitive type. Class as type of the
be 1.5 or later. For programming, the students can use object. Class as mechanism for user defined types.
Changing types through user defined casting and
any text editor and the javac and java programs or any
automatic type coercion for some primitive types.
development environment: for example, BlueJ,
Eclipse, NetBeans etc. BlueJ is strongly recommended Ideally, everything should be a class; primitive
types are defined for efficiency reasons; each
for its simplicity, ease of use and because it is very well
primitive type has a corresponding wrapper class.
suited for an obj ects first approach. Classes as user defined types. In some cases types
are changed by automatic coercion or casting e.g.
mixed type expressions. However, casting in
8. Introduction to algorithmic problem solving
general is not a good idea and should be avoided, if
using Java possible.
Note that topics 9 to 13 will get introduced almost 11. Variables, expressions
simultaneously when classes and their definitions
Variables as names for values; expressions
are introduced. (arithmetic and logical) and their evaluation
9. Objects (operators, associativity, precedence). Assignment
operation; difference between left hand side and
(a) Objects as data (attributes) + behaviour right hand side of assignment.
(methods or functions); object as an instance Variables denote values; variables are already
of a class. Constructors. defined as attributes in classes; variables have
Difference between object and class should be types that constrain the values it can denote.
Difference between variables denoting primitive
made very clear. BlueJ (www.bluej.org) and
values and object values
Greenfoot (www.greenfoot.org) can be used variables denoting objects are references to
for this purpose. Constructor as a special kind those objects. The assignment operator = is
of function; the new operator; multiple special. The variable on the lhs of = denotes the
constructors with different argument memory location while the same variable on the rhs
structures; constructor returns a reference to denotes the contents of the location e.g. i=i+2.
the object. 12. Statements, scope
(b) Analysis of some real world programming Statements; conditional (if, if-then-else, switch-
examples in terms of objects and classes. break, ?: ternary operator), looping (for, while-do,
do-while, continue, break); grouping statements in
Use simple examples like a calculator, date, blocks, scope and visibility of variables.
number etc. to illustrate how they can be Describe the semantics of the conditional and
treated as objects that behave in certain well- looping statements in detail. Evaluation of the
defined ways and how the interface provides a condition in conditional statements (esp.
way to access behaviour. Illustrate behaviour difference between || and | and && and &).
changes by adding new functions, deleting old Emphasize fall through in switch statement. Many
functions or modifyingexisting functions. small examples should be done to illustrate
control structures. Printing different kinds of

214
patterns for looping is instructive. When number of 14. Arrays, strings
iterations are known in advance use the for loop (a) Structured data types arrays (single and
otherwise the while-do or do-while loop. Express multi-dimensional), strings. Example algorithms
one loop construct using the others. For e.g.: that use structured data types (e.g. searching,
for (<init>; <test>; <inc>) <stmt>; is equivalent finding maximum/minimum, sorting techniques,
to: solving systems of linear equations, substring,
concatenation, length, access to char in string,
(i) Using while
etc.).
<init>; while <test> {<stmt>; <inc> } (ii) Storing many data elements of the same type
requires structured data types like arrays.
Using do-while
Access in arrays is constant time and does not
<init>; if !<test> do <stmt>; <inc> while depend on the number of elements. Sorting
<test>; techniques (bubble, selection, insertion),
Nesting of blocks. Variables with block scope, Structured data types can be defined by
function scope, class scope. Visibility rules when classes String. Introduce the Java library
variables with the same name are defined in String class and the basic operations on
different scopes. strings (accessing individual characters,
various substring operations, concatenation,
replacement, index of operations).
13. Functions (b) Basic concept of a virtual machine; Java
Functions/methods (as abstractions for complex virtual machine; compilation and execution of Java
user defined operations on objects), functions as programs (the javac and java programs).
mechanisms for side effects; formal arguments The JVM is a machine but built as a program
and actual arguments in functions; different and not through hardware. Therefore it is
behaviour of primitive and object arguments. called a virtual machine. To run, JVM
Static functions and variables. The this variable. machine language programs require an
Examples of algorithmic problem solving using interpreter (the java program). The advantage
functions (various number theoretic problems, is that such JVM machine language programs
finding roots of algebraic equations). (.class files) are portable and can run on any
Functions are like complex operations where the machine that has the java program.
object is implicitly the first argument. Variable (c) Compile time and run time errors; basic
this denotes the current object. Functions concept of an exception, the Exception class, catch
typically return values, they may also cause side- and throw.
effects (e.g. change attribute values of objects) Differentiate between compile time and run
typically functions that are only supposed to cause time errors. Run time errors crash the
side-effects return void (e.g. Set functions). Java program. Recovery is possible by the use of
passes argument by value. Illustrate the difference exceptions. Explain how an exception object is
created and passed up until a matching
between primitive values and object values as
catch is found. This behaviour is different
arguments (changes made inside functions persist from the one where a value is returned by a
after the call for object values). Static definitions as deeply nested function call. It is enough to
class variables and class functions visible and discuss the Exception class. Sub-classes of
shared by all instances. Need for static functions Exception can be discussed after inheritance
and variables. Introduce the main method has been done in Class XII.
needed to begin execution.

215
SECTION C Object pop()
15. Elementary data structures and associated boolean isEmpty()
algorithms, basic input/output Object top()
(a) Class as a contract; separating implementation Then, for example the LIFO property can be
from interface; encapsulation; private and public.
expressed by (assume s is a stack):
Class is the basic reusable unit. Its function if s.push(o); o1=pop() then o o1
prototypes (i.e. the interface) work as a visible
contract with the outside world since others What the rule says is: if o is pushed on the
will use these functions in their programs. stack s and then it is popped and o1 is the
This leads to encapsulation (i.e. hiding object obtained then o, o1 are identical.
implementation information) which in turn
leads to the use of private and public for Another useful property is:
realizing encapsulation. if s.isEmpty() == true then s.pop() = ERROR
(b) Interfaces in Java; implementing interfaces It says that popping an empty stack gives
through a class; interfaces for user defined ERROR.
implementation of behaviour. Similarly, several other properties can also be
Motivation for interface: often when creating specified. It is important to emphasize the
reusable classes some parts of the exact behavioural rules or properties of a data
implementation can only be provided by the structure since any implementation must
final end user. For example in a class that sorts guarantee that the rules hold.
records of different types the exact Some simple algorithms that use the data
comparison operation can only be provided by structures:
the end user. Since only he/she knows which
field(s) will be used for doing the i.For stack: parentheses matching, tower of
comparison and whether sorting should be in Hanoi, nested function calls; solving a maze.
ascending or descending order be given by the ii) For queue: scheduling processes, printers,
user of the class. jobs in a machine shop.
Emphasize the difference between the Java (d) Basic input/output using Scanner and Printer
language construct interface and the word classes from JDK; files and their representation
interface often used to describe the set of using the File class, file input/output; input/output
function prototypes of a class. exceptions. Tokens in an input stream, concept
(c) Basic data structures (stack, queue, dequeue); of whitespace, extracting tokens from an input
implementation directly through classes; stream (StringTokenizer class).
definition through an interface and multiple The Scanner class can be used for input of
implementations various types of data (e.g. int, float, char etc.)
by implementing the interface. Basic from the standard input stream or a file input
algorithms and programs using the above data stream. The File class is used model file
structures. objects in the underlying system in an OS
A data structure is a data collection with well independent manner. Similarly, the Printer
defined operations and behaviour or class handles output. Only basic input and
output using these classes should be covered.
properties. The behaviour or properties can
usually be expressed formally using equations Discuss the concept of a token (a delimited
or some kind of logical formulae. Consider for continuous stream of characters that is
e.g. a stack with operations defined as follows: meaningful in the application program e.g.
void push(Object o) words in a sentence where the delimiter is the

216
blank character). This naturally leads to the (f) Concrete computational complexity; concept of
idea of delimiters and in particular input size; estimating complexity in terms
whitespace and user defined characters as of functions; importance of dominant term;
delimiters. As an example show how the best, average and worstcase.
StringTokenizer class allows one to extract a Points to be given particular emphasis:
sequence of tokens from a string with user (i) Algorithms are usually compared along
defined delimiters. two dimensions amount of space (that is
(e) Concept of recursion, simple recursive memory) used and the time taken. Of the
functions (e.g. factorial, GCD, binary search, two the time taken is usually considered the
conversion of representations of numbers more important. The motivation to study
between different bases). time complexity is to compare
Many problems can be solved very elegantly by different algorithms and use the one that is
observing that the solution can be composed the most efficient in a particular situation.
of solutions to smaller versions of the same (ii)Actual run time on a particular computer is
problem with the base version having a not a good basis for comparison since it
known simple solution. Recursion can be depends heavily on the speed of the
initially motivated by using recursive equations computer, the total amount of RAM in the
to define certain functions. These definitions computer, the OS running on the system and
are fairly obvious and are easy to understand. the quality of the compiler used. So we need a
The definitions can be directly converted to a more abstract way to compare the time
program. Emphasize that any recursion must complexity of algorithms.
have a base case. Otherwise, the computation (iii) This is done by trying to approximate the
can go into an infinite loop. Illustrate this by number of operations done by each algorithm
removing the base case and running the as a function of the size of the input. In most
program. Examples: programs the loops are important in deciding
(i) Definition of factorial: the complexity. For example in bubble sort
there are two nested loops and in the worst
factorial(0) = 1 //base case case the time taken will be proportional to
factorial(n) = n * factorial(n-1) (ii) n(n-1) where n is the number of elements to be
sorted. Similarly, in linear search in the
Definition of GCD: worst case the target has to be compared with
gcd(m, n) = all the elements so time taken will be
proportional to n where n is the number of
if (m==n) then n //base case elements in the search set.
else if (m>n) then gcd(m-n, n) (iv)In most algorithms the actual complexity for
a particular input can vary. For example in
else gcd(m, n-m) search the number of comparisons can vary
from 1 to n. This means we need to study the
(iii)Definition of Fibonacci numbers:
best, worst and average cases. Comparisons
fib(0) = 1 //base case are usually made taking the worst case.
fib(1) = 1 //base case Average cases are harder to estimate since it
depends on how the data is distributed. For
fib(n) = fib(n-1)+ fib(n-2) example in search, if the elements are uniformly
The tower of Hanoi is a very good example of distributed it will take on the average n/2
how recursion gives a very simple and elegant comparisons when the average is taken over a
solution where as non-recursive solutions are statistically significant number ofinstances.
quite complex. Discuss the use of a stack to
keep track of function calls. The stack can also
be used to solve the tower of Hanoi problem
non-recursively.
217
(v) Comparisons are normally made for large PAPER II-PRACTICAL
values of the input size. This means that the
dominant term in the function is the important This paper of three hours duration will be evaluated
term. For example if we are looking at internally by the school.
bubble sort and see that time taken can be The paper shall consist of three programming
estimated as: a*n2 +b*n + c where n is the problems from which a candidate has to attempt any
number of elements to be sorted and a, b, c are one. The practical consists of the two parts:
constants then for large n the dominant term is (1) Planning Session
clearly n2 and we can in effect ignore the
(2) Examination Session The total time to be spent on
other two terms.
the Planning session and
16. Implementation of algorithms to solve the Examination session is three hours. After
problems completing the Planning session the candidates may
The students are required to do lab assignments in begin with the Examination session. A maximum of 90
the computer lab concurrently with the lectures. minutes is permitted for the Planning session.
Programming assignments should be done such However, if the candidates finish earlier, they are to be
that each major topic is covered in at least one permitted to begin with the Examination session.
assignment. Assignment problems should be Planning Session
designed so that they are non-trivial and make the The candidates will be required to prepare an
student do algorithm design, address correctness algorithm and a hand written Java program to solve the
issues, implement and execute the algorithm in problem.
Java and debug where necessary.
Examination Session
Self explanatory.
The program handed in at the end of the Planning
17. Social context of computing and ethical issues session shall be returned to the candidates. The
candidates will be required to key-in and execute the
(a) Intellectual property and corresponding laws
Java program on seen and unseen inputs individually on
and rights, software as intellectual property.
the Computer and show execution to the examiner. A
(b) Software copyright and patents and the printout of the program listing, including output results
difference between the two; trademarks; software should be attached to the answer script containing
licensing and piracy. the algorithm and handwritten program. This should
(c) Free software foundation and its position on be returned to the examiner. The program should be
software, open source software, various types sufficiently documented so that the algorithm,
of licensing (e.g. GPL, BSD). representation and development process is clear from
(d) Privacy, email etiquette, spam, security issues, reading the program. Large differences between the
phising. planned program and the printout will result in loss of
marks.
Social impact and ethical issues should be Teachers should maintain a record of all the
discussed and debated in class. The important assignments done as part of the practical work through
thing is for students to realise that these are the year and give it due credit at the time of
complex issues and there are multiple points of cumulative evaluation at the end of the year. Students
view on many of them and there is no single are expected to do a minimum of twenty assignments
correct or right view.
for the year.
Marks (out of a total of 100) should be distributed as
given below:

218
Continuous Evaluation (Marks should be given for choice of algorithm and
Candidates will be required to submit a work file implementation strategy, documentation, correct output
containing the practical work related to programming on known inputs mentioned in the question paper,
assignments done during the year. correct output for unknown inputs available only to the
examiner.)
Programming assignments done throughout the year Viva-voce -20 marks
(Internal evaluation) -20 marks (Viva-voce includes questions on the following
aspects of the problem attempted by the student: the
Terminal Evaluation algorithm and implementation strategy,
Solution to programming problem on the computer -60 documentation, correctness, alternative algorithms or
implementations. Questions should be confined largely
marks to the problem the student has attempted).

219
CLASS XII

There will be two papers in the subject: simplification rules for , . Converse,
PaperI: Theory- inverse and contra positive. Chain
3 hours
100 marks
Paper II: Practical- rule(Modus ponen).
3 hours
100 marks pp pp

PAPER I-THEORY true true true p

Paper 1 shall be of 3 hours duration and be divided into _ false p


two parts. _ false false
Part I (30 marks): This part will consist of _ (p _ q) p
compulsory short answer questions, testing
_ (p _ q) p
knowledge, application and skills relating to the entire
syllabus. The equivalence rules can be used to simplify
Part II (70 marks): This part will be divided into propositional wffs, for example:
three Sections, A, B and C. Candidates are required to 1. (p _q) _ (p _ r) to p_(q_r)
answer three questions out of four from Section A and
two questions out of three in each of the Sections 2. ((p _q) _ p) _q totrue
B and C. Each question in this part shall carry 10
marks. etc.
SECTION A (b) Binary valued quantities; basic postulates of
Boolean algebra; operations AND, OR and NOT;
1. Boolean Algebra truth tables.
(a) Propositional logic, well formed formulae, (c) Basic theorems of Boolean algebra (e.g.
truth values and interpretation of well formed Duality, idempotence, commutativity,
formulae (wff), truth tables, satisfiable, associativity, distributivity, operations with 0 and
unsatisfiable and valid formulae. Equivalence laws 1, complements, absorption, involution); De
and their use in simplifying wffs. Morgans theorem and its applications; reducing
Boolean expressions to sum of
Propositional variables; the common logical products and product of sums forms;
connectives ( (not)(negation), _ Karnaugh maps (up to four variables).

~
(and)(conjunction), _ (or)(disjunction), _ (p _~p true); law of contradiction (p _~p
(implication), _ (biconditional); definition of false); tautology and contingency
a well-formed formula (wff); representation of 2
2
simple word problems as wff (this can be used 0
for motivation); the values true and false;
interpretation of a wff; truth tables;
satisfiable, unsatisfiable and valid formulae.
Equivalence laws: commutativity of _, _;
associativity of _, _; distributivity; de
Morgans laws; law of implication (p _ q
~ p_ q); law of biconditional ((p _ q)
(p _ q) _ (q _ p)); identity (p p); law of
negation (~ (~p) p); law of excluded middle
Show the correspondence between boolean (b) Analysis of some real world programming
functions and the corresponding switching examples in terms of objects and classes.
circuits or gates. Show that NAND and NOR gates
are universal by converting some circuits to Use simple examples like a calculator, date,
purely NAND or NOR gates. number, etc. to illustrate how they can be
SECTION B treated as objects that behave in certain well-
The programming element in the syllabus (Sections B defined ways and how the interface provides a way to acce
and C) is aimed at algorithmic problem solving and changes by
not merely rote learning of Java syntax. The Java functions or
version used should be 1.5 or later. For programming,
the students can use any text editor and the javac and
java programs or any development environment: for 6. Primitive values, wrapper classes, types and
example, BlueJ, Eclipse, NetBeans etc. BlueJ is casting
strongly recommended for its simplicity, ease of use
and because it is very well suited for an objects first Primitive values and types: int, short, long, float,
approach. double, boolean, char. Corresponding wrapper
classes for each primitive type. Class as type of the
3. Implementation of algorithms to solve
object. Class as mechanism for user defined types.
problems
Changing types through user defined casting and
The students are required to do lab assignments in automatic type coercion for some primitive types.
the computer lab concurrently with the lectures.
Programming assignments should be done such Ideally, everything should be a class; primitive
that each major topic is covered in at least one types are defined for efficiency reasons; each
assignment. Assignment problems should be primitive type has a corresponding wrapper class.
designed so that they are non-trivial and make the Classes as user defined types. In some cases types
student do algorithm design, address correctness are changed by automatic coercion or casting e.g.
issues, implement and execute the algorithm in
mixed type expressions. However, casting in
Java and debug where necessary.
general is not a good idea and should be avoided, if
Self explanatory. possible.
4. Programming in Java (Review of Class XI
Sections B and C) 7. Variables, expressions
Note that items 4 to 8 will get introduced almost Variables as names for values; expressions
simultaneously when classes and their definitions (arithmetic and logical) and their evaluation
are introduced. (operators, associativity, precedence). Assignment
5. Objects operation; difference between left hand side and
right hand side of assignment.
(a) Objects as data (attributes) + behaviour
(methods or functions); object as an instance Variables denote values; variables are already
of a class. Constructors. defined as attributes in classes; variables have
Difference between object and class should be types that constrain the values it can denote.
made very clear. BlueJ (www.bluej.org) and Difference between variables denoting primitive
Greenfoot (www.greenfoot.org) can be values and object values
profitably used for this purpose. Constructor as
a special kind of function; the new operator; variables denoting objects are references to
multiple constructors with different argument those objects. The assignment operator = is
structures; constructor returns a reference to special. The variable on the lhs of = denotes the
the object. memory location while the same variable on the rhs
denotes the contents of the location e.g. i=i+2.
221
8. Statements, scope between primitive values and object values as
Statements; conditional (if, if-then-else, switch- arguments (changes made inside functions persist
break, ?: ternary operator), looping (for, while-do, after the call for object values). Static definitions as
do-while, continue, break); grouping statements in class variables and class functions visible and
blocks, scope and visibility of variables. shared by all instances. Need for static functions
and variables. Introduce the main method
Describe the semantics of the conditional and needed to begin execution.
looping statements in detail. Evaluation of the
condition in conditional statements (esp. 10. Arrays, strings
difference between || and | and && and &). (a) Structured data types arrays (single and
Emphasize fall through in switch statement. Many multi-dimensional), strings. Example algorithms
small examples should be done to illustrate that use structured data types (e.g. searching,
control structures. Printing different kinds of finding maximum/minimum, sorting techniques,
patterns for looping is instructive. When number of solving systems of linear equations, substring,
iterations are known in advance use the for loop concatenation, length, access to char in string,
otherwise the while-do or do-while loop. Express etc.).
one loop construct using the others. For e.g.: Storing many data elements of the same type
for (<init>; <test>; <inc>) <stmt>; is equivalent requires structured data types like arrays.
to: Access in arrays is constant time and does not
depend on the number of elements. Sorting
Using while techniques (bubble, selection, insertion).
<init>; while <test> {<stmt>; <inc> } Structured data types can be defined by
classes String. Introduce the Java library
Using do-while String class and the basic operations on
strings (accessing individual characters,
<init>; if !<test> do <stmt>; <inc> while <test>;
various substring operations, concatenation,
Nesting of blocks. Variables with block scope, replacement, index of operations). The Class
function scope, class scope. Visibility rules when StringBuffer should be introduced for those
variables with the same name are defined in applications that involve heavy manipulation
different scopes. of strings.
(b) Basic concept of a virtual machine; Java
9. Functions virtual machine; compilation and execution of Java
Functions/methods (as abstractions for complex programs (the javac and java programs).
user defined operations on objects), functions as The JVM is a machine but built as a program
mechanisms for side effects; formal arguments and not through hardware. Therefore it is
and actual arguments in functions; different called a virtual machine. To run, JVM
behaviour of primitive and object arguments. machine language programs require an
Static functions and variables. The this variable. interpreter (the java program). The advantage
Examples of algorithmic problem solving using is that such JVM machine language programs
functions (various number theoretic problems, (.class files) are portable and can run on any
finding roots of algebraic equations). machine that has the java program.
Functions are like complex operations where the (c) Compile time and run time errors; basic
object is implicitly the first argument. Variable concept of an exception, the Exception class, catch
this denotes the current object. Functions and throw.
typically return values, they may also cause side- Differentiate between compile time and run
effects (e.g. change attribute values of objects) time errors. Run time errors crash the
typically functions that are only supposed tocause program. Recovery is possible by the use of
side-effects return void (e.g. Set functions). Java exceptions. Explain how an exception object is
created and passed up until a matching
passes argument by value. Illustrate the difference
catch is found. This behaviour is different
222
from the one where a value is returned by a meaningful in the application program e.g.
deeply nested function call. It is enough to words in a sentence where the delimiter is the
discuss the Exception class. Sub-classes of blank character). This naturally leads to the
Exception can be discussed after inheritance idea of delimiters and in particular
has been done in Class XII. whitespace and user defined characters as
(d) Class as a contract; separating implementation delimiters. As an example show how the
from interface; encapsulation; private and public. StringTokenizer class allows one to extract a
Class is the basic reusable unit. Its function sequence of tokens from a string with user
prototypes (i.e. the interface) work as avisible defined delimiters.
contract with the outside world since others (g) Concept of recursion, simple recursive
will use these functions in their programs. functions (e.g. factorial, GCD, binary search,
This leads to encapsulation (i.e. hiding conversion of representations of numbers
implementation information) which in turn between different bases). Recursive sorting
leads to the use of private and public for techniques.
realizing encapsulation. Many problems can be solved very elegantly by
(e) Interfaces in Java; implementing interfaces observing that the solution can be composed
through a class; interfaces for user defined of solutions to smaller versions of the same
implementation of behaviour. problem with the base version having a
Motivation for interface: often when creating known simple solution. Recursion can be
reusable classes, some parts of the exact initially motivated by using recursive equations
implementation can only be provided by the to define certain functions. These definitions
final end user. For example, in a class that are fairly obvious and are easy to understand.
sorts records of different types the exact The definitions can be directly converted to a
comparison operation can only be provided by program. Emphasize that any recursion must
the end user. Since only he/she knows which have a base case. Otherwise, the computation
field(s) will be used for doing the can go into an infinite loop. Illustrate this by
comparison and whether sorting should be in removing the base case and running the
ascending or descending order be given by the program. Examples:
user of the class. (i) Definition of factorial:
Emphasize the difference between the Java
factorial(0) = 1 //base case
language construct interface and the word
interface often used to describe the set of factorial(n) = n * factorial(n-1) (ii)
function prototypes of a class. Definition of GCD:
(e) Basic input/output using Scanner and Printer gcd(m, n) =
classes from JDK; files and their representation
using the File class, file input/output; if (m==n) then n //base case else if
input/output exceptions. Tokens in an input (m>n) then gcd(m-n, n) else gcd(m,
stream, concept of whitespace, extracting tokens n-m) (iii)Definition of Fibonacci
from an input stream (StringTokenizer class).
The Scanner class can be used for input of numbers: fib(0) = 1 //base case
various types of data (e.g. int, float, char etc.) fib(1) = 1 //base case
from the standard input stream or a file input fib(n) = fib(n-1)+ fib(n-2)
stream. The File class is used model file The tower of Hanoi is a very good example of
objects in the underlying system in an OS how recursion gives a very simple and elegant
independent manner. Similarly, the Printer solution where as non-recursive solutions are
class handles output. Only basic input and quite complex. Discuss the use of a stack to
output using these classes should be covered.
keep track of function calls. A stack can also be
Discuss the concept of a token (a delimited used to solve the tower of Hanoi problem
continuous stream of characters that is
non-recursively.Merge sort and Quick sort on
223 arrays.
SECTION C 12. Data structures
Inheritance, polymorphism, data structures, (a) Basic data structures (stack, queue, dequeue);
computational complexity implementation directly through classes;
11. Inheritance and polymorphism definition through an interface and multiple
implementations by implementing the interface.
Inheritance; base and derived classes; member Basic algorithms and programs using the above
access in derived classes; redefinition of variables data structures.
and functions in subclasses; abstract classes; class
Object; protected visibility. Subclass A data structure is a data collection with well
polymorphism and dynamic binding. defined operations and behaviour or
properties. The behaviour or properties can
Emphasize the following: usually be expressed formally using equations
-inheritance as a mechanism to reuse a class by or some kind of logical formulae. Consider for
extending it. e.g. a stack with operations defined as follows:
-inheritance should not normally be used just to
void push(Object o)
reuse some functions defined in a class but only
when there is a genuine specialization Object pop()
(or subclass) relationship between objects of
the base class and that of the derived class. boolean isEmpty()
-Allows one to implement operations at the Object top()
highest relevant level of abstraction. Then, for example the LIFO property can be
-Freezes the interface in the form of abstract expressed by (assume s is a stack):
classes with abstract functions that can be if s.push(o); o1=pop() then o o1
extended by the concrete implementing classes. What the rule says is: if o is pushed on the
For example, an abstract class Shape can have an stack s and then it is popped and o1 is the
abstract function draw that is implemented object obtained then o, o1 are identical.
differently in the sub-classes like Circle, Another useful property is:
Quadrilateral etc.
if s.isEmpty() == true then s.pop() = ERROR
-how the exact function call at run time depends It says that popping an empty stack gives
on the type of the object referenced ERROR.
by the variable. This gives sub-class
polymorphism. For example in the code Similarly, several other properties can also be
fragment: specified. It is important to emphasize the
behavioural rules or properties of a data
Shape s1=new Circle(), s2=new structure since any implementation must
Quadrilateral(); guarantee that the rules hold.
s1.draw(); //the draw is the draw in Circle Some simple algorithms that use the data
s2.draw(); //the draw is the draw in structures:
Quadrilateral (i) For stack: parentheses matching, tower of
the two draw function invocations on s1, s2 Hanoi, nested function calls; solving a maze.
invoke different draw functions depending on (ii) For queue: scheduling processes,
the type of objects referenced by s1 and s2 printers, jobs in a machine shop.
respectively.

224
(b) Recursive data structures: single linked (iii)This is done by trying to approximate the
list (Algorithm and programming), binary number of operations done by each algorithm
trees, tree traversals (Conceptual) as a function of the size of the input. In most
Data structures should be defined as programs the loops are important in deciding
abstract data types with a well defined the complexity. For example in bubble sort
interface (it is instructive to define them there are two nested loops and in the worst
using the Java interface construct) see the case the time taken will be proportional to
comments in (a) above. Emphasize that n(n-1) where n is the number of elements to be
algorithms for recursive data structures are sorted. Similarly, in linear search in the worst
themselves recursive and that algorithms are case the target has to be compared with all the
usually the simplest and most elegant. The elements so time taken will be proportional
following should be covered for each data to n where n is the number of elements in the
structure: search set.
Linked List (single): insertion, deletion, (iv)In most algorithms the actual complexity for a
reversal, extracting an element or a sublist, particular input can vary. For example in
checking emptiness. search the number of comparisons can vary from 1
to n. This means we need to study the best, worst
Binary trees: apart from the definition the
and average cases. Comparisons are usually
following concepts should be covered:
made taking the worst case. Average cases are
external and internal nodes, height, level,
harder to estimate since it depends on how the data
size, degree, completeness, balancing,
is distributed. For example in search, if the
Traversals (pre, post and in-order). elements are uniformly distributed it will take on
the
13. Complexity and big Onotation average n/2 comparisons when the average is
Concrete computational complexity; concept of taken over a statistically significant number of
input size; estimating complexity in terms of instances.
functions; importance of dominant term; best, (v) Comparisons are normally made for large
average and worst case. Big O notation for values of the input size. This means that the
computational complexity; analysis of complexity dominant term in the function is the important term.
of example algorithms using the big O notation For example if we are looking at bubble sort and
(e.g. Various searching and sorting algorithms, see that time taken can be estimated as: a*n2 +b*n
algorithm for solution of linear equations etc.). + c where n is the number of elements to be sorted
Points to be given particular emphasis: and a, b, c are constants then for large n the
dominant term is clearly
(i) Algorithms are usually compared along two n2and we can, in effect, ignore the other two
dimensionsmemory) used and the time taken. Of the two amount of space (that is terms.
the time taken is usually considered the more All the above motivates the big O notation. Let f(n),
important. The motivation to study time g(n) be positive functions, then f(n) is said to be
complexity is to compare different algorithms O(g(n)) if there exists constants c, n
0such that
and use the one that is the most efficient in a
particular situation. f(x) c*g(n) whenever n>n
0. What this means is
that g(n) asymptotically dominates f(n).
Expressing time complexity using the big O
(ii) Actual run time on a particular computer is not notation gives us an abstract basis for comparison
a good basis for comparison since it depends and frees us from bothering about constants. So the
heavily on the speed of the computer, the total estimated time complexity a*n2 +b*n+c is O(n2
amount of RAM in the computer, the OS running on ).
the system and the quality of the compiler used. So Analyse the big O complexity of the algorithms
we need a more abstract way to compare the time pertaining to the data structures in 11 (a) and (b)
complexity of algorithms. above.
225
PAPER II-PRACTICAL Marks (out of a total of 100) should be distributed as
This paper of three hours duration will be evaluated by given below:
the Visiting Examiner appointed locally and
approvedby the Council. Continuous Evaluation
Candidates will be required to submit a work file
The paper shall consist of three programming
containing the practical work related to programming
problems from which a candidate has to attempt any
assignments done during the year.
one. The practical consists of the two parts:
Programming assignments done throughout the year
1. Planning Session
(Internal evaluation)
2. Examination Session -10 marks
The total time to be spent on the Planning session and Programming assignments done throughout the year
the Examination session is three hours. After (Visiting Examiner)
completing the Planning session the candidates may -10 marks
begin with the Examination session. A maximum of 90
minutes is permitted for the Planning session. Terminal Evaluation
However, if the candidates finish earlier, they are to be Solution to programming problem on the computer -60
permitted to begin with the Examination session. marks
(Marks should be given for choice of algorithm and
Planning Session implementation strategy, documentation, correct output
The candidates will be required to prepare an on known inputs mentioned in the question paper,
algorithm and a hand written Java program to solve the correct output for unknown inputs available only to the
problem. examiner.)
Viva-voce
Examination Session -20 marks
The program handed in at the end of the Planning (Viva-voce includes questions on the following
session shall be returned to the candidates. The aspects of the problem attempted by the student: the
candidates will be required to key-in and execute the algorithm and implementation strategy,
Java program on seen and unseen inputs individually on documentation, correctness, alternative algorithms or
the Computer and show execution to the Visiting implementations. Questions should be confined
Examiner. A printout of the program listing including largely to the problem the student has attempted).
output results should be attached to the answer script NOTE:
containing the algorithm and handwritten program.
This should be returned to the examiner. The program Algorithm should be expressed clearly using any
should be sufficiently documented so that the standard scheme such as a pseudo code.
algorithm, representation and development process is
clear from reading the program. Large differences EQUIPMENT
between the planned program and the printout will There should be enough computers to provide for a
result in loss of marks. teaching schedule where at least three-fourths of the
Teachers should maintain a record of all the time available is used for programming.
assignments done as part of the practical work through Schools should have equipment/platforms such that all
the year and give it due credit at the time of the software required for practical work runs properly,
cumulative evaluation at the end of the year. Students i.e. it should run at acceptable speeds.
are expected to do a minimum of twenty assignments Since hardware and software evolve and change very
for the year. rapidly, the schools may have to upgrade them as
required. Following are the recommended
specifications as of now:
226
The Facilities: run the operating system and Java programming
 A lecture cum demonstration room with a system (Java compiler, Java runtime environment,
MULTIMEDIA PROJECTOR/ an LCD and O.H.P. Java development environment) at acceptable
attached to the computer. speeds.
 A white board with white board markers should be  Good Quality printers.
available. Software:
 A fully equipped Computer Laboratory that  Any suitable Operating System can be used.
allows one computer per student.  JDK 6 or later.
 Internet connection for accessing the World Wide  Documentation for the JDK version being used.
Web and email facility.
 A suitable text editor. A development
 The computers should have a minimum of 512 environment with a debugger is preferred (e.g. BlueJ,
MB (1 GB preferred) RAM and a PIV or higher Eclipse, NetBeans). BlueJ is recommended for its ease
of use and simplicity.

processor. The basic requirement is that it should 227


ISC YEAR 2016 EXAMINATION
SAMPLE TABLE FOR SENDING MARKS FOR PRACTICAL WORK
Assessment of Practical Assessment of the Practical Examination TOTAL
File (To be evaluated by the Visiting Examiner only) MARKS (Total
Internal Visiting Marks are to be
Algorithm Java Documentation Hard Output Viva-
Unique Evaluation Examiner Program Copy Voce added and
S. entered by the
Identification
(printout)
No. Number (UID) Visiting
of the candidate
Examiner)
10
20 100 Marks
10 Marks 10 Marks 10 Marks 20 Marks 10 Marks 10 Marks Marks Marks

1.

2.

3.

4.

5.

6.

7.

8.

9.

10.

Name of the Visiting Examiner:_________________________________

Signature: _______________________________

Date:___________________________________
28