Vous êtes sur la page 1sur 17

COMPUTER SCIENCE (868)

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


world.
(1) To understand algorithmic problem solving
using data abstractions, functional and (3) To create awareness of ethical problems and
procedural abstractions, and object based and issues related to computing.
object oriented abstractions.
Aims (Skills)
(2) To understand: (a) how computers represent,
To devise algorithmic solutions to problems and to
store and process data by studying the
be able to code, validate, document, execute and
architecture and machine language of a simple
debug the solution using the Java programming
microprocessor and the different levels of
system.
abstraction that mediate between the machine
and the algorithmic problem solving level and

CLASS XI

There will be two papers in the subject: bases using English or pseudo code. These
algorithms are also good examples for defining
Paper I: Theory - 3 hours70 marks
different functions in a class modelling numbers
Paper II: Practical - 3 hours30 marks (when programming is discussed). For addition
PAPER I THEORY 70 MARKS and subtraction use the analogy with decimal
numbers, emphasize how carry works (this will be
Paper 1 shall be of 3 hours duration and be divided useful later when binary adders are discussed).
into two parts.
2. Encodings
Part I (20 marks): This part will consist of
compulsory short answer questions, testing (a) Binary encodings for integers and real
knowledge, application and skills relating to the entire numbers using a finite number of bits (sign-
syllabus. magnitude, twos complement, mantissa-
Part II (50 marks): This part will be divided into exponent notation). Basic operations on
three Sections, A, B and C. Candidates will be integers and floating point numbers.
required to answer two questions out of three from Limitations of finite representations.
Section A (each carrying 10 marks) and two questions Signed, unsigned numbers, least and most
out of three from Sections B (each carrying 10 marks)
significant bits. Sign-magnitude
and two questions out of three from Section C
(each carrying 5 marks). Therefore, a total of six representation and its shortcomings (two
questions are to be answered in Part II. representations for 0, addition requires extra
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-
exponent representation, binary point (discuss
Representation of numbers in different bases and trade-off between size of mantissa and
interconversion between them (e.g. binary, octal,
exponent). Single and double precision.
decimal, hexadecimal). Addition and subtraction
operations for numbers in different bases. Arithmetic operations with floating point
numbers. Properties of finite representation:
Introduce the positional system of representing overflow, underflow, lack of associativity
numbers and the concept of a base. Discuss the (demonstrate this through actual programs).
conversion of representations between different

233
(b) Characters and their encodings (e.g. ASCII, 5. Propositional logic, hardware implementation,
Unicode). arithmetic operations

Discuss the limitations of the ASCII code in (a) Propositional logic, well formed formulae,
truth values and interpretation of well formed
representing characters of other languages. formulae, truth tables.
Discuss the Unicode representation for the
local language. Java uses Unicode, so strings Propositional variables; the common logical
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 of a well-formed formula (wff); representation
for Latin (i.e. English) character strings may of simple word problems as wff (this can be
be done. More details on Unicode are used for motivation); the values true and
available at www.unicode.org. false; interpretation of a wff; truth tables;
satisfiable, unsatisfiable and valid formulae.
3. High level structure of computer (b) Logic and hardware, basic gates (AND, NOT,
OR) and their universality, other gates
Block diagram of a computer system with details (NAND, NOR, XOR); inverter, half adder,
of (i) function of each block and full adder.
(ii) interconnectivity and data and control flow Show how the logic in (a) above can be
between the various blocks realized in hardware in the form of gates.
These gates can then be combined to
Develop the diagram by successive refinement of
implement the basic operations for arithmetic.
blocks till all the following have been covered: Tie up with the arithmetic operations on
ALU, RAM, cache, the buses (modern computers integers discussed earlier in 2 (a).
have multiple buses), disk (disk controller and
what it does), input/output ports (serial, parallel, 6. Memory
USB, network, modem, line-in, line-out etc.), Memory organization and access; parity; memory
devices that can be attached to these ports hierarchy - cache, primary memory, secondary
(e.g keyboard, mouse, monitor, CDROM, DVD, memory.
audio input/output devices, printer, etc.). Clearly The access time differences between the different
describe the connectivity and the flow of data and kinds of memory; size differences; locality of
control signals. reference and cache memory.

4. Basic architecture of a simple processor and its 7. System and other software
instruction set Boot process. Operating system as resource
manager, command processing, files, directories
Simple Hypothetical Computer. and file system. Commonly available programs
The simple hypothetical computer abbreviated as (editors, compilers, interpreters, word processors,
spread sheets etc.).
(SHC) is meant to introduce the basic structure of
a processor in particular registers, basic Boot process step-by-step from power on till the
instruction set, structure of an instruction, prompt. In OS discuss: (i) all the resources
(processor, memory, i/o) that need to be managed
program counter addressing modes (immediate,
in a computer; (ii) what is meant by managing
direct, register, register-indirect). Simple these resources. Logical structure of data storage
programs should be written in the SHC on disk using logical disks, hierarchical
instruction set (e.g. max./min. of set of nos.) directories and files. Distinguish between
interpreters and compilers. In particular discuss
the javac and java programs.

234
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
be 1.5 or later. For programming, the students can use the object. Class as mechanism for user defined
any text editor and the javac and java programs or any types. Changing types through user defined
development environment: for example, BlueJ, casting and automatic type coercion for some
primitive types.
Eclipse, NetBeans etc. BlueJ is strongly recommended
for its simplicity, ease of use and because it is very Ideally, everything should be a class; primitive
well suited for an objects first approach. types are defined for efficiency reasons; each
primitive type has a corresponding wrapper class.
8. Introduction to algorithmic problem solving Classes as user defined types. In some cases types
are changed by automatic coercion or casting
using Java
e.g. mixed type expressions. However, casting in
Note that topics 9 to 13 will get introduced almost general is not a good idea and should be avoided,
simultaneously when classes and their definitions if possible.
are introduced.
11. Variables, expressions
9. Objects
Variables as names for values; expressions
(a) Objects as data (attributes) + behaviour (arithmetic and logical) and their evaluation
(methods or functions); object as an instance (operators, associativity, precedence). Assignment
of a class. Constructors. operation; difference between left hand side and
right hand side of assignment.
Difference between object and class should be
Variables denote values; variables are already
made very clear. BlueJ (www.bluej.org) and defined as attributes in classes; variables have
Greenfoot (www.greenfoot.org) can be used types that constrain the values it can denote.
for this purpose. Constructor as a special kind Difference between variables denoting primitive
of function; the new operator; multiple values and object values variables denoting
constructors with different argument objects are references to those objects. The
assignment operator = is special. The variable on
structures; constructor returns a reference to
the lhs of = denotes the memory location while the
the object. same variable on the rhs denotes the contents of
(b) Analysis of some real world programming the location e.g. i=i+2.
examples in terms of objects and classes.
12. Statements, scope
Use simple examples like a calculator, date, Statements; conditional (if, if-then-else, switch-
number etc. to illustrate how they can be break, ?: ternary operator), looping (for, while-do,
treated as objects that behave in certain well- do-while, continue, break); grouping statements in
defined ways and how the interface provides a blocks, scope and visibility of variables.
way to access behaviour. Illustrate behaviour Describe the semantics of the conditional and
changes by adding new functions, deleting old looping statements in detail. Evaluation of the
functions or modifying existing functions. condition in conditional statements (esp.
difference between || and | and && and &).
Emphasize fall through in switch statement. Many
small examples should be done to illustrate
control structures. Printing different kinds of
patterns for looping is instructive. When number
235
of iterations are known in advance use the for 14. Arrays, strings
loop otherwise the while-do or do-while loop.
(a) Structured data types arrays (single and
Express one loop construct using the others. For
multi-dimensional), strings. Example
e.g.:
algorithms that use structured data types (e.g.
for (<init>; <test>; <inc>) <stmt>; is equivalent searching, finding maximum/minimum,
to: sorting techniques, solving systems of linear
equations, substring, concatenation, length,
(i) Using while
access to char in string, etc.).
<init>; while <test> {<stmt>; <inc> }
Storing many data elements of the same type
(ii) Using do-while requires structured data types like arrays.
<init>; if !<test> do <stmt>; <inc> while Access in arrays is constant time and does not
<test>; depend on the number of elements. Sorting
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,
13. Functions replacement, index of operations).
Functions/methods (as abstractions for complex (b) Basic concept of a virtual machine; Java
user defined operations on objects), functions as virtual machine; compilation and execution of
mechanisms for side effects; formal arguments Java programs (the javac and java programs).
and actual arguments in functions; different
behaviour of primitive and object arguments. The JVM is a machine but built as a program
Static functions and variables. The this variable. and not through hardware. Therefore it is
Examples of algorithmic problem solving using called a virtual machine. To run, JVM
functions (various number theoretic problems, machine language programs require an
finding roots of algebraic equations). interpreter (the java program). The advantage
is that such JVM machine language programs
Functions are like complex operations where the (.class files) are portable and can run on any
object is implicitly the first argument. Variable machine that has the java program.
this denotes the current object. Functions (c) Compile time and run time errors; basic
typically return values, they may also cause side- concept of an exception, the Exception class,
effects (e.g. change attribute values of objects) catch and throw.
typically functions that are only supposed to cause
Differentiate between compile time and run
side-effects return void (e.g. Set functions). Java time errors. Run time errors crash the
passes argument by value. Illustrate the difference program. Recovery is possible by the use of
between primitive values and object values as exceptions. Explain how an exception object
arguments (changes made inside functions persist is created and passed up until a matching
after the call for object values). Static definitions catch is found. This behaviour is different
as class variables and class functions visible and from the one where a value is returned by a
shared by all instances. Need for static functions deeply nested function call. It is enough to
and variables. Introduce the main method discuss the Exception class. Sub-classes of
Exception can be discussed after inheritance
needed to begin execution.
has been done in Class XII.

