Total Pageviews

Sunday, July 23, 2023

ISCE- LIST OF PROGRAMS

1 Magic number CLICK
2 Happy number CLICK
3 Fibonacci series CLICK
4 Check twin prime from a series CLICK
5 Armstrong number CLICK
6 Automorphic number CLICK
7 decimal to binary conversion CLICK
8 a+a/2! +a/3! +a/4! +.... n th term
9 neon number in java CLICK
10 KaprekarNumbers CLICK
11 Fascinating Number CLICK
12 square Matrix CLICK
13 string having repeating characters CLICK
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
PATTERN * * * * * * * * * * *

ISCE

 THEORY

APC BOOK

PRACTICAL


PROJECT


SAMPLE COPY



UNION MAKE SET FIND SET


 













void make_set(int v) {
    parent[v] = v;
}

int find_set(int v) {
    if (v == parent[v])
        return v;
    return find_set(parent[v]);
}

void union_sets(int a, int b) {
    a = find_set(a);
    b = find_set(b);
    if (a != b)
        parent[b] = a;
}











There are two ways to improve it: 
1. Path Compression
2. Union by Rank










DAA

 The divide-and-conquer approach

DEFINITION-LINK

merge sort--LINK


SORT:

merge sort--LINK


GRAPH:

UNION MAKE SET FIND SET---LINK

PRIMS--

KRUSKAL--

DYSTRAS--

DFS--

BFS--

FLOYD--

WARSHALL--

WRAPPER CLASS

 Wrapper Classes-INTRODUCTION  CLICK

WRAPPER CLASS-AUTOBOX UNBOX  CLICK

WRAPPER CLASS-INTEGER  CLICK

WRAPPER CLASS-CHARACTER  CLICK

ARTIFICIAL INTELLIGENCE

 THOERY ---LINK

PRACTICAL---

CHAPTER WISE QUESTION----

ASSIGNMENT----

CBCS SYLLABUS-----

FOL PRACTISE--LINK


Saturday, July 22, 2023

GRAPHICS ADVANCED LEARNER

 1.

The Cohen-Sutherland Algorithm

2.

The Sutherland-Hodgman Algorithm

3.

Midpoint Subdivision Algorithm

GRAPHICS SLOW LEARNER

AI-SLOW LEARNER

AI-ADVANCED LEARNER

 

1.

If P represents 'This book is good' and Q represents 'This book is cheap', write the following sentences in symbolic form:

(a) This book is good and cheap.

(b) This book is not good but cheap.

(c) This book is costly but good.

(d) This book is neither good nor cheap.

(e) This book is either good or cheap.

 

2.

Translate the following sentences into propositional forms:

(a) If it is not raining and I have the time. then I will go to a movie.

(b) It is raining and I will not go to a movie.

(c) It is not raining.

(d) I will not go to a movie.

(e) I will go to a movie only if it is not raining.

Hints:

 Let P be the proposition 'It is raining'.

Let Q be the proposition 'I have the time'.

Let R be the proposition '1 will go to a movie'.

 

3.

Write the following sentences in symbolic form: (

a) This book is interesting but the exercises are difficult.

(b) This book is interesting but the subject is difficult.

(c) This book is not interesting. the exercises are difficult but the subject is not difficult.

(d) If this book is interesting and the exercises are not difficult then the subject is not difficult.

(e) This book is interesting means that the subject is not difficult, and conversely.

(f) The subject is not difficult but this book is interesting and the exercises are difficult.

(g) The subject is not difficult but the exercises are difficult.

(h) Either the book is interesting or the subject is difficult.

 

 

4.

Derive S from the following premises using a valid argument:

(i)                  P => Q

(ii)                Q => ¬R

(iii)               P v S

(iv)               R

 

5.

Check the validity of the following argument:

If Ram has completed B.E. (Computer Science) or MBA, then he is assured of a good job.

 If Ram is assured of a good job, he is happy.

Ram is not happy.

So Ram has not completed MBA.

 

6.

Express the following sentences involving predicates in symbolic form:

