Document Sample

COMPUTER SCIENCE (868) CLASS XI (Scope) General remarks decimal, hexadecimal). Addition and subtraction operations for numbers in different bases. a) The scope document contains details, explanatory material and other information to help in teaching the Introduce the positional system of representing syllabus. It must be read in conjunction with the numbers and the concept of a base. Discuss the syllabus. conversion of representations between different bases using English or pseudo code since students new to b) The examples and problems given in this document computing may be seeing algorithms for the first time. are meant to be suggestive and indicative not These algorithms are also good examples for defining enumerative or exhaustive. That means that the different functions in a class modelling numbers student should typically know how to solve the (when programming is discussed). For addition and problems and be familiar with the examples subtraction use the analogy with decimal numbers, mentioned here but it does not mean that those are the emphasize how carry works (this will be useful later only problems or examples that will be examined in when binary adders are discussed). the terminal examination. Encodings c) There is some information regarding environments and software. This information again is in the nature b) Binary encodings for integers and real numbers of recommendations and is not mandatory. For the using a finite number of bits (sign-magnitude, twos programming part the recommendations are based on complement, mantissa-exponent notation). Basic an objects first approach to programming. Individual operations on integers and floating point numbers. teachers are perfectly free to use other software and Limitations of finite representations. environments that suit the way they wish to teach the Signed, unsigned numbers, least and most significant material. bits. Sign-magnitude representation and its d) The scope document follows the structure of the shortcomings (two representations for 0, addition syllabus. Each item of the syllabus is first reproduced requires extra step); twos-complement representation. in italics and the explanatory material then follows the Operations (arithmetic, logical, shift), discuss the reproduced item. basic algorithms used for the arithmetic operations. Floating point representation: normalized scientific e) The syllabus per se does not assume any previous notation, mantissa-exponent representation, binary background as a pre-requisite. However, a majority of point (discuss trade-off between size of mantissa and students are likely to have done a computer exponent). Single and double precision. Arithmetic applications course at the class X level or may be operations with floating point numbers. Properties of otherwise familiar with programming. So, a balance finite representation: overflow, underflow, lack of has to be struck between the student without any associativity (demonstrate this through actual background and one with programming background. programs). Especially in sections B and C it is possible that the ‘fresh’ student may have to put in extra effort and the c) Characters and their encodings (e.g. ASCII, teacher may have to help such students with extra Unicode). assignments and explanations. Discuss the limitations of the ASCII code in SECTION A representing characters of other languages. Discuss the Unicode representation for the local language. Basic Computer hardware and software: Java uses Unicode, so strings in the local language can Numbers be used (they can be displayed if fonts are available) – a simple table lookup for local language equivalents a) Representation of numbers in different bases and for Latin (i.e. English) character strings should interest interconversion between them (e.g. binary, octal, 1071 22 students. More details on Unicode are available at f) Assembly language of 8085, simple assembly www.unicode.org. language programs, assembly process and assembler. High level structure of computer Discussion of the assembly language should be done along with the instruction set (previous section). d) Block diagram of a computer system with details of Emphasize how it is easier to program in assembly i) function of each block and ii) interconnectivity and language than in machine language. Assembly data and control flow between the various blocks. process: symbol table and its use in translating a Develop the diagram by successive refinement of program to machine language. Macros are not blocks till all the following have been covered: ALU, included. RAM, cache, the buses (modern computers have Propositional logic, hardware implementation, multiple buses), disk (disk controller and what it arithmetic operations does), input/output ports (serial, parallel, USB, network, modem, line-in, line-out etc.), devices that g) Propositional logic, well formed formulae, truth can be attached to these ports (e.g keyboard, mouse, values and interpretation of well formed formulae, monitor, CDROM, DVD, audio input/output devices, truth tables. printer, etc.). Clearly describe the connectivity and the Propositional variables; the common logical flow of data and control signals. . connectives(∽ (not), ∧ (and), ∨ (or), ⇾ (implication), Basic architecture of typical simple processor and its assembly language ⇿ (equivalence)); definition of a well-formed formula e) Basic architecture of the 8085 microprocessor. (wff); representation of simple word problems as wff (this can be used for motivation); the values true and Instruction set, addresses, addressing modes, simple false; interpretation of a wff; truth tables; satisfiable, machine language programs using the different unsatisfiable and valid formulae. addressing modes, execution of machine language programs, input and output. h) Logic and hardware, basic gates (AND, NOT, OR) and their universality, other gates (NAND, NOR, The idea here is to discuss a concrete microprocessor XOR); inverter, half adder, full adder. instead of an abstract computer thus giving students a clearer understanding of how a typical computer Show how the logic in g) can be realized in hardware works. The aim is not to know all details of the 8085 in the form of gates. These gates can then be microprocessor. The basic features that must be combined to implement the basic operations for covered are: i) Structure of memory; ii) registers - A- arithmetic. Tie up with the arithmetic operations on register (accumulator), general (B, C, D, E, H, L in 8- integers discussed earlier in b). bit individual and paired 16-bit modes), program Memory counter, stack pointer, flag; iii) addressing modes (immediate, direct, register, register-indirect); iv) i) Memory - construction of a memory bit using a flip- Instruction set (data transfer, arithmetic, logical, flop, D-flip-flop and its use in constructing registers. conditional and transfer of control, input/output). j) Memory organization and access; parity; memory Interrupts are not included. Since many free hierarchy - cache, primary memory, secondary simulators are available the student should actually memory. write, run and observe what happens when a machine language program runs. Example machine and The access time differences between the different assembly language programs: evaluating simple kinds of memory; size differences; locality of expressions, adding a sequence of numbers, finding reference and cache memory. the minimum and/or maximum of a sequence of System and other software numbers, using finding the minimum/maximum to do sorting of a sequence of numbers. In particular, k) Boot process. Operating system as resource discuss how the stack can be used for calling and manager, command processing, files, directories and returning from subprograms. Emphasize how data and file system. Commonly available programs (editors, program look alike and depend on the interpretation compilers, interpreters, word processors, spread used. sheets etc.). 1081 22 Boot process step-by-step from power on till the Primitive values, wrapper classes, types and prompt. In OS discuss: i) all the resources (processor, casting memory, i/o) that need to be managed in a computer c) Primitive values and types: int, short, long, float, ii) what is meant by managing these resources. double, boolean, char. Corresponding wrapper Logical structure of data storage on disk using logical classes for each primitive type. Class as type of the disks, hierarchical directories and files. Distinguish object. Class as mechanism for user defined types. between interpreters and compilers. In particular Changing types through user defined casting and discuss the javac and java programs. automatic type coercion for some primitive types. Ideally, everything should be a class; primitive types are defined for efficiency reasons; each primitive type SECTION B has a corresponding wrapper class. Classes as user defined types. In some cases types are changed by The programming element in the syllabus is aimed at automatic coercion or casting – e.g. mixed type algorithmic problem solving and not merely rote expressions. However, casting in general is not a good learning of Java syntax. The Java version used should idea and should be avoided, if possible. be 1.5 or later. For programming, the students can use any text editor and the javac and java programs or any Variables, expressions development environment: for example, BlueJ, d) Variables as names for values; expressions Eclipse, NetBeans etc. BlueJ is strongly recommended (arithmetic and logical) and their evaluation for its simplicity, ease of use and because it is very (operators, associativity, precedence). Assignment well suited for an ‘objects first’ approach. operation; difference between left hand side and right hand side of assignment. Introduction to algorithmic problem solving using Java Variables denote values; variables are already defined as attributes in classes; variables have types that Note that items a) to f) will get introduced almost constrain the values it can denote. Difference between simultaneously when classes and their definitions are variables denoting primitive values and object values introduced. – variables denoting objects are references to those Objects objects. The assignment operator = is special. The variable on the lhs of = denotes the memory location a) Objects as data (attributes) + behaviour (methods while the same variable on the rhs denotes the or functions); object as an instance of a class. contents of the location e.g. i=i+2. Constructors. Statements, scope Difference between object and class should be made very clear. BlueJ (www.bluej.org) and Greenfoot e) Statements; conditional (if, if-then-else, switch- (www.greenfoot.org) can be profitably used for this break, ?: ternary operator), looping (for, while-do, do-while, continue, break); grouping statements in purpose. Constructor as a special kind of function; the blocks, scope and visibility of variables. new operator; multiple constructors with different argument structures; constructor returns a reference to Describe the semantics of the the conditional and the object. looping statements in detail. Evaluation of the condition in conditional statements (esp. difference b) Analysis of some real world programming between || and | and && and &). Emphasize fall examples in terms of objects and classes. through in switch statement. Many small examples Use simple examples like a calculator, date, number should be done to illustrate control structures. Printing etc. to illustrate how they can be treated as objects that different kinds of patterns for looping is instructive. behave in certain well-defined ways and how the When number of iterations are known in advance use interface provides a way to access behaviour. the for loop otherwise the while-do or do-while loop. Illustrate behaviour changes by adding new functions, Express one loop construct using the others. For e.g.: deleting old functions or modifying existing functions. for (<init>; <test>; <inc>) <stmt>; is equivalent to: 1091 22 Using while individual characters, various substring operations, concatenation, replacement, index of operations). <init>; while <test> {<stmt>; <inc> } h) Basic concept of a virtual machine; Java virtual Using do-while machine; compilation and execution of Java programs <init>; if !<test> do <stmt>; <inc> while <test>; (the javac and java programs). Nesting of blocks. Variables with block scope, The JVM is a machine but built as a program and not function scope, class scope. Visibility rules when through hardware. Therefore it is called a virtual variables with the same name are defined in different machine. To run, JVM machine language programs scopes. require an interpreter (the java program). The Functions advantage is that such JVM machine language programs (.class files) are portable and can run on any f) Functions/methods (as abstractions for complex machine that has the java program. user defined operations on objects), functions as mechanisms for side effects; formal arguments and i) Compile time and run time errors; basic concept of actual arguments in functions; different behaviour of an exception, the Exception class, catch and throw. primitive and object arguments. Static functions and Differentiate between compile time and run time variables. The this variable. Examples of algorithmic errors. Run time errors crash the program. Recovery is problem solving using functions (various number possible by the use of exceptions. Explain how an theoretic problems, finding roots of algebraic exception object is created and passed up until a equations). matching catch is found. This behaviour is different Functions are like complex operations where the from the one where a value is returned by a deeply object is implicitly the first argument. Variable this nested function call. It is enough to discuss the denotes the current object. Functions typically return Exception class. Sub-classes of Exception can be values, they may also cause side-effects (e.g. change discussed after inheritance has been done in class XII. attribute values of objects) – typically functions that SECTION C are only supposed to cause side-effects return void Elementary data structures and associated (e.g. Set functions). Java passes argument by value. algorithms, basic input/ouput, Illustrate the difference between primitive values and object values as arguments (changes made inside a) Class as a contract; separating implementation functions persist after the call for object values). Static from interface; encapsulation; private and public. definitions as class variables and class functions Class is the basic reusable unit. Its function prototypes visible and shared by all instances. Need for static (i.e. the interface) work as a visible contract with the functions and variables. Introduce the main method – outside world since others will use these functions in needed to begin execution. their programs. This leads to encapsulation (i.e. hiding Arrays, strings implementation information) which in turn leads to the use of private and public for realizing g) Structured data types – arrays (single and multi- encapsulation. dimensional), strings. Example algorithms that use structured data types (e.g. searching, finding b) Interfaces in Java; implementing interfaces through maximum/minimum, sorting, solving systems of linear a class; interfaces for user defined implementation of equations, substring, concatenation, length, access to behaviour . char in string, etc.). Motivation for interface: often when creating reusable Storing many data elements of the same type requires classes some parts of the exact implementation can structured data types – like arrays. Access in arrays is only be provided by the final end user. For example in constant time and does not depend on the number of a class that sorts records of different types the exact elements. Structured data types can be defined by comparison operation can only be provided by the end classes – String. Introduce the Java library String class user. Since only he/she knows which field(s) will be and the basic operations on strings (accessing used for doing the comparison and whether sorting 1101 22 should be in ascending or descending order be given the File class, file input/output; input/output by the user of the class. exceptions. Tokens in an input stream, concept of whitespace, extracting tokens from an input stream Emphasize the difference between the Java language (StringTokenizer class). construct interface and the word interface often used to describe the set of function prototypes of a class. The Scanner class can be used for input of various types of data (e.g. int, float, char etc.) from the c) Basic data structures (stack, queue, dequeue); standard input stream or a file input stream. The File implementation directly through classes; definition class is used model file objects in the underlying through an interface and multiple implementations system in an OS independent manner. Similarly, the by implementing the interface. Basic algorithms using Printer class handles output. Only basic input and the above data structures. output using these classes should be covered. A data structure is a data collection with well Discuss the concept of a token (a delimited continuous defined operations and behaviour or properties. stream of characters that is meaningful in the The behaviour or properties can usually be application program – e.g. words in a sentence where expressed formally using equations or some kind the delimiter is the blank character). This naturally of logical formulae. Consider for e.g. a stack with leads to the idea of delimiters and in particular operations defined as follows: whitespace and user defined characters as delimiters. As an example show how the StringTokenizer class void push(Object o) allows one to extract a sequence of tokens from a Object pop() string with user defined delimiters. boolean isEmpty() e) Concept of recursion, simple recursive functions (e.g. factorial, GCD, binary search, conversion of Object top() representations of numbers between different bases). Then, for example the LIFO property can be Many problems can be solved very elegantly by expressed by (assume s is a stack): observing that the solution can be composed of solutions to ‘smaller’ versions of the same problem if s.push(o); o1=pop() then o ≡ o1 with the base version having a known simple solution. Recursion can be initially motivated by using What the rule says is: if o is pushed on the stack s recursive equations to define certain functions. These and then it is popped and o1 is the object obtained definitions are fairly obvious and are easy to then o, o1 are identical. understand. The definitions can be directly converted Another useful property is: to a program. Emphasize that any recursion must have a base case. Otherwise, the computation can go into an if s.isEmpty() == true then s.pop() = ERROR infinite loop. Illustrate this by removing the base case and running the program. Examples: It says that popping an empty stack gives ERROR. 1) Definition of factorial: Similarly, several other properties can also be specified. It is important to emphasize the behavioural factorial(0) = 1 //base case rules or properties of a data structure since any factorial(n) = n * factorial(n-1) implementation must guarantee that the rules hold. Definition of GCD: Some simple algorithms that use the data structures: gcd(m, n) = i) For stack: parentheses matching, tower of Hanoi, nested function calls; solving a maze. if (m==n) then n //base case ii) For queue: scheduling processes, printers, else if (m>n) then gcd(m-n, n) jobs in a machine shop. else gcd(m, n-m) d) Basic input/output using Scanner and Printer Definition of Fibonacci numbers: classes from JDK; files and their representation using 1111 22 fib(0) = 1 //base case take on the average n/2 comparisons when the average is taken over a statistically significant number of fib(1) = 1 //base case instances. fib(n) = fib(n-1)+ fib(n-2) v) Comparisons are normally made for large values of The tower of Hanoi is a very good example of how the input size. This means that the dominant term in recursion gives a very simple and elegant solution the function is the important term. For example if we where as non-recursive solutions are quite complex. are looking at bubble sort and see that time taken can Discuss the use of a stack to keep track of function be estimated as: a*n2 +b*n + c where n is the number calls. The stack can also be used to solve the tower of of elements to be sorted and a, b, c are constants then Hanoi problem non-recursively. for large n the dominant term is clearly n2 and we can f) Concrete computational complexity; concept of in effect ignore the other two terms. input size; estimating complexity in terms of functions; Implementation of algorithms to solve problems importance of dominant term; best, average and worst case. The students are required to do lab assignments in the Points to be given particular emphasis: computer lab concurrently with the lectures. Programming assignments should be done such that i) Algorithms are usually compared along two each major topic is covered in at least one assignment. dimensions – amount of space (that is memory) used Assignment problems should be designed so that they and the time taken. Of the two the time taken is are non-trivial and make the student do algorithm usually considered the more important. The design, address correctness issues, implement and motivation to study time complexity is to compare execute the algorithm in Java and debug where different algorithms and use the one that is the most necessary. Some sample problems are given in the efficient in a particular situation. scope document. ii) Actual run time on a particular computer is not a good basis for comparison since it depends heavily on Social context of computing and ethical issues the speed of the computer, the total amount of RAM g) Intellectual property and corresponding laws and in the computer, the OS running on the system and the rights, software as intellectual property. quality of the compiler used. So we need a more abstract way to compare the time complexity of h) Software copyright and patents and the difference algorithms. between the two; trademarks; software licensing and piracy. iii) This is done by trying to approximate the number of operations done by each algorithm as a function of i) Free software foundation and its position on the size of the input. In most programs the loops are software, open source software, various types of important in deciding the complexity. For example in licensing (e.g. GPL, BSD). bubble sort there are two nested loops and in the worst j) Privacy, email etiquette, spam, security issues, case the time taken will be proportional to n(n-1) phising. where n is the number of elements to be sorted. Similarly, in linear search in the worst case the target Social impact and ethical issues should be discussed has to be compared with all the elements so time taken and debated in class. The important thing is for will be proportional to n where n is the number of students to realise that these are complex issues and elements in the search set. their are multiple points of view on many of them and iv) In most algorithms the actual complexity for a there is no single ‘correct’ or ‘right’ view. particular input can vary. For example in search the (Questions on social context of computing and ethical number of comparisons can vary from 1 to n. This issues should be short answer questions and should be means we need to study the best, worst and average asked only in Part I). cases. Comparisons are usually made taking the worst case. Average cases are harder to estimate since it depends on how the data is distributed. For example in search, if the elements are uniformly distributed it will 1121 22 PAPER II - PRACTICAL Continuous Evaluation Programming assignments in Java throughout the year This paper will be evaluated internally by the school. The evaluation shall consist of a 3-hour practical 20 marks examination at the end of the year and evaluation of Terminal Evaluation all assignments done throughout the year. Java solution to programming problem - 60 marks The terminal examination of three hours duration shall consist of three programming problems from which a (Marks should be given for choice of algorithm and candidate has to attempt any one. In each problem a implementation strategy, documentation, correct output candidate will be required to write and execute a Java on known inputs mentioned in the question paper, program on seen and unseen inputs. The program correct output for unknown inputs available only to the should be sufficiently documented so that the examiner.) algorithm and the development process is clear from reading the program. Viva-Voce (based on the programming problem chosen by the student) - 20 marks Teachers should maintain a record of all the 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. and implementation strategy, documentation, Marks (out of a total of 100) will be distributed as correctness, alternative algorithms or implementations. given below: Questions should be confined largely to the problem the student has attempted.) CLASS XII (Scope) There will be two papers in the subject: formulae. Equivalence laws and their use in simplifying wffs. Paper I: Theory- 3 hours …100 marks Propositional variables; the common logical Paper II: Practical- 3 hours …100 marks connectives(∽ (not), ∧ (and), ∨ (or), ⇒ (implication), PAPER I-THEORY ⇔ (biconditional); definition of a well-formed formula Paper 1 shall be of 3 hours duration and be divided (wff); representation of simple word problems as wff into two parts. (this can be used for motivation); the values true and false; interpretation of a wff; truth tables; satisfiable, Part I (30 marks): This part will consist of unsatisfiable and valid formulae. compulsory short answer questions, testing knowledge, application and skills relating to the entire Equivalence laws: commutativity of ∧, ∨; associativity syllabus. of ∧,∨; distributivity; de Morgan’s laws; law of Part II (70 marks): This part will be divided into implication (p ⇒ q ≡ ∽p ∨ q); law of biconditional ((p three Sections, A, B and C. Candidates are required to answer three questions out of four from Section A and ⇔ q) ≡ (p ⇒ q) ∧ (q ⇒ p)); identity (p ≡ p); law of two questions out of three in each of the sections B and C. Each question in this part shall carry 10 negation ( ∽(∽p) ≡ p); law of excluded middle (p ∨ ∽p marks. ≡ true); law of contradiction(p ∧∽p ≡ false); SECTION A simplification rules for ∧, ∨. Boolean Algebra p∨p≡p p∧p≡p a) Propositional logic, well formed formulae, truth values and interpretation of well formed formulae p ∨ true ≡ true p ∧ true ≡ p (wff), truth tables, satisfiable, unsatisfiable and valid p ∨ false ≡ p p ∧ false ≡ false 1131 22 p ∨ (p ∧ q) ≡ p p ∧ (p ∨ q) ≡ p and because it is very well suited for an ‘objects first’ approach. The equivalence rules can be used to simplify Programming in Java (Review of class XI sections propositional wffs, for example: B and C) 1) (p ⇒ q) ∧ (p ⇒ r) to p ⇒ (q ∧ r) Note that items a) to f) will get introduced almost simultaneously when classes and their definitions are 2) ((p ⇒ q) ∧ p) ⇒ q to true introduced. etc. Objects b) Binary valued quantities; basic postulates of a) Objects as data (attributes) + behaviour (methods Boolean algebra; operations AND, OR and NOT; or functions); object as an instance of a class. truth tables. Constructors. c) Basic theorems of Boolean algebra (e.g. Duality, Difference between object and class should be made idempotence, commutativity, associativity, very clear. BlueJ (www.bluej.org) and Greenfoot distributivity, operations with 0 and 1, complements, (www.greenfoot.org) can be profitably used for this absorption, involution); De Morgan’s theorem and its purpose. Constructor as a special kind of function; the applications; reducing Boolean expressions to sum of new operator; multiple constructors with different products and product of sums forms; Karnaugh maps argument structures; constructor returns a reference to (up to four variables). the object. b) Analysis of some real world programming Verify the laws of boolean algebra using truth tables. examples in terms of objects and classes. Inputs, outputs for circuits like half and full adders, majority circuit etc., SOP representation; reduction Use simple examples like a calculator, date, number using Karnaugh maps and boolean algebra. etc. to illustrate how they can be treated as objects that behave in certain well-defined ways and how the Computer Hardware interface provides a way to access behaviour. d) Elementary logic gates (NOT, AND, OR, NAND, Illustrate behaviour changes by adding new functions, NOR, XOR, XNOR) and their use in circuits. deleting old functions or modifying existing functions. e) Applications of Boolean algebra and logic gates to Primitive values, wrapper classes, types and half adders, full adders, encoders, decoders, casting multiplexers, NAND, NOR as universal gates. c) Primitive values and types: int, short, long, float, Show the correspondence between boolean functions double, boolean, char. Corresponding wrapper and the corresponding switching circuits or gates. classes for each primitive type. Class as type of the Show that NAND and NOR gates are universal by object. Class as mechanism for user defined types. converting some circuits to purely NAND or NOR Changing types through user defined casting and gates. automatic type coercion for some primitive types. Ideally, everything should be a class; primitive types SECTION B are defined for efficiency reasons; each primitive type The programming element in the syllabus (sections B has a corresponding wrapper class. Classes as user and C) is aimed at algorithmic problem solving and defined types. In some cases types are changed by not merely rote learning of Java syntax. The Java automatic coercion or casting – e.g. mixed type version used should be 1.5 or later. For programming, expressions. However, casting in general is not a good the students can use any text editor and the javac and idea and should be avoided, if possible. java programs or any development environment: for Variables, expressions example, BlueJ, Eclipse, NetBeans etc. BlueJ is strongly recommended for its simplicity, ease of use d) Variables as names for values; expressions (arithmetic and logical) and their evaluation 1141 22 (operators, associativity, precedence). Assignment theoretic problems, finding roots of algebraic operation; difference between left hand side and right equations). hand side of assignment. Functions are like complex operations where the Variables denote values; variables are already defined object is implicitly the first argument. Variable this as attributes in classes; variables have types that denotes the current object. Functions typically return constrain the values it can denote. Difference between values, they may also cause side-effects (e.g. change variables denoting primitive values and object values attribute values of objects) – typically functions that – variables denoting objects are references to those are only supposed to cause side-effects return void objects. The assignment operator = is special. The (e.g. Set functions). Java passes argument by value. variable on the lhs of = denotes the memory location Illustrate the difference between primitive values and while the same variable on the rhs denotes the object values as arguments (changes made inside contents of the location e.g. i=i+2. functions persist after the call for object values). Static definitions as class variables and class functions Statements, scope visible and shared by all instances. Need for static e) Statements; conditional (if, if-then-else, switch- functions and variables. Introduce the main method – break, ?: ternary operator), looping (for, while-do, needed to begin execution. do-while, continue, break); grouping statements in Arrays, strings blocks, scope and visibility of variables. g) Structured data types – arrays (single and multi- Describe the semantics of the the conditional and dimensional), strings. Example algorithms that use looping statements in detail. Evaluation of the structured data types (e.g. searching, finding condition in conditional statements (esp. difference maximum/minimum, sorting, solving systems of linear between || and | and && and &). Emphasize fall equations, substring, concatenation, length, access to through in switch statement. Many small examples char in string, etc.). should be done to illustrate control structures. Printing different kinds of patterns for looping is instructive. Storing many data elements of the same type requires When number of iterations are known in advance use structured data types – like arrays. Access in arrays is the for loop otherwise the while-do or do-while loop. constant time and does not depend on the number of Express one loop construct using the others. For e.g.: elements. Structured data types can be defined by classes – String. Introduce the Java library String class for (<init>; <test>; <inc>) <stmt>; is equivalent to: and the basic operations on strings (accessing Using while individual characters, various substring operations, <init>; while <test> {<stmt>; <inc> } concatenation, replacement, index of operations). Using do-while h) Basic concept of a virtual machine; Java virtual machine; compilation and execution of Java programs <init>; if !<test> do <stmt>; <inc> while <test>; (the javac and java programs). Nesting of blocks. Variables with block scope, The JVM is a machine but built as a program and not function scope, class scope. Visibility rules when through hardware. Therefore it is called a virtual variables with the same name are defined in different machine. To run, JVM machine language programs scopes. require an interpreter (the java program). The Functions advantage is that such JVM machine language programs (.class files) are portable and can run on any f) Functions/methods (as abstractions for complex machine that has the java program. user defined operations on objects), functions as mechanisms for side effects; formal arguments and i) Compile time and run time errors; basic concept of actual arguments in functions; different behaviour of an exception, the Exception class, catch and throw. primitive and object arguments. Static functions and Differentiate between compile time and run time variables. The this variable. Examples of algorithmic errors. Run time errors crash the program. Recovery is problem solving using functions (various number possible by the use of exceptions. Explain how an exception object is created and passed up until a 1151 22 matching catch is found. This behaviour is different whitespace and user defined characters as delimiters. from the one where a value is returned by a deeply As an example show how the StringTokenizer class nested function call. It is enough to discuss the allows one to extract a sequence of tokens from a Exception class. Sub-classes of Exception can be string with user defined delimiters. discussed after inheritance has been done in class XII. m) Concept of recursion, simple recursive functions j) Class as a contract; separating implementation (e.g. factorial, GCD, binary search, conversion of from interface; encapsulation; private and public. representations of numbers between different bases). Class is the basic reusable unit. Its function prototypes Many problems can be solved very elegantly by (i.e. the interface) work as a visible contract with the observing that the solution can be composed of outside world since others will use these functions in solutions to ‘smaller’ versions of the same problem their programs. This leads to encapsulation (i.e. hiding with the base version having a known simple solution. implementation information) which in turn leads to Recursion can be initially motivated by using the use of private and public for realizing recursive equations to define certain functions. These encapsulation. definitions are fairly obvious and are easy to understand. The definitions can be directly converted k) Interfaces in Java; implementing interfaces through to a program. Emphasize that any recursion must have a class; interfaces for user defined implementation of a base case. Otherwise, the computation can go into an behaviour . infinite loop. Illustrate this by removing the base case Motivation for interface: often when creating reusable and running the program. Examples: classes some parts of the exact implementation can 1) Definition of factorial: only be provided by the final end user. For example in a class that sorts records of different types the exact factorial(0) = 1 //base case comparison operation can only be provided by the end factorial(n) = n * factorial(n-1) user. Since only he/she knows which field(s) will be used for doing the comparison and whether sorting 2) Definition of GCD: should be in ascending or descending order be given gcd(m, n) = by the user of the class. if (m==n) then n //base case Emphasize the difference between the Java language construct interface and the word interface often used else if (m>n) then gcd(m-n, n) to describe the set of function prototypes of a class. else gcd(m, n-m) l) Basic input/output using Scanner and Printer 3) Definition of Fibonacci numbers: classes from JDK; files and their representation using the File class, file input/output; input/output fib(0) = 1 //base case exceptions. Tokens in an input stream, concept of fib(1) = 1 //base case whitespace, extracting tokens from an input stream (StringTokenizer class). fib(n) = fib(n-1)+ fib(n-2) The Scanner class can be used for input of various The tower of Hanoi is a very good example of how types of data (e.g. int, float, char etc.) from the recursion gives a very simple and elegant solution standard input stream or a file input stream. The File where as non-recursive solutions are quite complex. class is used model file objects in the underlying Discuss the use of a stack to keep track of function system in an OS independent manner. Similarly, the calls. A stack can also be used to solve the tower of Printer class handles output. Only basic input and Hanoi problem non-recursively. output using these classes should be covered. Discuss the concept of a token (a delimited continuous SECTION C stream of characters that is meaningful in the application program – e.g. words in a sentence where Inheritance, polymorphism, data structures, the delimiter is the blank character). This naturally computational complexity leads to the idea of delimiters and in particular Inheritance and polymorphism 1161 22 a) Inheritance; base and derived classes; member void push(Object o) access in derived classes; redefinition of variables and functions in subclasses; abstract classes; class Object pop() Object; protected visibility. Subclass polymorphism boolean isEmpty() and dynamic binding. Object top() Emphasize the following: Then, for example the LIFO property can be - inheritance as a mechanism to reuse a class by expressed by (assume s is a stack): extending it. - inheritance should not normally be used just to reuse if s.push(o); o1=pop() then o ≡ o1 some functions defined in a class but only when there is a genuine specialization (or subclass) relationship What the rule says is: if o is pushed on the stack s between objects of the base class and that of the and then it is popped and o1 is the object obtained derived class. then o, o1 are identical. - Allows one to implement operations at the highest Another useful property is: relevant level of abstraction. if s.isEmpty() == true then s.pop() = ERROR - Freezes the interface in the form of abstract classes It says that popping an empty stack gives ERROR. with abstract functions that can be extended by the concrete implementing classes. For example, an Similarly, several other properties can also be abstract class Shape can have an abstract function specified. It is important to emphasize the behavioural draw that is implemented differently in the sub-classes rules or properties of a data structure since any like Circle, Quadrilateral etc. implementation must guarantee that the rules hold. - how the exact function call at run time depends on Some simple algorithms that use the data structures: the type of the object referenced by the variable. This i) For stack: parentheses matching, tower of Hanoi, gives sub-class polymorphism. For example in the nested function calls; solving a maze. code fragment: ii) For queue: scheduling processes, printers, jobs in a Shape s1=new Circle(), s2=new Quadrilateral(); machine shop. s1.draw(); //the draw is the draw in Circle c) Recursive data structures: singly and doubly linked s2.draw(); //the draw is the draw in Quadrilateral lists, binary trees, tree traversals, binary search tree. Algorithms using these data structures (merge sort the two draw function invocations on s1, s2 invoke and quick sort, searching. different draw functions depending on the type of objects referenced by s1 and s2 respectively. Data structures should be defined as abstract data types with a well defined interface (it is instructive to Data structures define them using the Java interface construct) – see b) Basic data structures (stack, queue, dequeue); the comments in b) above. Emphasize that algorithms implementation directly through classes; definition for recursive data structures are themselves recursive through an interface and multiple implementations and that algorithms are usually the simplest and most by implementing the interface. Basic algorithms using elegant. The following should be covered for each the above data structures. data structure: A data structure is a data collection with well Lists: insertion, deletion, reversal, appending two lists, defined operations and behaviour or properties. extracting an element or a sublist, checking The behaviour or properties can usually be emptiness. Searching, sorting (by quicksort and expressed formally using equations or some kind mergesort algorithms), binary search in a sorted list. of logical formulae. Consider for e.g. a stack with Binary trees: apart from the definition the following operations defined as follows: concepts should be covered external and internal nodes, height, completeness, balancing, Traversals 1171 22 (pre, post and in-order). Implementation using arrays is taken over a statistically significant number of and linked structures. instances. Binary search tree: insertion, deletion, search. v) Comparisons are normally made for large values of the input size. This means that the dominant term in Complexity and big O notation the function is the important term. For example if we d) Concrete computational complexity; concept of are looking at bubble sort and see that time taken can input size; estimating complexity in terms of functions; be estimated as: a*n2 +b*n + c where n is the number importance of dominant term; best, average and worst of elements to be sorted and a, b, c are constants then case. Big O notation for computational complexity; for large n the dominant term is clearly n2 and we can, analysis of complexity of example algorithms using in effect, ignore the other two terms. the big O notation (e.g. Various searching and sorting All the above motivates the big O notation. Let f(n), algorithms, algorithm for solution of linear equations g(n) be positive functions, then f(n) is said to be etc.). O(g(n)) if there exists constants c, n0 such that f(x)≤ Points to be given particular emphasis: c*g(n) whenever n>n0. What this means is that g(n) i) Algorithms are usually compared along two asymptotically dominates f(n). Expressing time dimensions – amount of space (that is memory) used complexity using the big O notation gives us an and the time taken. Of the two the time taken is abstract basis for comparison and frees us from usually considered the more important. The bothering about constants. So the estimated time motivation to study time complexity is to compare complexity a*n2+b*n+c is O(n2). different algorithms and use the one that is the most Analyse the big O complexity of the algorithms efficient in a particular situation. pertaining to the data structures in parts b) and c) ii) Actual run time on a particular computer is not a above. good basis for comparison since it depends heavily on the speed of the computer, the total amount of RAM Implementation of algorithms to solve problems in the computer, the OS running on the system and the The students are required to do lab assignments in the quality of the compiler used. So we need a more computer lab concurrently with the lectures. abstract way to compare the time complexity of Programming assignments should be done such that algorithms. each major topic is covered in at least one assignment. iii) This is done by trying to approximate the number Assignment problems should be designed so that they of operations done by each algorithm as a function of are non-trivial and make the student do algorithm the size of the input. In most programs the loops are design, address correctness issues, implement and important in deciding the complexity. For example in execute the algorithm in Java and debug where bubble sort there are two nested loops and in the worst necessary. case the time taken will be proportional to n(n-1) where n is the number of elements to be sorted. Similarly, in linear search in the worst case the target has to be compared with all the elements so time taken PAPER II - PRACTICAL will be proportional to n where n is the number of elements in the search set. This paper of three hours duration will be evaluated by the teacher and a Visiting Examiner appointed iv) In most algorithms the actual complexity for a locally and approved by the Council. particular input can vary. For example in search the number of comparisons can vary from 1 to n. This The paper shall consist of three programming means we need to study the best, worst and average problems from which a candidate has to attempt any cases. Comparisons are usually made taking the worst one. In each problem a candidate will be required to case. Average cases are harder to estimate since it write and execute a Java program on seen and unseen depends on how the data is distributed. For example in inputs. The program should be sufficiently search, if the elements are uniformly distributed it will documented so that the algorithm, representation and take on the average n/2 comparisons when the average 1181 22 development process is clear from reading the A white board with white board markers should program. be available. Marks (out of a total of 100) should be distributed as A fully equipped Computer Laboratory that given below: allows one computer per student. Continuous Evaluation Internet connection for accessing the World Wide Candidates will be required to submit a work file Web and email facility. containing the practical work related to programming The computers should have a minimum of 256 assignments done during the year. MB (512MB preferred) RAM and a PIII or higher Programming assignments done throughout the year processor. The basic requirement is that it should (Internal evaluation) - 10 marks run the operating system and Java programming Programming assignments done throughout the year system (Java compiler, Java runtime environment, (Visiting Examiner) - 10 marks Java development environment) at acceptable speeds. Terminal Evaluation Solution to programming problem on the computer Good Quality printers. 60 marks Software: (Marks should be given for choice of algorithm and Any suitable Operating System can be used. implementation strategy, documentation, correct output on known inputs mentioned in the question paper, JDK 1.5 or later. correct output for unknown inputs available only to the Documentation for the JDK version being used. examiner.) Viva-voce - 20 marks A suitable text editor. A development environment with a debugger is preferred (e.g. (Viva-voce includes questions on the following BlueJ, Eclipse, NetBeans). BlueJ is recommended aspects of the problem attempted by the student: the for its ease of use and simplicity. algorithm and implementation strategy, documentation, correctness, alternative algorithms or implementations. Questions should be confined largely to the problem the student has attempted.) EQUIPMENT There should be enough computers to provide for a teaching schedule where at least three-fourths of the time available is used for programming. Schools should have equipment/platforms such that all the software required for practical work runs properly, i.e. it should run at acceptable speeds. Since hardware and software evolve and change very rapidly, the schools may have to upgrade them as required. Following are the recommended specifications as of now: The Facilities: A lecture cum demonstration room with a MULTIMEDIA PROJECTOR/ an LCD and O.H.P. attached to the computer. 1191 22

DOCUMENT INFO

Shared By:

Categories:

Tags:
International Workshop, Lecture Notes in Computer Science, High-Speed Communication, Computer Science, Communication Architectures, Second International, Georg Carle, International Conference, Ralf Steinmetz, java programs

Stats:

views: | 9 |

posted: | 4/15/2010 |

language: | English |

pages: | 13 |

OTHER DOCS BY liuqingzhan

How are you planning on using Docstoc?
BUSINESS
PERSONAL

By registering with docstoc.com you agree to our
privacy policy and
terms of service, and to receive content and offer notifications.

Docstoc is the premier online destination to start and grow small businesses. It hosts the best quality and widest selection of professional documents (over 20 million) and resources including expert videos, articles and productivity tools to make every small business better.

Search or Browse for any specific document or resource you need for your business. Or explore our curated resources for Starting a Business, Growing a Business or for Professional Development.

Feel free to Contact Us with any questions you might have.