236
SECTION C boolean isEmpty()
15. Elementary data structures and associated Object top()
algorithms, basic input/output Then, for example the LIFO property can be
(a) Class as a contract; separating implementation expressed by (assume s is a stack):
from interface; encapsulation; private and if s.push(o); o1=pop() then o o1
public.
What the rule says is: if o is pushed on the
Class is the basic reusable unit. Its function stack s and then it is popped and o1 is the
prototypes (i.e. the interface) work as a visible object obtained then o, o1 are identical.
contract with the outside world since others
will use these functions in their programs. Another useful property is:
This leads to encapsulation (i.e. hiding if s.isEmpty() == true then s.pop() = ERROR
implementation information) which in turn
leads to the use of private and public for It says that popping an empty stack gives
realizing encapsulation. ERROR.

(b) Interfaces in Java; implementing interfaces Similarly, several other properties can also be
through a class; interfaces for user defined specified. It is important to emphasize the
implementation of behaviour. behavioural rules or properties of a data
structure since any implementation must
Motivation for interface: often when creating guarantee that the rules hold.
reusable classes some parts of the exact
implementation can only be provided by the Some simple algorithms that use the data
final end user. For example in a class that structures:
sorts records of different types the exact i) For stack: parentheses matching, tower of
comparison operation can only be provided Hanoi, nested function calls; solving a
by the end user. Since only he/she knows maze.
which field(s) will be used for doing the
ii) For queue: scheduling processes, printers,
comparison and whether sorting should be in
jobs in a machine shop.
ascending or descending order be given by
the user of the class. (d) Basic input/output using Scanner and Printer
classes from JDK; files and their
Emphasize the difference between the Java
representation using the File class, file
language construct interface and the word
input/output; input/output exceptions. Tokens
interface often used to describe the set of
in an input stream, concept of whitespace,
function prototypes of a class.
extracting tokens from an input stream
(c) Basic data structures (stack, queue, dequeue); (StringTokenizer class).
implementation directly through classes;
The Scanner class can be used for input of
definition through an interface and multiple
various types of data (e.g. int, float, char etc.)
implementations by implementing the
from the standard input stream or a file input
interface. Basic algorithms and programs
stream. The File class is used model file
using the above data 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
properties. The behaviour or properties can output using these classes should be covered.
usually be expressed formally using equations
Discuss the concept of a token (a delimited
or some kind of logical formulae. Consider
continuous stream of characters that is
for e.g. a stack with operations defined as
meaningful in the application program e.g.
follows:
words in a sentence where the delimiter is the
void push(Object o) blank character). This naturally leads to the
Object pop() idea of delimiters and in particular

