Sei sulla pagina 1di 16

COMPUTER SCIE CE (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: algorithms are also good examples for defining
Paper I: Theory - 3 hours ….100 marks different functions in a class modelling numbers
(when programming is discussed). For addition
Paper II: Practical - 3 hours ….100 marks and subtraction use the analogy with decimal
numbers, emphasize how carry works (this will be
PAPER I -THEORY useful later when binary adders are discussed).
Paper 1 shall be of 3 hours duration and be divided 2. Encodings
into two parts.
(a) Binary encodings for integers and real
Part I (30 marks): This part will consist of numbers using a finite number of bits (sign-
compulsory short answer questions, testing magnitude, twos complement, mantissa-
knowledge, application and skills relating to the entire exponent notation). Basic operations on
syllabus.
integers and floating point numbers.
Part II (70 marks): This part will be divided into Limitations of finite representations.
three Sections, A, B and C. Candidates are required to
answer three questions out of four from Section A and Signed, unsigned numbers, least and most
two questions out of three in each of the Sections B significant bits. Sign-magnitude
and C. Each question in this part shall carry 10 representation and its shortcomings (two
marks. representations for 0, addition requires extra
SECTIO A step); twos-complement representation.
Operations (arithmetic, logical, shift), discuss
Basic Computer Hardware and Software
the basic algorithms used for the arithmetic
1. umbers operations. Floating point representation:
normalized scientific notation, mantissa-
Representation of numbers in different bases and
exponent representation, binary point (discuss
interconversion between them (e.g. binary, octal,
decimal, hexadecimal). Addition and subtraction trade-off between size of mantissa and
operations for numbers in different bases. exponent). Single and double precision.
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
bases using English or pseudo code. These (demonstrate this through actual programs).

175
(b) Characters and their encodings (e.g. ASCII, (iii) addressing modes (immediate, direct,
Unicode). register, register-indirect); (iv) Instruction set
Discuss the limitations of the ASCII code in (data transfer, arithmetic, logical, conditional
representing characters of other languages. and transfer of control, input/output).
Discuss the Unicode representation for the Interrupts are not included. Since many free
local language. Java uses Unicode, so strings simulators are available, the students should
in the local language can be used (they can actually write, run and observe what happens
be displayed if fonts are available) – a simple when a machine language program runs.
table lookup for local language equivalents Example, machine and assembly language
for Latin (i.e. English) character strings may programs: evaluating simple expressions,
be done. More details on Unicode are adding a sequence of numbers, finding the
available at www.unicode.org. minimum and/or maximum of a sequence of
numbers, using finding the minimum /
3. High level structure of computer maximum to do sorting of a sequence of
Block diagram of a computer system with details numbers. In particular, discuss how the stack
of (i) function of each block and can be used for calling and returning from
(ii) interconnectivity and data and control flow subprograms. Emphasize how data and
between the various blocks. program look alike and depend on the
Develop the diagram by successive refinement of interpretation used.
blocks till all the following have been covered: (b) Assembly language of 8085, simple assembly
ALU, RAM, cache, the buses (modern computers language programs, assembly process and
have multiple buses), disk (disk controller and assembler.
what it does), input/output ports (serial, parallel,
USB, network, modem, line-in, line-out etc.), Discussion of the assembly language should
devices that can be attached to these ports (e.g be done along with the instruction set
keyboard, mouse, monitor, CDROM, DVD, audio (previous section). Emphasize how it is easier
input/output devices, printer, etc.). Clearly to program in assembly language than in
describe the connectivity and the flow of data and machine language. Assembly process: symbol
control signals. table and its use in translating a program to
machine language. Macros are not included.
4. Basic architecture of typical simple processor
and its assembly language 5. Propositional logic, hardware implementation,
(a) Basic architecture of the 8085 arithmetic operations
microprocessor. Instruction set, addresses, (a) Propositional logic, well formed formulae,
addressing modes, simple machine language
truth values and interpretation of well formed
programs using the different addressing
formulae, truth tables.
modes, execution of machine language
programs, input and output. Propositional variables; the common logical
connectives (~ (not), ∧ (and), ∨ (or),
The idea here is to discuss a concrete
⇒ (implication), ⇔ (equivalence)); definition
microprocessor instead of an abstract
of a well-formed formula (wff); representation
computer thus giving students a clearer
of simple word problems as wff (this can be
understanding of how a typical computer
used for motivation); the values true and
works. The aim is not to know all details of
false; interpretation of a wff; truth tables;
the 8085 microprocessor. The basic features
satisfiable, unsatisfiable and valid formulae.
that must be covered are: (i) Structure of
memory; (ii) registers - A-register (b) Logic and hardware, basic gates (AND, NOT,
(accumulator), general (B, C, D, E, H, L in OR) and their universality, other gates
8-bit individual and paired 16-bit modes), (NAND, NOR, XOR); inverter, half adder,
program counter, stack pointer, flag; full adder.
176
Show how the logic in (a) above can be 8. Introduction to algorithmic problem solving
realized in hardware in the form of gates. using Java
These gates can then be combined to @ote that topics 9 to 13 will get introduced almost
implement the basic operations for arithmetic. simultaneously when classes and their definitions
Tie up with the arithmetic operations on are introduced.
integers discussed earlier in 2 (a).
9. Objects
6. Memory
(a) Objects as data (attributes) + behaviour
(a) Memory - construction of a memory bit using (methods or functions); object as an instance
a flip-flop, D-flip-flop and its use in of a class. Constructors.
constructing registers.
Difference between object and class should be
(b) Memory organization and access; parity; made very clear. BlueJ (www.bluej.org) and
memory hierarchy - cache, primary memory, Greenfoot (www.greenfoot.org) can be used
secondary memory. for this purpose. Constructor as a special kind
The access time differences between the of function; the new operator; multiple
different kinds of memory; size differences; constructors with different argument
structures; constructor returns a reference to
locality of reference and cache memory.
the object.
7. System and other software (b) Analysis of some real world programming
examples in terms of objects and classes.
Boot process. Operating system as resource
manager, command processing, files, directories Use simple examples like a calculator, date,
and file system. Commonly available programs number etc. to illustrate how they can be
(editors, compilers, interpreters, word processors, treated as objects that behave in certain well-
spread sheets etc.). defined ways and how the interface provides a
way to access behaviour. Illustrate behaviour
Boot process step-by-step from power on till the changes by adding new functions, deleting old
prompt. In OS discuss: (i) all the resources functions or modifying existing functions.
(processor, memory, i/o) that need to be managed
in a computer; (ii) what is meant by managing 10. Primitive values, wrapper classes, types and
these resources. Logical structure of data storage casting
on disk using logical disks, hierarchical
directories and files. Distinguish between Primitive values and types: int, short, long, float,
interpreters and compilers. In particular discuss double, boolean, char. Corresponding wrapper
the javac and java programs. classes for each primitive type. Class as type of
the object. Class as mechanism for user defined
SECTIO B types. Changing types through user defined
casting and automatic type coercion for some
The programming element in the syllabus is aimed at primitive types.
algorithmic problem solving and not merely rote Ideally, everything should be a class; primitive
learning of Java syntax. The Java version used should types are defined for efficiency reasons; each
be 1.5 or later. For programming, the students can use primitive type has a corresponding wrapper class.
any text editor and the javac and java programs or any Classes as user defined types. In some cases types
development environment: for example, BlueJ, are changed by automatic coercion or casting –
Eclipse, NetBeans etc. BlueJ is strongly recommended e.g. mixed type expressions. However, casting in
for its simplicity, ease of use and because it is very general is not a good idea and should be avoided,
well suited for an ‘objects first’ approach. if possible.

177
11. Variables, expressions 13. Functions
Variables as names for values; expressions Functions/methods (as abstractions for complex
(arithmetic and logical) and their evaluation user defined operations on objects), functions as
(operators, associativity, precedence). Assignment mechanisms for side effects; formal arguments
operation; difference between left hand side and and actual arguments in functions; different
right hand side of assignment. behaviour of primitive and object arguments.
Static functions and variables. The this variable.
Variables denote values; variables are already
Examples of algorithmic problem solving using
defined as attributes in classes; variables have
functions (various number theoretic problems,
types that constrain the values it can denote.
finding roots of algebraic equations).
Difference between variables denoting primitive
values and object values – variables denoting Functions are like complex operations where the
objects are references to those objects. The object is implicitly the first argument. Variable
assignment operator = is special. The variable on this denotes the current object. Functions
the lhs of = denotes the memory location while the typically return values, they may also cause side-
same variable on the rhs denotes the contents of effects (e.g. change attribute values of objects) –
the location e.g. i=i+2. typically functions that are only supposed to cause
side-effects return void (e.g. Set functions). Java
12. Statements, scope
passes argument by value. Illustrate the difference
Statements; conditional (if, if-then-else, switch- between primitive values and object values as
break, ?: ternary operator), looping (for, while-do, arguments (changes made inside functions persist
do-while, continue, break); grouping statements in after the call for object values). Static definitions
blocks, scope and visibility of variables. as class variables and class functions visible and
Describe the semantics of the conditional and shared by all instances. @eed for static functions
looping statements in detail. Evaluation of the and variables. Introduce the main method –
condition in conditional statements (esp. needed to begin execution.
difference between || and | and && and &). 14. Arrays, strings
Emphasize fall through in switch statement. Many
(a) Structured data types – arrays (single and
small examples should be done to illustrate
multi-dimensional), strings. Example
control structures. Printing different kinds of
algorithms that use structured data types (e.g.
patterns for looping is instructive. When number
searching, finding maximum/minimum,
of iterations are known in advance use the for
sorting, solving systems of linear equations,
loop otherwise the while-do or do-while loop.
substring, concatenation, length, access to
Express one loop construct using the others. For
char in string, etc.).
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
(i) Using while depend on the number of elements. Structured
<init>; while <test> {<stmt>; <inc> } data types can be defined by classes – String.
Introduce the Java library String class and
(ii) Using do-while the basic operations on strings (accessing
<init>; if !<test> do <stmt>; <inc> while individual characters, various substring
<test>; operations, concatenation, replacement, index
of operations).
@esting of blocks. Variables with block scope,
function scope, class scope. Visibility rules when (b) Basic concept of a virtual machine; Java
variables with the same name are defined in virtual machine; compilation and execution of
different scopes. Java programs (the javac and java programs).

178
The JVM is a machine but built as a program which field(s) will be used for doing the
and not through hardware. Therefore it is comparison and whether sorting should be in
called a virtual machine. To run, JVM ascending or descending order be given by
machine language programs require an the user of the class.
interpreter (the java program). The advantage Emphasize the difference between the Java
is that such JVM machine language programs language construct interface and the word
(.class files) are portable and can run on any interface often used to describe the set of
machine that has the java program. function prototypes of a class.
(c) Compile time and run time errors; basic (c) Basic data structures (stack, queue, dequeue);
concept of an exception, the Exception class, implementation directly through classes;
catch and throw. definition through an interface and multiple
implementations by implementing the
Differentiate between compile time and run interface. Basic algorithms using the above
time errors. Run time errors crash the data structures.
program. Recovery is possible by the use of
exceptions. Explain how an exception object A data structure is a data collection with well
is created and passed up until a matching defined operations and behaviour or
catch is found. This behaviour is different properties. The behaviour or properties can
from the one where a value is returned by a usually be expressed formally using equations
or some kind of logical formulae. Consider
deeply nested function call. It is enough to
for e.g. a stack with operations defined as
discuss the Exception class. Sub-classes of follows:
Exception can be discussed after inheritance
has been done in Class XII. void push(Object o)
Object pop()
SECTIO C boolean isEmpty()
15. Elementary data structures and associated Object top()
algorithms, basic input/ouput Then, for example the LIFO property can be
expressed by (assume s is a stack):
(a) Class as a contract; separating implementation
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
stack s and then it is popped and o1 is the
Class is the basic reusable unit. Its function object obtained then o, o1 are identical.
prototypes (i.e. the interface) work as a visible
Another useful property is:
contract with the outside world since others
will use these functions in their programs. if s.isEmpty() == true then s.pop() = ERROR
This leads to encapsulation (i.e. hiding It says that popping an empty stack gives
implementation information) which in turn ERROR.
leads to the use of private and public for Similarly, several other properties can also be
realizing encapsulation. specified. It is important to emphasize the
(b) Interfaces in Java; implementing interfaces behavioural rules or properties of a data
through a class; interfaces for user defined structure since any implementation must
implementation of behaviour. guarantee that the rules hold.
Some simple algorithms that use the data
Motivation for interface: often when creating structures:
reusable classes some parts of the exact
implementation can only be provided by the i) For stack: parentheses matching, tower of
final end user. For example in a class that Hanoi, nested function calls; solving a
sorts records of different types the exact maze.
comparison operation can only be provided ii) For queue: scheduling processes, printers,
by the end user. Since only he/she knows jobs in a machine shop.