1. All students are clever.

2. Some students are not successful.

3. Every clever student is successful.

4. There are some successful students who are not clever.

5. Some students are clever and successful.

7.

Discuss the validity of the following argument:

All educated persons are well behaved.

Ram is educated.

No well-behaved person is quarrelsome.

Therefore. Ram is not quarrelsome.

8.

Test the validity of the following argument:

Babies are illogical.

Nobody is despised who can manage a crocodile.

Illogical persons are despised.

Therefore babies cannot manage crocodiles.

 

9.

Show that the following argument is valid:

All men are mortal.

Socrates is a man.

So Socrates is mortal.

 

10.

Test the validity of the following argument:

If Ram is clever then Prem is well-behaved.

If Joe is good then Sam is bad and Prem is not well-behaved.

If Lal is educated then Joe is good or Ram is clever.

Hence if Lal is educated and Prem is not well-behaved then Sam is bad.

Monday, July 17, 2023

15. Write a Prolog program to implement maxlist(List,Max) so that Max is the greatest number in the list of numbers List using cut predicate.

 15. Write a Prolog program to implement maxlist(List,Max) so that Max is the greatest number in the list of numbers List using cut predicate. 


maxlist([H],H).

maxlist([H|T],R):-

maxlist(T,M1),

 H>=M1,

 R is H,!.

maxlist([H|T],R):-

maxlist(T,M1),

 H<M1,

 R is M1.


OUTPUT:.

maxlist([1,20,2],X).

X = 20

 



16. Write a Prolog program to implement GCD of two numbers.

 16. Write a Prolog program to implement GCD of two numbers. 


gcd(X,0,X).

gcd(X,Y,Z):-

 R is mod(X,Y),

gcd(Y,R,Z).

OUTPUT:

gcd(6,9,X).

X = 3


17. Write a prolog program that implements Semantic Networks/Frame Structures.

 17. Write a prolog program that implements Semantic Networks/Frame Structures.




OUTPUT:

11. Write a Prolog program to implement maxlist(List,Max) so that Max is the greatest number in the list of numbers List.

 11. Write a Prolog program to implement maxlist(List,Max) so that Max is the greatest number in the list of numbers List.


max([H|T],R):-

 length(T,L),

 L>0 -> (  max(T,R1),  (   H > R1 ->     R is H    ;     R is R1  ) ) ; R is H.



OUTPUT:

max([6,9,7],X).

X = 9

max([6,9,70],X).

X = 70


10. Write a Prolog program to implement max(X,Y,Max) so that Max is the greater of two numbers X and Y.

 10. Write a Prolog program to implement max(X,Y,Max) so that Max is the greater of two numbers X and Y.


max(X,Y,R):-

 X>=Y ->

  R is X,

  write(R)

 ;

  R is Y,

  write(R).

 

OUTPUT:

max(2,6,X).

6

X = 6



12. Write a Prolog program to implement sumlist(List,Sum) so that Sum is the sum of a given list of numbers List.

  12. Write a Prolog program to implement sumlist(List,Sum) so that Sum is the sum of a given list of numbers List. 


sumlist([],0).

 

sumlist([H|T],R):-

sumlist(T,R1),

  R is H+R1.

OUTPUT:

sumlist([6,9,70],X).

X = 85


14. Write a Prolog program to implement reverse(List,ReversedList) that reverses lists.

 14. Write a Prolog program to implement reverse(List,ReversedList) that reverses lists. 


reverse([],[]).

reverse([X|T],REV):-reverse(T,R),append(R,[X],REV).


OUTPUT:


reverse([1,2,2],X).

X = [2, 2, 1]


13. Write a Prolog program to implement two predicates evenlength(List) and oddlength(List) so that they are true if their argument is a list of even or odd length respectively.

 13. Write a Prolog program to implement two predicates evenlength(List) and oddlength(List) so that they are true if their argument is a list of even or odd length respectively. 

evenlength:-

write('true --> even').

oddlength:-

write('true --> odd').

 