237
whitespace and user defined characters as (f) Concrete computational complexity; concept
delimiters. As an example show how the of input size; estimating complexity in terms
StringTokenizer class allows one to extract a of functions; importance of dominant term;
sequence of tokens from a string with user best, average and worst case.
defined delimiters.
Points to be given particular emphasis:
(e) Concept of recursion, simple recursive (i) Algorithms are usually compared along
functions (e.g. factorial, GCD, binary search, two dimensions amount of space (that is
conversion of representations of numbers memory) used and the time taken. Of the
between different bases). two the time taken is usually considered
Many problems can be solved very elegantly the more important. The motivation to
by observing that the solution can be study time complexity is to compare
composed of solutions to smaller versions of different algorithms and use the one that is
the same problem with the base version the most efficient in a particular situation.
having a known simple solution. Recursion (ii) Actual run time on a particular computer
can be initially motivated by using recursive is not a good basis for comparison since it
equations to define certain functions. These depends heavily on the speed of the
definitions are fairly obvious and are easy to computer, the total amount of RAM in the
understand. The definitions can be directly computer, the OS running on the system
converted to a program. Emphasize that any and the quality of the compiler used. So
recursion must have a base case. Otherwise, we need a more abstract way to compare
the computation can go into an infinite loop. the time complexity of algorithms.
Illustrate this by removing the base case and (iii) This is done by trying to approximate the
running the program. Examples: number of operations done by each
(i) Definition of factorial: algorithm as a function of the size of the
input. In most programs the loops are
factorial(0) = 1 //base case important in deciding the complexity. For
factorial(n) = n * factorial(n-1) example in bubble sort there are two
nested loops and in the worst case the time
(ii) Definition of GCD: taken will be proportional to n(n-1) where
gcd(m, n) = n is the number of elements to be sorted.
Similarly, in linear search in the worst
if (m==n) then n //base case case the target has to be compared with
all the elements so time taken will be
else if (m>n) then gcd(m-n, n)
proportional to n where n is the number of
else gcd(m, n-m) elements in the search set.
(iii) Definition of Fibonacci numbers: (iv) In most algorithms the actual complexity
for a particular input can vary. For
fib(0) = 1 //base case example in search the number of
fib(1) = 1 //base case comparisons can vary from 1 to n. This
means we need to study the best, worst
fib(n) = fib(n-1)+ fib(n-2) and average cases. Comparisons are
The tower of Hanoi is a very good example of usually made taking the worst case.
how recursion gives a very simple and elegant Average cases are harder to estimate
solution where as non-recursive solutions are since it depends on how the data is
quite complex. Discuss the use of a stack to distributed. For example in search, if the
keep track of function calls. The stack can elements are uniformly distributed it will
also be used to solve the tower of Hanoi take on the average n/2 comparisons when
problem non-recursively. the average is taken over a statistically
significant number of instances.

