Green CSE : OCET 2007-2011

Saturday, March 3, 2012

MAGICAL BOOK........

Type anything in that book, it will reply .
Type your question on the book - it will reply. Type on the right side
where you can see the cursor .
 Make sure you type the correct words and do not make spelling
mistakes... too good!!!! TRY THE MAGICAL BOOK...HUUUUUU.. think that book
is me....
             Click : Magical Book


Monday, February 27, 2012

!!!..... English Daily ...!!!

  1. Conversations , Stories, Proverbs, Slang, Grammar..........
  2. Verb Tense Tutorial..
  3. English Reading Room
    • Free Online Newspapers
    • Free Online Magazines
    • Free Online Books and Literature
    • Free Online Reference Materials
    • Online Libraries

...... Android OS ....

>>>>> Java >>>>>

Java Hub : java ebooks, jobs etc.,  click here : Java hub


Java : 
  • Java is a programming language originally developed by James Gosling at Sun Microsystems (which has since merged into Oracle Corporation) and released in 1995 as a core component of Sun Microsystems' Java platform.
  • Java applications are typically compiled to bytecode (class file) that can run on any Java Virtual Machine (JVM) regardless of computer architecture. 

Object :  An object is a simulation of the real-world entities.
 To work with objects, we should be able to identify three key characteristics of objects:
The object's behavior— what can you do with this object, or what methods can you apply to it?
The object's state— how does the object react when you apply those methods?
The object's identity— how is the object distinguished from others that may have the same
behavior and state?


Class :
  Classes act as templates for the objects. Classes are structures that holds the member fields and member functions of the object.



Sorting Algorithms

Bubble Sort ==> Click here : Definition and Example in Java
Example in C :
#include <stdio.h>
#include <conio.h>
void main( )
{
int arr[5] = { 25, 17, 31, 13, 2 } ;
int i, j, temp ;
clrscr( ) ;
printf ( "Bubble sort.\n" ) ;
printf ( "\nArray before sorting:\n") ;
for ( i = 0 ; i <= 4 ; i++ )
printf ( "%d\t", arr[i] ) ;
for ( i = 0 ; i <= 3 ; i++ )
{
for ( j = 0 ; j <= 3 - i ; j++ )
{
if ( arr[j] > arr[j + 1] )
{
temp = arr[j] ;
arr[j] = arr[j + 1] ;
arr[j + 1] = temp ;
}
}
}
printf ( "\n\nArray after sorting:\n") ;
for ( i = 0 ; i <= 4 ; i++ )
printf ( "%d\t", arr[i] ) ;
getch( ) ;
}


Example in C :
#include <stdio.h>
#include <conio.h>
void main( )
{
int arr[5] = { 25, 17, 31, 13, 2 } ;
int i, j, temp ;
clrscr( ) ;
printf ( "Selection sort.\n" ) ;
printf ( "\nArray before sorting:\n") ;
for ( i = 0 ; i <= 4 ; i++ )
printf ( "%d\t", arr[i] ) ;
for ( i = 0 ; i <= 3 ; i++ )
{
for ( j = i + 1 ; j <= 4 ; j++ )
{
if ( arr[i] > arr[j] )
{
temp = arr[i] ;
arr[i] = arr[j] ;
arr[j] = temp ;
}
}
}
printf ( "\n\nArray after sorting:\n") ;
for ( i = 0 ; i <= 4 ; i++ )
printf ( "%d\t", arr[i] ) ;
getch( ) ;
}


Example in C :
#include <stdio.h>
#include <conio.h>
void main( )
{
int arr[5] = { 25, 17, 31, 13, 2 } ;
int i, j, k, temp ;
clrscr( ) ;
printf ( "Insertion sort.\n" ) ;
printf ( "\nArray before sorting:\n") ;
for ( i = 0 ; i <= 4 ; i++ )
printf ( "%d\t", arr[i] ) ;
for ( i = 1 ; i <= 4 ; i++ )
{
for ( j = 0 ; j < i ; j++ )
{
if ( arr[j] > arr[i] )
{
temp = arr[j] ;
arr[j] = arr[i] ;
for ( k = i ; k > j ; k-- )
arr[k] = arr[k - 1] ;
arr[k + 1] = temp ;
}
}
}
printf ( "\n\nArray after sorting:\n") ;
for ( i = 0 ; i <= 4 ; i++ )
printf ( "%d\t", arr[i] ) ;
getch( ) ;
}

Quick Sort ==> Definition and Example in Java