179
(d) Basic input/output using Scanner and Printer (ii) Definition of GCD:
classes from JDK; files and their
gcd(m, n) =
representation using the File class, file
input/output; input/output exceptions. Tokens if (m==n) then n //base case
in an input stream, concept of whitespace, else if (m>n) then gcd(m-n, n)
extracting tokens from an input stream
(StringTokenizer class). else gcd(m, n-m)
The Scanner class can be used for input of (iii) Definition of Fibonacci numbers:
various types of data (e.g. int, float, char etc.) fib(0) = 1 //base case
from the standard input stream or a file input
stream. The File class is used model file fib(1) = 1 //base case
objects in the underlying system in an OS fib(n) = fib(n-1)+ fib(n-2)
independent manner. Similarly, the Printer
class handles output. Only basic input and The tower of Hanoi is a very good example of
output using these classes should be covered. how recursion gives a very simple and elegant
solution where as non-recursive solutions are
Discuss the concept of a token (a delimited quite complex. Discuss the use of a stack to
continuous stream of characters that is keep track of function calls. The stack can
meaningful in the application program – e.g. also be used to solve the tower of Hanoi
words in a sentence where the delimiter is the problem non-recursively.
blank character). This naturally leads to the
idea of delimiters and in particular (f) Concrete computational complexity; concept
whitespace and user defined characters as of input size; estimating complexity in terms
delimiters. As an example show how the of functions; importance of dominant term;
StringTokenizer class allows one to extract a best, average and worst case.
sequence of tokens from a string with user Points to be given particular emphasis:
defined delimiters.
(i) Algorithms are usually compared along
(e) Concept of recursion, simple recursive two dimensions – amount of space (that is
functions (e.g. factorial, GCD, binary search, memory) used and the time taken. Of the
conversion of representations of numbers two the time taken is usually considered
between different bases). the more important. The motivation to
Many problems can be solved very elegantly study time complexity is to compare
by observing that the solution can be different algorithms and use the one that is
composed of solutions to ‘smaller’ versions of the most efficient in a particular situation.
the same problem with the base version (ii) Actual run time on a particular computer
having a known simple solution. Recursion is not a good basis for comparison since it
can be initially motivated by using recursive depends heavily on the speed of the
equations to define certain functions. These computer, the total amount of RAM in the
definitions are fairly obvious and are easy to computer, the OS running on the system
understand. The definitions can be directly and the quality of the compiler used. So
converted to a program. Emphasize that any we need a more abstract way to compare
recursion must have a base case. Otherwise, the time complexity of algorithms.
the computation can go into an infinite loop.
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
algorithm as a function of the size of the
(i) Definition of factorial: input. In most programs the loops are
factorial(0) = 1 //base case important in deciding the complexity. For
example in bubble sort there are two
factorial(n) = n * factorial(n-1) nested loops and in the worst case the time
180
taken will be proportional to n(n-1) where 17. Social context of computing and ethical issues
n is the number of elements to be sorted.
(a) Intellectual property and corresponding laws
Similarly, in linear search in the worst
case the target has to be compared with and rights, software as intellectual property.
all the elements so time taken will be (b) Software copyright and patents and the
proportional to n where n is the number of difference between the two; trademarks;
elements in the search set. software licensing and piracy.
(iv) In most algorithms the actual complexity (c) Free software foundation and its position on
for a particular input can vary. For software, open source software, various types
example in search the number of of licensing (e.g. GPL, BSD).
comparisons can vary from 1 to n. This
means we need to study the best, worst (d) Privacy, email etiquette, spam, security issues,
and average cases. Comparisons are phising.
usually made taking the worst case.
Average cases are harder to estimate Social impact and ethical issues should be
since it depends on how the data is discussed and debated in class. The important
distributed. For example in search, if the thing is for students to realise that these are
elements are uniformly distributed it will complex issues and there are multiple points of
take on the average n/2 comparisons when view on many of them and there is no single
the average is taken over a statistically ‘correct’ or ‘right’ view.
significant number of instances.
(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 This paper of three hours duration will be evaluated
important term. For example if we are internally by the school.
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
large n the dominant term is clearly n2 and (1) Planning Session
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. 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
the computer lab concurrently with the lectures. 90 minutes is permitted for the Planning session.
Programming assignments should be done such However, if the candidates finish earlier, they are to
that each major topic is covered in at least one be permitted to begin with the Examination session.
assignment. Assignment problems should be
designed so that they are non-trivial and make the Planning Session
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.

181
Examination Session Marks (out of a total of 100) should be distributed as
given below:
The program handed in at the end of the Planning
Continuous Evaluation
session shall be returned to the candidates. The
candidates will be required to key-in and execute the Candidates will be required to submit a work file
containing the practical work related to programming
Java program on seen and unseen inputs individually assignments done during the year.
on the Computer and show execution to the examiner.
Programming assignments done throughout the year
A printout of the program listing, including output
(Internal evaluation) - 20 marks
results should be attached to the answer script
containing the algorithm and handwritten program. Terminal Evaluation
This should be returned to the examiner. The program Solution to programming problem on the computer
should be sufficiently documented so that the - 60 marks
algorithm, representation and development process is (Marks should be given for choice of algorithm and
clear from reading the program. Large differences implementation strategy, documentation, correct output
between the planned program and the printout will on known inputs mentioned in the question paper,
result in loss of marks. correct output for unknown inputs available only to the
examiner.)
Teachers should maintain a record of all the Viva-voce - 20 marks
assignments done as part of the practical work through
(Viva-voce includes questions on the following aspects
the year and give it due credit at the time of of the problem attempted by the student: the algorithm
cumulative evaluation at the end of the year. Students and implementation strategy, documentation,
are expected to do a minimum of twenty assignments correctness, alternative algorithms or implementations.
for the year. Questions should be confined largely to the problem
the student has attempted).

182
CLASS XII

There will be two papers in the subject: p∨p≡p p∧p≡p


Paper I: Theory- 3 hours …100 marks
p ∨ true ≡ true p ∧ true ≡ p
Paper II: Practical- 3 hours …100 marks
p ∨ false ≡ p p ∧ false ≡ false
PAPER I-THEORY
p ∨ (p ∧ q) ≡ p p ∧ (p ∨ q) ≡ p
Paper 1 shall be of 3 hours duration and be divided The equivalence rules can be used to simplify
into two parts. propositional wffs, for example:
Part I (30 marks): This part will consist of 1) (p ⇒ q) ∧ (p ⇒ r) to p ⇒ (q ∧ r)
compulsory short answer questions, testing
knowledge, application and skills relating to the entire 2) ((p ⇒ q) ∧ p) ⇒ q to true
syllabus.
etc.
Part II (70 marks): This part will be divided into
(b) Binary valued quantities; basic postulates of
three Sections, A, B and C. Candidates are required to
Boolean algebra; operations AND, OR and
answer three questions out of four from Section A and
NOT; truth tables.
two questions out of three in each of the Sections B
and C. Each question in this part shall carry 10 (c) Basic theorems of Boolean algebra (e.g.
marks. Duality, idempotence, commutativity,
associativity, distributivity, operations with 0
SECTIO A
and 1, complements, absorption, involution);
1. Boolean Algebra De Morgan’s theorem and its applications;
reducing Boolean expressions to sum of
(a) Propositional logic, well formed formulae,
products and product of sums forms;
truth values and interpretation of well formed
formulae (wff), truth tables, satisfiable, Karnaugh maps (up to four variables).
unsatisfiable and valid formulae. Equivalence
laws and their use in simplifying wffs. Verify the laws of boolean algebra using truth
tables. Inputs, outputs for circuits like half and
Propositional variables; the common logical full adders, majority circuit etc., SOP
connectives (~ (not), ∧ (and), ∨ (or), ⇒ representation; reduction using Karnaugh maps
(implication), ⇔ (biconditional); definition of and boolean algebra.
a well-formed formula (wff); representation of
simple word problems as wff (this can be used 2. Computer Hardware
for motivation); the values true and false; (a) Elementary logic gates (NOT, AND, OR,
interpretation of a wff; truth tables; NAND, NOR, XOR, XNOR) and their use in
satisfiable, unsatisfiable and valid formulae. circuits.
Equivalence laws: commutativity of ∧, ∨;
(b) Applications of Boolean algebra and logic
associativity of ∧, ∨; distributivity; de
gates to half adders, full adders, encoders,
Morgan’s laws; law of implication (p ⇒ q ≡
decoders, multiplexers, NAND, NOR as
~p ∨ q); law of biconditional ((p ⇔ q) ≡
universal gates.
(p ⇒ q) ∧ (q ⇒ p)); identity (p ≡ p); law of
negation (~ (~p) ≡ p); law of excluded middle Show the correspondence between boolean
(p ∨~p ≡ true); law of contradiction(p∧~p ≡ functions and the corresponding switching
false); simplification rules for ∧, ∨. circuits or gates. Show that @A@D and @OR gates
183
are universal by converting some circuits to types. Changing types through user defined
purely @A@D or @OR gates. casting and automatic type coercion for some
primitive types.
SECTIO B Ideally, everything should be a class; primitive
The programming element in the syllabus (Sections B types are defined for efficiency reasons; each
and C) is aimed at algorithmic problem solving and primitive type has a corresponding wrapper class.
not merely rote learning of Java syntax. The Java Classes as user defined types. In some cases types
version used should be 1.5 or later. For programming, are changed by automatic coercion or casting –
the students can use any text editor and the javac and e.g. mixed type expressions. However, casting in
java programs or any development environment: for general is not a good idea and should be avoided,
example, BlueJ, Eclipse, NetBeans etc. BlueJ is if possible.
strongly recommended for its simplicity, ease of use 6. Variables, expressions
and because it is very well suited for an ‘objects first’
approach. Variables as names for values; expressions
(arithmetic and logical) and their evaluation
3. Programming in Java (Review of Class XI (operators, associativity, precedence). Assignment
Sections B and C) operation; difference between left hand side and
@ote that items 4 to 8 will get introduced almost right hand side of assignment.
simultaneously when classes and their definitions Variables denote values; variables are already
are introduced. defined as attributes in classes; variables have
types that constrain the values it can denote.
4. Objects
Difference between variables denoting primitive
(a) Objects as data (attributes) + behaviour values and object values – variables denoting
(methods or functions); object as an instance objects are references to those objects. The
of a class. Constructors. assignment operator = is special. The variable on
Difference between object and class should be the lhs of = denotes the memory location while the
made very clear. BlueJ (www.bluej.org) and same variable on the rhs denotes the contents of
Greenfoot (www.greenfoot.org) can be the location e.g. i=i+2.
profitably used for this purpose. Constructor 7. Statements, scope
as a special kind of function; the new
operator; multiple constructors with different Statements; conditional (if, if-then-else, switch-
argument structures; constructor returns a break, ?: ternary operator), looping (for, while-do,
reference to the object. do-while, continue, break); grouping statements in
blocks, scope and visibility of variables.
(b) Analysis of some real world programming
examples in terms of objects and classes. Describe the semantics of the conditional and
looping statements in detail. Evaluation of the
Use simple examples like a calculator, date,
condition in conditional statements (esp.
number, etc. to illustrate how they can be
difference between || and | and && and &).
treated as objects that behave in certain well-
Emphasize fall through in switch statement. Many
defined ways and how the interface provides a
small examples should be done to illustrate
way to access behaviour. Illustrate behaviour
control structures. Printing different kinds of
changes by adding new functions, deleting old
patterns for looping is instructive. When number
functions or modifying existing functions.
of iterations are known in advance use the for
5. Primitive values, wrapper classes, types and loop otherwise the while-do or do-while loop.
casting Express one loop construct using the others. For
e.g.:
Primitive values and types: int, short, long, float,
double, boolean, char. Corresponding wrapper for (<init>; <test>; <inc>) <stmt>; is equivalent
classes for each primitive type. Class as type of to:
the object. Class as mechanism for user defined Using while
184
<init>; while <test> {<stmt>; <inc> } the basic operations on strings (accessing
Using do-while individual characters, various substring
operations, concatenation, replacement, index
<init>; if !<test> do <stmt>; <inc> while <test>;
of operations). The Class StringBuffer should
Nesting of blocks. Variables with block scope, be introduced for those applications that
function scope, class scope. Visibility rules when involve heavy manipulation of strings.
variables with the same name are defined in
(b) Basic concept of a virtual machine; Java
different scopes.
virtual machine; compilation and execution of
8. Functions Java programs (the javac and java programs).
Functions/methods (as abstractions for complex The JVM is a machine but built as a program
user defined operations on objects), functions as and not through hardware. Therefore it is
mechanisms for side effects; formal arguments called a virtual machine. To run, JVM
and actual arguments in functions; different machine language programs require an
behaviour of primitive and object arguments. interpreter (the java program). The advantage
Static functions and variables. The this variable. is that such JVM machine language programs
Examples of algorithmic problem solving using (.class files) are portable and can run on any
functions (various number theoretic problems, machine that has the java program.
finding roots of algebraic equations).
(c) Compile time and run time errors; basic
Functions are like complex operations where the concept of an exception, the Exception class,
object is implicitly the first argument. Variable catch and throw.
this denotes the current object. Functions
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 to cause program. Recovery is possible by the use of
side-effects return void (e.g. Set functions). Java exceptions. Explain how an exception object
passes argument by value. Illustrate the difference 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 deeply nested function call. It is enough to
as class variables and class functions visible and discuss the Exception class. Sub-classes of
shared by all instances. @eed 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.
(d) Class as a contract; separating implementation
from interface; encapsulation; private and
9. Arrays, strings
public.
(a) Structured data types – arrays (single and
multi-dimensional), strings. Example Class is the basic reusable unit. Its function
algorithms that use structured data types (e.g. prototypes (i.e. the interface) work as a visible
contract with the outside world since others
searching, finding maximum/minimum,
will use these functions in their programs.
sorting, solving systems of linear equations,
This leads to encapsulation (i.e. hiding
substring, concatenation, length, access to
implementation information) which in turn
char in string, etc.).
leads to the use of private and public for
Storing many data elements of the same type realizing encapsulation.
requires structured data types – like arrays.
(e) Interfaces in Java; implementing interfaces
Access in arrays is constant time and does not
through a class; interfaces for user defined
depend on the number of elements. Structured
implementation of behaviour.
data types can be defined by classes – String.
Introduce the Java library String class and
185
Motivation for interface: often when creating the same problem with the base version
reusable classes, some parts of the exact having a known simple solution. Recursion
implementation can only be provided by the can be initially motivated by using recursive
final end user. For example, in a class that equations to define certain functions. These
sorts records of different types the exact definitions are fairly obvious and are easy to
comparison operation can only be provided understand. The definitions can be directly
by the end user. Since only he/she knows converted to a program. Emphasize that any
which field(s) will be used for doing the recursion must have a base case. Otherwise,
comparison and whether sorting should be in the computation can go into an infinite loop.
ascending or descending order be given by Illustrate this by removing the base case and
the user of the class. running the program. Examples:
Emphasize the difference between the Java (i) Definition of factorial:
language construct interface and the word factorial(0) = 1 //base case
interface often used to describe the set of
factorial(n) = n * factorial(n-1)
function prototypes of a class.
(ii) Definition of GCD:
(f) Basic input/output using Scanner and Printer
classes from JDK; files and their gcd(m, n) =
representation using the File class, file if (m==n) then n //base case
input/output; input/output exceptions. Tokens else if (m>n) then gcd(m-n, n)
in an input stream, concept of whitespace,
extracting tokens from an input stream else gcd(m, n-m)
(StringTokenizer class). (iii) Definition of Fibonacci numbers:
The Scanner class can be used for input of 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
stream. The File class is used model file fib(n) = fib(n-1)+ fib(n-2)
objects in the underlying system in an OS The tower of Hanoi is a very good example of
independent manner. Similarly, the Printer how recursion gives a very simple and elegant
class handles output. Only basic input and solution where as non-recursive solutions are
output using these classes should be covered. quite complex. Discuss the use of a stack to
Discuss the concept of a token (a delimited keep track of function calls. A stack can also
continuous stream of characters that is be used to solve the tower of Hanoi problem
meaningful in the application program – e.g. non-recursively.
words in a sentence where the delimiter is the
blank character). This naturally leads to the SECTIO C
idea of delimiters and in particular
Inheritance, polymorphism, data structures,
whitespace and user defined characters as
computational complexity
delimiters. As an example show how the
StringTokenizer class allows one to extract a
10. Inheritance and polymorphism
sequence of tokens from a string with user
defined delimiters. Inheritance; base and derived classes; member
access in derived classes; redefinition of variables
(g) Concept of recursion, simple recursive
and functions in subclasses; abstract classes; class
functions (e.g. factorial, GCD, binary search,
Object; protected visibility. Subclass
conversion of representations of numbers
polymorphism and dynamic binding.
between different bases).
Many problems can be solved very elegantly Emphasize the following:
by observing that the solution can be - inheritance as a mechanism to reuse a class
composed of solutions to ‘smaller’ versions of by extending it.

186
- inheritance should not normally be used just Object top()
to reuse some functions defined in a class but
Then, for example the LIFO property can be
only when there is a genuine specialization
expressed by (assume s is a stack):
(or subclass) relationship between objects of
the base class and that of the derived class. if s.push(o); o1=pop() then o ≡ o1
- Allows one to implement operations at the What the rule says is: if o is pushed on the
highest relevant level of abstraction. stack s and then it is popped and o1 is the
- Freezes the interface in the form of abstract object obtained then o, o1 are identical.
classes with abstract functions that can be Another useful property is:
extended by the concrete implementing if s.isEmpty() == true then s.pop() = ERROR
classes. For example, an abstract class Shape
can have an abstract function draw that is It says that popping an empty stack gives
implemented differently in the sub-classes like ERROR.
Circle, Quadrilateral etc. Similarly, several other properties can also be
- how the exact function call at run time specified. It is important to emphasize the
depends on the type of the object referenced behavioural rules or properties of a data
by the variable. This gives sub-class structure since any implementation must
polymorphism. For example in the code guarantee that the rules hold.
fragment: Some simple algorithms that use the data
Shape s1=new Circle(), s2=new structures:
Quadrilateral(); (i) For stack: parentheses matching, tower of
s1.draw(); //the draw is the draw in Circle Hanoi, nested function calls; solving a
s2.draw(); //the draw is the draw in maze.
Quadrilateral (ii) For queue: scheduling processes,
printers, jobs in a machine shop.
the two draw function invocations on s1, s2
invoke different draw functions depending on (b) Recursive data structures: singly and doubly
the type of objects referenced by s1 and s2 linked lists, binary trees, tree traversals,
respectively. binary search tree. Algorithms using these
data structures (merge sort and quick sort,
11. Data structures searching).
(a) Basic data structures (stack, queue, dequeue); Data structures should be defined as abstract
implementation directly through classes; data types with a well defined interface (it is
definition through an interface and multiple instructive to define them using the Java
implementations by implementing the interface construct) – see the comments in (a)
interface. Basic algorithms using the above above. Emphasize that algorithms for
data structures. recursive data structures are themselves
recursive and that algorithms are usually the
A data structure is a data collection with well
defined operations and behaviour or simplest and most elegant. The following
properties. The behaviour or properties can should be covered for each data structure:
usually be expressed formally using equations Lists: insertion, deletion, reversal, appending
or some kind of logical formulae. Consider two lists, extracting an element or a sublist,
for e.g. a stack with operations defined as checking emptiness. Searching, sorting (by
follows: quicksort and mergesort algorithms), binary
void push(Object o) search in a sorted list.
Binary trees: apart from the definition the
Object pop()
following concepts should be covered:
boolean isEmpty() external and internal nodes, height,
187
completeness, balancing, Traversals (iv) In most algorithms the actual complexity for a
(pre, post and in-order). Implementation particular input can vary. For example in
using arrays and linked structures. search the number of comparisons can vary
from 1 to n. This means we need to study the
Binary search tree: insertion, deletion, best, worst and average cases. Comparisons
search. are usually made taking the worst case.
Average cases are harder to estimate since it
12. Complexity and big O notation depends on how the data is distributed. For
Concrete computational complexity; concept of example in search, if the elements are
uniformly distributed it will take on the
input size; estimating complexity in terms of
average n/2 comparisons when the average is
functions; importance of dominant term; best, taken over a statistically significant number of
average and worst case. Big O notation for instances.
computational complexity; analysis of complexity
(v) Comparisons are normally made for large
of example algorithms using the big O notation
values of the input size. This means that the
(e.g. Various searching and sorting algorithms, dominant term in the function is the important
algorithm for solution of linear equations etc.). term. For example if we are looking at bubble
Points to be given particular emphasis: sort and see that time taken can be estimated
as: a*n2 +b*n + c where n is the number of
(i) Algorithms are usually compared along two elements to be sorted and a, b, c are constants
dimensions – amount of space (that is then for large n the dominant term is clearly
memory) used and the time taken. Of the two n2 and we can, in effect, ignore the other two
the time taken is usually considered the more terms.
important. The motivation to study time All the above motivates the big O notation. Let
complexity is to compare different algorithms f(n), g(n) be positive functions, then f(n) is said to
and use the one that is the most efficient in a be O(g(n)) if there exists constants c, n0 such that
particular situation. f(x)≤ c*g(n) whenever n>n0. What this means is
that g(n) asymptotically dominates f(n).
(ii) Actual run time on a particular computer is Expressing time complexity using the big O
not a good basis for comparison since it notation gives us an abstract basis for comparison
depends heavily on the speed of the computer, and frees us from bothering about constants. So
the total amount of RAM in the computer, the the estimated time complexity a*n2+b*n+c is
OS running on the system and the quality of O(n2).
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.
(iii) This is done by trying to approximate the
13. Implementation of algorithms to solve
number of operations done by each algorithm
problems
as a function of the size of the input. In most
programs the loops are important in deciding The students are required to do lab assignments in
the complexity. For example in bubble sort the computer lab concurrently with the lectures.
there are two nested loops and in the worst Programming assignments should be done such
case the time taken will be proportional to that each major topic is covered in at least one
n(n-1) where n is the number of elements to be assignment. Assignment problems should be
sorted. Similarly, in linear search in the worst designed so that they are non-trivial and make the
student do algorithm design, address correctness
case the target has to be compared with all
issues, implement and execute the algorithm in
the elements so time taken will be Java and debug where necessary.
proportional to n where n is the number of
elements in the search set. Self explanatory.

188
PAPER II - PRACTICAL Marks (out of a total of 100) should be distributed as
given below:
This paper of three hours duration will be evaluated
by the Visiting Examiner appointed locally and
Continuous Evaluation
approved by the Council.
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) - 10 marks
2. Examination Session Programming assignments done throughout the year
The total time to be spent on the Planning session and (Visiting Examiner) - 10 marks
the Examination session is three hours. After
completing the Planning session the candidates may Terminal Evaluation
begin with the Examination session. A maximum of Solution to programming problem on the computer
90 minutes is permitted for the Planning session. - 60 marks
However, if the candidates finish earlier, they are to
(Marks should be given for choice of algorithm and
be permitted to begin with the Examination session.
implementation strategy, documentation, correct output
on known inputs mentioned in the question paper,
Planning Session correct output for unknown inputs available only to the
The candidates will be required to prepare an examiner.)
algorithm and a hand written Java program to solve Viva-voce - 20 marks
the problem.
(Viva-voce includes questions on the following
Examination Session aspects of the problem attempted by the student: the
algorithm and implementation strategy,
The program handed in at the end of the Planning documentation, correctness, alternative algorithms or
session shall be returned to the candidates. The implementations. Questions should be confined
candidates will be required to key-in and execute the largely to the problem the student has attempted).
Java program on seen and unseen inputs individually
OTE:
on the Computer and show execution to the Visiting
Examiner. A printout of the program listing including Algorithm should be expressed clearly using any
output results should be attached to the answer script standard scheme such as a pseudo code.
containing the algorithm and handwritten program.
This should be returned to the examiner. The program EQUIPME T
should be sufficiently documented so that the There should be enough computers to provide for a
algorithm, representation and development process is teaching schedule where at least three-fourths of the
clear from reading the program. Large differences time available is used for programming.
between the planned program and the printout will
result in loss of marks. Schools should have equipment/platforms such that all
the software required for practical work runs properly,
Teachers should maintain a record of all the i.e. it should run at acceptable speeds.
assignments done as part of the practical work through
the year and give it due credit at the time of Since hardware and software evolve and change very
cumulative evaluation at the end of the year. Students rapidly, the schools may have to upgrade them as
required. Following are the recommended
are expected to do a minimum of twenty assignments
specifications as of now:
for the year.

189
The Facilities: system (Java compiler, Java runtime environment,
• A lecture cum demonstration room with a Java development environment) at acceptable
MULTIMEDIA PROJECTOR/ an LCD and speeds.
O.H.P. attached to the computer. • Good Quality printers.
• A white board with white board markers should
be available. Software:
• A fully equipped Computer Laboratory that • Any suitable Operating System can be used.
allows one computer per student. • JDK 1.5 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 256
environment with a debugger is preferred (e.g.
MB (512MB preferred) RAM and a PIII or higher
BlueJ, Eclipse, NetBeans). BlueJ is recommended
processor. The basic requirement is that it should
for its ease of use and simplicity.
run the operating system and Java programming

190

Potrebbero piacerti anche