ISC Computer Science Theory Paper
PART A
(Attempt all questions)
Ques 1. Questions based on Boolean Algebra, Prepositional Logic
(5 sub-parts * 2 = 10 marks)
Ques 2. Questions based on Array address calculation, Implementation of Stacks in Algebraic
expression, interface, dynamic binding, exception, computation complexity
Ques 3. Output question have 2 parts of 5 marks each (Atleast one based on recursion)
PART 2
Section A (Attempt any three questions)
Ques 4. Question based on K-Map along with logic gate circuit (1 SOP and 1 POS)
Ques 5. Question based situation - Draw truth table, Reduce using K-Map and draw logic circuit
Ques 6. Question based on Hardware - Half and Full Adder, Decoder, Encoder and Multiplexer
Ques 7. Question on Truth table, Prepositional logic and Laws of Boolean Algebra
Section B (Attempt any two questions)
Ques 8. Object passing / general programs
Ques 9. Strings / Array
Ques 10. Recursion
Section C (Attempt any two questions)
Ques 11. Inheritance
Ques 12. Stacks / Queue
Ques 13. Binary Tree (Tree traversal) and Algorithm on Linked List
Sharing Knowledge
Monday, March 12, 2012
ISC Computer Science Theory Paper - Structure
Thursday, February 23, 2012
Wednesday, February 22, 2012
MOBIUS function
M( N) = 1 if N = 1
= 0 if any prime factor of N is contained in N more than once
= ( -1)^ P if N is a product of p distinct prime factors
Example :
M( 78) = -1 ( for 78 = 2 * 3 * 13 M( 78) = ( -1)^ 3 = -1 )
M( 34) = 1 ( for 34 = 2 * 17 M( 34) = ( -1) ^2 = 1 )
M( 12) = 0 ( for 12 = 2 * 2 * 3 M( 12) = 0 for 2 appears two times)
M( 17) = -1 ( for 17 = 17 M( 17) = ( -1)^ 1 = -1 )
Write a program to input natural number N and output M( N).
import java.io.*;
class MobiusFn
{
BufferedReader ob = new BufferedReader(new InputStreamReader(System.in));
int n,a,p,c,q;
public MobiusFn()
{
a=2;
p=0;
c=0;
}
public void input() throws IOException
{
System.out.println("Enter a number ");
n=Integer.parseInt(ob.readLine());
}
public int primefac(int x)
{
if(x==1) return 1;
while(x>1)
{
c=0;
while(x%a==0)
{
c++;
p++;
System.out.println("Prime Fator is "+a);
x=x/a;
}
if(c>1) return 0;
a++;
}
q=(int)Math.pow(-1,p);
return q;
}
public void display()
{
int r=primefac(n);
if(r==0) System.out.println("Prime factor of N is contained in N more than once. Mobius function returns " + r );
else System.out.println("Mobius function returns value " + r);
}
public static void main(String arg[]) throws IOException
{
MobiusFn obj = new MobiusFn();
obj.input();
obj.display();
}
}
Number combination - Expected question 2012
Output : Given number 5
Combinations :
1 1 1 1 1
1 1 1 2
1 2 2
1 1 3
1 4
2 3
import java.io.*;
class numcombi
{
String str="";
int a=0;
int b=0;
public void combi() throws IOException
{
BufferedReader br = new BufferedReader(new InputStreamReader(System.in));
System.out.print("Enter a number : ");
int num = Integer.parseInt(br.readLine());
System.out.println("Combinations :");
for(int i=1;i<=num/2;i++)
{
str="";
extract(num,i);
}
}
public void extract(int n, int m)
{
a=m;
str+=" "+a;
b=n-a;
System.out.println(str+" "+b);
if(b<=m)
{
return;
}
extract(b,m);
}
public static void main(String arg[]) throws IOException
{
numcombi obj= new numcombi();
obj.combi();
}
}
Sunday, February 19, 2012
Sum of two Binary numbers
class BinarySum
{
public int n,m,p,q,r;
public void input()
{
// two binary numbers added by converting into decimal
// and sum then converted into binary
Scanner br = new Scanner(System.in);
System.out.println(" Input a binary number n");
n=br.nextInt();
System.out.println(" Input a binary number m");
m=br.nextInt();
}
public void calculate()
{
p=bintodec(n);
q=bintodec(m);
if(p== -1 || q== -1)
System.out.println("INVALID BINARY VALUE ");
else
{
System.out.println("Binary number " + n + " in decimal is " + p);
System.out.println("Binary number " + m + " in decimal is " + q);
r=sumbin(p+q);
System.out.println("Sum of two binary number " + n + " and " + m + " is " + r);
}
}
public int bintodec(int x)
{
int a,s=0, i=0;
while(x>0)
{
a=x%10;
if(a>1) return -1;
s = s + (int)Math.pow(2,i)*a;
x=x/10;
i++;
}
return s;
}
public int sumbin(int x)
{
int a,s=0, i=0;
while(x>0)
{
a=x%2;
s = s + (int)Math.pow(10,i)*a;
x=x/2;
i++;
}
return s;
}
public static void main(String arg[])
{
BinarySum ob= new BinarySum();
ob.input();
ob.calculate();
}
}
Two decimal numbers converted into binary and sum in binary form
class BinaryAdd
{
public int n,m,p,q,r;
public void input()
{
// two decimal numbers converted into binary
// and sum is also converted into binary
Scanner br = new Scanner(System.in);
System.out.println(" Input a number n");
n=br.nextInt();
System.out.println(" Input a number m");
m=br.nextInt();
}
public void calculate()
{
p=decbin(n);
q=decbin(m);
System.out.println("Binary value for " + n + " is " + p);
System.out.println("Binary value for " + m + " is " + q);
r=sumbin(m+n);
System.out.println("Sum of two binary number " + p + " and " + q + " is " + r);
}
public int decbin(int x)
{
int a,s=0, i=0;
while(x>0)
{
a=x%2;
s = s + (int)Math.pow(10,i)*a;
x=x/2;
i++;
}
return s;
}
public int sumbin(int x)
{
int a,s=0, i=0;
while(x>0)
{
a=x%2;
s = s + (int)Math.pow(10,i)*a;
x=x/2;
i++;
}
return s;
}
public static void main(String arg[])
{
BinaryAdd ob= new BinaryAdd();
ob.input();
ob.calculate();
}
}
Decimal number to binary conversion
class dectobin
{
public int n,m,s,i,a;
public void input()
{
Scanner br = new Scanner(System.in);
System.out.println(" Input anumber n");
n=br.nextInt();
}
public void calculate()
{
s=0;
i=0;
m=n;
while(n>0)
{
a=n%2;
s = s + (int)Math.pow(10,i)*a;
n=n/2;
i++;
}
System.out.println("Binary value for " + m + " is " + s);
}
public static void main(String arg[])
{
dectobin ob= new dectobin();
ob.input();
ob.calculate();
}
}