Example in C :
#include <stdio.h>
#include <conio.h>
int split ( int*, int, int ) ;
void main( )
{
int arr[10] = { 11, 2, 9, 13, 57, 25, 17, 1, 90, 3 } ;
int i ;
void quicksort ( int *, int, int ) ;
clrscr( ) ;
printf ( "Quick sort.\n" ) ;
printf ( "\nArray before sorting:\n") ;
for ( i = 0 ; i <= 9 ; i++ )
printf ( "%d\t", arr[i] ) ;
quicksort ( arr, 0, 9 ) ;
printf ( "\nArray after sorting:\n") ;
for ( i = 0 ; i <= 9 ; i++ )
printf ( "%d\t", arr[i] ) ;
getch( ) ;
}
void quicksort ( int a[ ], int lower, int upper )
{
int i ;
if ( upper > lower )
{
i = split ( a, lower, upper ) ;
quicksort ( a, lower, i - 1 ) ;
quicksort ( a, i + 1, upper ) ;
}
}
int split ( int a[ ], int lower, int upper )
{
int i, p, q, t ;
p = lower + 1 ;
q = upper ;
i = a[lower] ;
while ( q >= p )
{
while ( a[p] < i )
p++ ;
while ( a[q] > i )
q-- ;
if ( q > p )
{
t = a[p] ;
a[p] = a[q] ;
a[q] = t ;
}
}
t = a[lower] ;
a[lower] = a[q] ;
a[q] = t ;
return q ;
}

Merge Sort :

#include <stdio.h>
#include <conio.h>
void main( )
{
int a[5] = { 11, 2, 9, 13, 57 } ;
int b[5] = { 25, 17, 1, 90, 3 } ;
int c[10] ;
int i, j, k, temp ;
clrscr( ) ;
printf ( "Merge sort.\n" ) ;
printf ( "\nFirst array:\n" ) ;
for ( i = 0 ; i <= 4 ; i++ )
printf ( "%d\t", a[i] ) ;
printf ( "\n\nSecond array:\n" ) ;
for ( i = 0 ; i <= 4 ; i++ )
printf ( "%d\t", b[i] ) ;
for ( i = 0 ; i <= 3 ; i++ )
{
for ( j = i + 1 ; j <= 4 ; j++ )
{
if ( a[i] > a[j] )
{
temp = a[i] ;
a[i] = a[j] ;
a[j] = temp ;
}
if ( b[i] > b[j] )
{
temp = b[i] ;
b[i] = b[j] ;
b[j] = temp ;
}
}
}
for ( i = j = k = 0 ; i <= 9 ; )
{
if ( a[j] <= b[k] )
c[i++] = a[j++] ;
else
c[i++] = b[k++] ;
if ( j == 5 || k == 5 )
break ;
}
for ( ; j <= 4 ; )
c[i++] = a[j++] ;
for ( ; k <= 4 ; )
c[i++] = b[k++] ;
printf ( "\n\nArray after sorting:\n") ;
for ( i = 0 ; i <= 9 ; i++ )
printf ( "%d\t", c[i] ) ;
getch( ) ;
}

Heap Sort :

#include <stdio.h>
#include <conio.h>
void makeheap ( int [ ], int ) ;
void heapsort ( int [ ], int ) ;
void main( )
{
int arr[10] = { 11, 2, 9, 13, 57, 25, 17, 1, 90, 3 } ;
int i ;
clrscr( ) ;
printf ( "Heap Sort.\n" ) ;
makeheap ( arr, 10 ) ;
printf ( "\nBefore Sorting:\n" ) ;
for ( i = 0 ; i <= 9 ; i++ )
printf ( "%d\t", arr[i] ) ;
heapsort ( arr, 10 ) ;
printf ( "\nAfter Sorting:\n" ) ;
for ( i = 0 ; i <= 9 ; i++ )
printf ( "%d\t", arr[i] ) ;
getch( );
}
void makeheap ( int x[ ], int n )
{
int i, val, s, f ;
for ( i = 1 ; i < n ; i++ )
{
val = x[i] ;
s = i ;
f = ( s - 1 ) / 2 ;
while ( s > 0 && x[f] < val )
{
x[s] = x[f] ;
s = f ;
f = ( s - 1 ) / 2 ;
}
x[s] = val ;
}
}
void heapsort ( int x[ ], int n )
{
int i, s, f, ivalue ;
for ( i = n - 1 ; i > 0 ; i-- )
{
ivalue = x[i] ;
x[i] = x[0] ;
f = 0 ;
if ( i == 1 )
s = -1 ;
else
s = 1 ;
if ( i > 2 && x[2] > x[1] )
s = 2 ;
while ( s >= 0 && ivalue < x[s] )
{
x[f] = x[s] ;
f = s ;
s = 2 * f + 1 ;
if ( s + 1 <= i - 1 && x[s] < x[s + 1] )
s++ ;
if ( s > i - 1 )
s = -1 ;
}
x[f] = ivalue ;
}
}