oddeven([_|T]):- length(T,L), L>=0 -> (  L1 is L+1,  L2 is mod(L1,2),  L2=:=0 ->evenlength  ;   oddlength ).




OUTPUT:

 

oddeven([5,8,9]).

true --> odd

1true

oddeven([5,8,6,9]).

true --> even

1true

 



8. Write a Prolog program to implement append for two lists.

  8. Write a Prolog program to implement append for two lists.

app([],L,L).

app([X|M],N,[X|Q]):-

 app(M,N,Q).



OUTPUT:

app([1,2],[3,4],X).

X = [1, 2, 3, 4]

app([1,2],[],X).

X = [1, 2]

 


7. Write a Prolog program, remove-nth(Before, After) that asserts the After list is the Before list with the removal of every n‘th item from every list at all levels.

 7. Write a Prolog program, remove-nth(Before, After) that asserts the After list is the Before list with the removal of every n‘th item from every list at all levels.


del(1,[_|T],T).

del(P,[X|Y],[X|R]):-

 P1 is P-1,

 del(P1,Y,R).



dalpos(P,L,R):-

 P1 is P-1,

 del(P1,L,R1),

 del(P,R1,R).


OUTPUT:


del(2,[10,20,30,40],X).

X = [10, 30, 40]

Next101001,000 Stop


9. Write a Prolog program to implement palindrome (List).

 9. Write a Prolog program to implement palindrome (List). 


pal([]):- write('palindrome').

pal([_]):- write('palindrome').

pal(L) :-

 append([H|T], [H], L),

 pal(T) ;write('Not a palindrome').


OUTPUT:

pal([1,2,1]).

palindrome

1true

Next101001,000 Stop

pal([1,2,2]).

Not a palindrome

1true


6. Write a Prolog program to remove the Nth item from a list.

 6. Write a Prolog program to remove the Nth item from a list. 

del(1,[_|T],T).

del(P,[X|Y],[X|R]):-

 P1 is P-1,

 del(P1,Y,R).


OUTPUT:

del(2,[1,2],X).

X = [1]

Next101001,000 Stop

del(3,[1,2,3,4],X).

X = [1, 2, 4]

Next101001,000 Stop

del(5,[1,2,3,4],X).

false


5. Write a prolog program, insert_nth(item, n, into_list, result) that asserts that result is the list into_list with item inserted as the n‘th element into every list at all levels.

 5. Write a prolog program, insert_nth(item, n, into_list, result) that asserts that result is the list into_list with item inserted as the n‘th element into every list at all levels. 


insert_nth(Item,1,List,[Item|List]).

insert_nth(Item,Pos,[H|List],[H|Result]):-Pos1 is Pos-1,insert_nth(Item,Pos1,List,Result).





OUTPUT:

insert_nth(5,1,[2],X).
X = 2


insert_nth(5,1,[9,8,7,6],Y).
Y = [59876]

4. Write a prolog program to calculate the nth Fibonacci number.

 4. Write a prolog program to calculate the nth Fibonacci number. 


fib(0, 1) :- !.

fib(1, 1) :- !.

fib(N, F) :-        N > 1,        N1 is N-1,        N2 is N-2,        fib(N1, F1),        fib(N2, F2),        F is F1+F2.



OUTPUT:

fib(5N.
N = 8

3. Write a prolog program to calculate the factorial of a given number.

 3. Write a prolog program to calculate the factorial of a given number. 


fact(0,1).

fact(N,F):-(  N>0,  N1 is N-1, fact(N1,F1),  F is N*F1).



OUTPUT:

fact(5,N).

N = 120

Next101001,000 Stop


2. Write a prolog program to find the maximum of two numbers.

 2. Write a prolog program to find the maximum of two numbers.


max(X,Y):-(   X=Y ->write('both are equal') ;

 X>Y ->  (  Z is X,   write(Z), write('  is max')  )

  ;

  (  Z is Y,   write(Z),write(' is max')  ) ).


OUTPUT:

max(50,50).

both are equal

1true

max(50,5).

50is max

1true