238
(v) Comparisons are normally made for large PAPER II PRACTICAL 30 MARKS
values of the input size. This means that
This paper of three hours duration will be evaluated
the dominant term in the function is the
internally by the school.
important term. For example if we are
looking at bubble sort and see that time The paper shall consist of three programming
taken can be estimated as: a*n2 +b*n + c problems from which a candidate has to attempt any
where n is the number of elements to be one. The practical consists of the two parts:
sorted and a, b, c are constants then for (1) Planning Session
large n the dominant term is clearly n2 and
we can in effect ignore the other two (2) Examination Session
terms. The total time to be spent on the Planning session and
16. Implementation of algorithms to solve the Examination session is three hours.
problems A maximum of 90 minutes is permitted for the
Planning session and 90 minutes for the Examination
The students are required to do lab assignments in
the computer lab concurrently with the lectures. session. Candidates are to be permitted to proceed
Programming assignments should be done such to the Examination Session only after the
that each major topic is covered in at least one 90 minutes of the Planning Session are over.
assignment. Assignment problems should be Planning Session
designed so that they are non-trivial and make the
student do algorithm design, address correctness The candidates will be required to prepare an
issues, implement and execute the algorithm in algorithm and a hand written Java program to solve
Java and debug where necessary. the problem.
Self explanatory. Examination Session
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
(a) Intellectual property and corresponding laws candidates will be required to key-in and execute the
and rights, software as intellectual property. Java program on seen and unseen inputs individually
(b) Software copyright and patents and the on the Computer and show execution to the examiner.
difference between the two; trademarks; A printout of the program listing, including output
software licensing and piracy. results should be attached to the answer script
containing the algorithm and handwritten program.
(c) Free software foundation and its position on This should be returned to the examiner. The program
software, open source software, various types
should be sufficiently documented so that the
of licensing (e.g. GPL, BSD).
algorithm, representation and development process is
(d) Privacy, email etiquette, spam, security issues, clear from reading the program. Large differences
phising. between the planned program and the printout will
Social impact and ethical issues should be result in loss of marks.
discussed and debated in class. The important Teachers should maintain a record of all the
thing is for students to realise that these are assignments done as part of the practical work through
complex issues and there are multiple points of the year and give it due credit at the time of
view on many of them and there is no single cumulative evaluation at the end of the year. Students
correct or right view.
are expected to do a minimum of twenty assignments
for the year.

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

