# ISC Computer Science 2015 Class-12 Previous Year Question Papers Solved

**Question 12.**

A line on a plane can be represented by coordinates of the two-end points p_{1} and p_{2} as p_{1}(x_{1}, y_{1}) and p_{2}(x_{2}, y_{2}).

A superclass Plane is defined to represent a line and a subclass Circle to find the length of the radius and the area of the circle by using the required data members of the superclass. [10]
**Some of the members of both classes are given below:**

**Class name**: Plane

**Data members/instance variables:**

**x _{1}**: to store the x-coordinate of the first endpoint

**y**to store the y-coordinate of the first endpoint

_{1}:**Member functions/methods:**

**Plane (int nx, int ny**): parameterized constructor to assign the data members x

_{1}= nx and y

_{1}= ny

**void show()**: to display the coordinates

**Class name:**Circle

**Data members /instance variables:**

**x**to store the x-coordinate of the second endpoint

_{2}:**y**to store the y-coordinate of the second endpoint

_{2}:**radiu**s: double variable to store the radius of the circle

**are**a: double variable to store the area of the circle

**Member functions/methods:**

**Circle(…)**: parameterized constructor to assign values to data members of both the classes

void findRadius(): to calculate the length of the radius using the formula:

assuming that x

_{1}, x

_{2}, y

_{1}, y

_{2}are the coordinates of the two ends of the diameter of a circle

**voidfindArea():**to find the area of a circle using the formula: πr

^{2}. The value of pie(π) is 22/7 or 3.14

**void show()**: to display both the coordinates along with the length of the radius and area of the circle

Specify the class Plane giving details of the constructor and void show() Using the concept of inheritance, specify the class Circle giving details of the constructor, void findRadius(), void find Area() and voidShow()

**The main function and algorithm need not be written.**

**Answer 12:**

class Plane { int x1; int y1; public Plane(int nx, int ny) { x1=nx; y1=ny; } public void show() { System.out.println("P1: "+x1 +", "+y1); } } class Circle extends Plane{ int x2; int y2; double radius; double area; public Circle(int nx1, int ny1, int nx2, int ny2) { super(nx1, nx2); x2=nx2; y2=ny2; } public void fmdRadius() { radius=Math.sqrt(Math.pow((x2-x1), 2)+Math.pow((y2-y1), 2))/2.0; } public void findArea() { area=Math.Pi*radius*radius; } public void show(){ super. show(); System.out.println("P2: "+x2+", "+y2); System.out.println("Radius:"+radius); System.out.println("Area: "+area); } } class Coordinate { //main method created so that the program can be executed public static void main(String args[]) { Circle obj=new Circle(2, 3, 4, 5); obj.findRadius(); obj.findArea(); obj.show(); } }

**Question 13.**

**(a) A linked list is formed from the objects of the class: [4]**

class Nodes { int num; Node next; }

Write an Algorithm OR a Method to print the sum of nodes that contains only odd integers of an existing linked list.

**The method declaration is as follows:**

void NodesCount (Nodes starPtr)

**(b) **

**(i) Give the meaning of the following common expression in Big O notation: [1]**

O(N)

O(N^{2})

(ii) List any two cases to analyse algorithm complexities. [1]
**(c) Answer the following from the diagram of a Binary Tree given below:**

(i) Name the leaf nodes of the right sub-tree. [1]
(ii) Write postorder traversal of the left subtree of node B including itself. [1]
(iii) State the level number of nodes R and M when the root is at level 0. [1]
(iv) Name the internal nodes of the tree. [1]
**Answer 13:**

(a) public void nodesCount(Nodes startPtr) { int sum=0; while(startPtr!=null) { if(startPtr.num%2=1) sum=sum+startPtr.num; startPtr=startPtr.next; } System.out.println(sum); }

(b)

(i) O(N) is a computational complexity which is Linear in nature.

O(N^{2}) is a computational complexity which is Quadratic in nature.

(ii) Two cases to analyze algorithm complexities: Worst Case, Best Case.

(c)

(i) Nodes P and E are the leaf nodes of the right sub-tree.

(ii) R, N, M, C, B is the required post-order traversal.

(iii) 2

(iv) C, F, M, H are the internal nodes.

-: End of** ISC Computer Science 2015 Class-12** Solved Paper :-

Return to – ISC Class-12 Solved Previous Year Question Paper

Thanks

Please Share with Your Friends

**Read Next 👇 Click on Page Number Given Below 👇**