240
CLASS XII

There will be two papers in the subject: inverse and contra positive. Chain
Paper I: Theory - 3 hours.70 marks rule(Modus ponen).
ppp ppp
Paper II: Practical - 3 hours.30 marks
p true true p true p
PAPER I THEORY 70 MARKS p false p p false false
Paper 1 shall be of 3 hours duration and be divided p (p q) p p (p q) p
into two parts. The equivalence rules can be used to simplify
Part I (20 marks): This part will consist of propositional wffs, for example:
compulsory short answer questions, testing 1) (p q) (p r) to p (q r)
knowledge, application and skills relating to the entire
syllabus. 2) ((p q) p) q to true
etc.
Part II (50 marks): This part will be divided into
three Sections, A, B and C. Candidates will be (b) Binary valued quantities; basic postulates of
required to answer two questions out of three from Boolean algebra; operations AND, OR and
Section A (each carrying 10 marks) and two questions NOT; truth tables.
out of three from Sections B (each carrying 10 marks) (c) Basic theorems of Boolean algebra
and two questions out of three from Section C (e.g. Duality, idempotence, commutativity,
(each carrying 5 marks). Therefore, a total of six associativity, distributivity, operations with 0
questions are to be answered in Part II and 1, complements, absorption, involution);
SECTION A De Morgans theorem and its applications;
reducing Boolean expressions to sum of
1. Boolean Algebra
products and product of sums forms;
(a) Propositional logic, well formed formulae, Karnaugh maps (up to four variables).
truth values and interpretation of well formed
Verify the laws of boolean algebra using truth
formulae (wff), truth tables, satisfiable,
tables. Inputs, outputs for circuits like half
unsatisfiable and valid formulae. Equivalence
and full adders, majority circuit etc., SOP and
laws and their use in simplifying wffs.
POS representation; Maxterms & Minterms,
Propositional variables; the common logical Canonical and Cardinal representation,
connectives (~ (not)(negation), reduction using Karnaugh maps and boolean
(and)(conjunction), (or)(disjunction), algebra.
(implication), (biconditional); definition of
a well-formed formula (wff); representation of 2. Computer Hardware
simple word problems as wff (this can be used (a) Elementary logic gates (NOT, AND, OR,
for motivation); the values true and false; NAND, NOR, XOR, XNOR) and their use in
interpretation of a wff; truth tables; circuits.
satisfiable, unsatisfiable and valid formulae.
(b) Applications of Boolean algebra and logic
Equivalence laws: commutativity of , ; gates to half adders, full adders, encoders,
associativity of , ; distributivity; de decoders, multiplexers, NAND, NOR as
Morgans laws; law of implication (p q universal gates.
~p q); law of biconditional ((p q)
(p q) (q p)); identity (p p); law of Show the correspondence between boolean
negation (~ (~p) p); law of excluded middle functions and the corresponding switching
(p ~p true); law of contradiction (p~p circuits or gates. Show that NAND and NOR gates
false); tautology and contingency are universal by converting some circuits to
simplification rules for , . Converse, purely NAND or NOR gates.

241
SECTION B (b) Analysis of some real world programming
The programming element in the syllabus (Sections B examples in terms of objects and classes.
and C) is aimed at algorithmic problem solving and Use simple examples like a calculator, date,
not merely rote learning of Java syntax. The Java number, etc. to illustrate how they can be
version used should be 1.5 or later. For programming, treated as objects that behave in certain well-
the students can use any text editor and the javac and defined ways and how the interface provides a
java programs or any development environment: for way to access behaviour. Illustrate behaviour
example, BlueJ, Eclipse, NetBeans etc. BlueJ is changes by adding new functions, deleting old
strongly recommended for its simplicity, ease of use functions or modifying existing functions.
and because it is very well suited for an objects first
approach. 6. Primitive values, wrapper classes, types and
casting
3. Implementation of algorithms to solve
Primitive values and types: int, short, long, float,
problems
double, boolean, char. Corresponding wrapper
The students are required to do lab assignments in classes for each primitive type. Class as type of
the computer lab concurrently with the lectures. the object. Class as mechanism for user defined
Programming assignments should be done such types. Changing types through user defined
that each major topic is covered in at least one casting and automatic type coercion for some
assignment. Assignment problems should be primitive types.
designed so that they are non-trivial and make the
student do algorithm design, address correctness Ideally, everything should be a class; primitive
issues, implement and execute the algorithm in types are defined for efficiency reasons; each
Java and debug where necessary. primitive type has a corresponding wrapper class.
Classes as user defined types. In some cases types
Self explanatory. are changed by automatic coercion or casting
e.g. mixed type expressions. However, casting in
4. Programming in Java (Review of Class XI
general is not a good idea and should be avoided,
Sections B and C)
if possible.
Note that items 4 to 8 will get introduced almost
simultaneously when classes and their definitions 7. Variables, expressions
are introduced. Variables as names for values; expressions
(arithmetic and logical) and their evaluation
5. Objects
(operators, associativity, precedence). Assignment
(a) Objects as data (attributes) + behaviour operation; difference between left hand side and
(methods or functions); object as an instance right hand side of assignment.
of a class. Constructors.
Variables denote values; variables are already
Difference between object and class should be defined as attributes in classes; variables have
made very clear. BlueJ (www.bluej.org) and types that constrain the values it can denote.
Greenfoot (www.greenfoot.org) can be Difference between variables denoting primitive
profitably used for this purpose. Constructor values and object values variables denoting
as a special kind of function; the new objects are references to those objects. The
operator; multiple constructors with different assignment operator = is special. The variable on
argument structures; constructor returns a the lhs of = denotes the memory location while the
reference to the object. same variable on the rhs denotes the contents of
the location e.g. i=i+2.

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

243
deeply nested function call. It is enough to meaningful in the application program e.g.
discuss the Exception class. Sub-classes of words in a sentence where the delimiter is the
Exception can be discussed after inheritance blank character). This naturally leads to the
has been done in Class XII. idea of delimiters and in particular
(d) Class as a contract; separating implementation whitespace and user defined characters as
from interface; encapsulation; private and delimiters. As an example show how the
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 a visible 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
(e) Interfaces in Java; implementing interfaces by observing that the solution can be
through a class; interfaces for user defined composed of solutions to smaller versions of
implementation of behaviour. the same problem with the base version
Motivation for interface: often when creating having a known simple solution. Recursion
reusable classes, some parts of the exact can be initially motivated by using recursive
implementation can only be provided by the equations to define certain functions. These
final end user. For example, in a class that definitions are fairly obvious and are easy to
sorts records of different types the exact understand. The definitions can be directly
comparison operation can only be provided converted to a program. Emphasize that any
by the end user. Since only he/she knows recursion must have a base case. Otherwise,
which field(s) will be used for doing the the computation can go into an infinite loop.
comparison and whether sorting should be in Illustrate this by removing the base case and
ascending or descending order be given by running the program. Examples:
the 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 factorial(n) = n * factorial(n-1)
interface often used to describe the set of (ii) Definition of GCD:
function prototypes of a class.
gcd(m, n) =
(e) Basic input/output using Scanner and Printer
classes from JDK; files and their if (m==n) then n //base case
representation using the File class, file else if (m>n) then gcd(m-n, n)
input/output; input/output exceptions. Tokens else gcd(m, n-m)
in an input stream, concept of whitespace, (iii) Definition of Fibonacci numbers:
extracting tokens from an input stream
fib(0) = 1 //base case
(StringTokenizer class).
fib(1) = 1 //base case
The Scanner class can be used for input of
various types of data (e.g. int, float, char etc.) fib(n) = fib(n-1)+ fib(n-2)
from the standard input stream or a file input The tower of Hanoi is a very good example of
stream. The File class is used model file how recursion gives a very simple and elegant
objects in the underlying system in an OS solution where as non-recursive solutions are
independent manner. Similarly, the Printer quite complex. Discuss the use of a stack to
class handles output. Only basic input and keep track of function calls. A stack can also
output using these classes should be covered. be used to solve the tower of Hanoi problem
Discuss the concept of a token (a delimited non-recursively. Merge sort and Quick sort on
continuous stream of characters that is arrays.

244
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
Inheritance; base and derived classes; member interface. Basic algorithms and programs
access in derived classes; redefinition of variables using the above 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 or some kind of logical formulae. Consider
by extending it. for e.g. a stack with operations defined as
follows:
- inheritance should not normally be used just
to reuse some functions defined in a class but void push(Object o)
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()
Object top()
- Allows one to implement operations at the
highest relevant level of abstraction. Then, for example the LIFO property can be
expressed by (assume s is a stack):
- Freezes the interface in the form of abstract
classes with abstract functions that can be if s.push(o); o1=pop() then o o1
extended by the concrete implementing What the rule says is: if o is pushed on the
classes. For example, an abstract class Shape stack s and then it is popped and o1 is the
can have an abstract function draw that is object obtained then o, o1 are identical.
implemented differently in the sub-classes like Another useful property is:
Circle, Quadrilateral etc.
if s.isEmpty() == true then s.pop() = ERROR
- how the exact function call at run time It says that popping an empty stack gives
depends 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
Hanoi, nested function calls; solving a
the two draw function invocations on s1, s2
maze.
invoke different draw functions depending on
the type of objects referenced by s1 and s2 (ii) For queue: scheduling processes,
respectively. printers, jobs in a machine shop.

245
(b) Recursive data structures: single linked list (iii) This is done by trying to approximate the
(Algorithm and programming), binary trees, number of operations done by each algorithm
tree traversals (Conceptual) as a function of the size of the input. In most
programs the loops are important in deciding
Data structures should be defined as
the complexity. For example in bubble sort
abstract data types with a well defined
there are two nested loops and in the worst
interface (it is instructive to define them
case the time taken will be proportional to
using the Java interface construct) see the
n(n-1) where n is the number of elements to be
comments in (a) above. Emphasize that
sorted. Similarly, in linear search in the worst
algorithms for recursive data structures are
case the target has to be compared with all
themselves recursive and that algorithms are
the elements so time taken will be
usually the simplest and most elegant. The
proportional to n where n is the number of
following should be covered for each data
elements in the search set.
structure:
(iv) In most algorithms the actual complexity for a
Linked List (single): insertion, deletion,
particular input can vary. For example in
reversal, extracting an element or a sublist,
search the number of comparisons can vary
checking emptiness.
from 1 to n. This means we need to study the
Binary trees: apart from the definition the best, worst and average cases. Comparisons
following concepts should be covered: are usually made taking the worst case.
external and internal nodes, height, level, Average cases are harder to estimate since it
size, degree, completeness, balancing, depends on how the data is distributed. For
Traversals (pre, post and in-order). example in search, if the elements are
uniformly distributed it will take on the
13. Complexity and big O notation 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
of example algorithms using the big O notation term. For example if we are looking at bubble
(e.g. Various searching and sorting algorithms, sort and see that time taken can be estimated
algorithm for solution of linear equations etc.). as: a*n2 +b*n + c where n is the number of
Points to be given particular emphasis: elements to be sorted and a, b, c are constants
then for large n the dominant term is clearly
(i) Algorithms are usually compared along two n2 and we can, in effect, ignore the other two
dimensions amount of space (that is terms.
memory) used and the time taken. Of the two
the time taken is usually considered the more All the above motivates the big O notation. Let
important. The motivation to study time f(n), g(n) be positive functions, then f(n) is said to
complexity is to compare different algorithms be O(g(n)) if there exists constants c, n0 such that
and use the one that is the most efficient in a f(x) c*g(n) whenever n>n0. What this means is
particular situation. that g(n) asymptotically dominates f(n).
Expressing time complexity using the big O
(ii) Actual run time on a particular computer is notation gives us an abstract basis for comparison
not a good basis for comparison since it and frees us from bothering about constants. So
depends heavily on the speed of the computer, the estimated time complexity a*n2+b*n+c is
the total amount of RAM in the computer, the O(n2).
OS running on the system and the quality of
the compiler used. So we need a more Analyse the big O complexity of the algorithms
abstract way to compare the time complexity pertaining to the data structures in 11 (a) and (b)
of algorithms. above.

246
PAPER II PRACTICAL 30 MARKS EVALUATION:
This paper of three hours duration will be evaluated Marks (out of a total of 30) should be distributed as
by the Visiting Examiner appointed locally and given below:
approved by the Council.
Continuous Evaluation
The paper shall consist of three programming
Candidates will be required to submit a work file
problems from which a candidate has to attempt any
containing the practical work related to programming
one. The practical consists of the two parts:
assignments done during the year.
1. Planning Session
Programming assignments done throughout the year
2. Examination Session (Internal evaluation) - 5 marks
The total time to be spent on the Planning session and Programming assignments done throughout the year
the Examination session is three hours. (Visiting Examiner) - 5 marks
A maximum of 90 minutes is permitted for the
Terminal Evaluation
Planning session and 90 minutes for the Examination
session. Candidates are to be permitted to proceed Solution to programming problem on the computer
to the Examination Session only after the - 17 marks
90 minutes of the Planning Session are over.
(Marks should be given for choice of algorithm and
Planning Session implementation strategy, documentation, correct output
on known inputs mentioned in the question paper,
The candidates will be required to prepare an
algorithm and a hand written Java program to solve correct output for unknown inputs available only to the
the problem. examiner.)

Examination Session Viva-voce - 3 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 documentation, correctness, alternative algorithms or
on 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 EQUIPMENT
clear from reading the program. Large differences
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
time available is used for programming.
Teachers should maintain a record of all the
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:

247
The Facilities: The computers should have a minimum of 512
MB (1 GB preferred) RAM and a PIV or higher
A lecture cum demonstration room with a processor. The basic requirement is that it should
MULTIMEDIA PROJECTOR/ an LCD and run the operating system and Java programming
O.H.P. attached to the computer. system (Java compiler, Java runtime environment,
A white board with white board markers should Java development environment) at acceptable
speeds.
be available.
Good Quality printers.
A fully equipped Computer Laboratory that
allows one computer per student. Software:

Internet connection for accessing the World Wide Any suitable Operating System can be used.
Web and email facility. JDK 6 or later.
Documentation for the JDK version being used.
A suitable text editor. A development
environment with a debugger is preferred (e.g.
BlueJ, Eclipse, NetBeans). BlueJ is recommended
for its ease of use and simplicity.

248
SAMPLE TABLE FOR PRACTICAL WORK
Assessment of Assessment of the Practical Examination TOTAL
Practical File (To be evaluated by the Visiting Examiner only) MARKS (Total
Unique
Internal Visiting Algorithm Java Documentation Hard Copy Output Viva- Marks are to be
Identification
Evaluation Examiner Program (printout) Voce added and
Number
entered by the
S. No. (Unique ID)/
Visiting
Index Number
Examiner)
of the
candidate
30 Marks
5 Marks 5 Marks 3 Marks 5 Marks 2 Marks 2 Marks 5 Marks 3 Marks
1.

2.

3.

4.

5.

6.

7.

8.

9.

10.

Name of the Visiting Examiner:_________________________________

Signature: _______________________________

Date:___________________________________

249

Vous aimerez peut-être aussi