It2EDU

Thursday, April 13, 2017


Dear all Gate aspirants in this blog, I shared GATE previous exam papers.



Computer science paper1 download here and answer paper 

Download here



Computer science paper2 Download here and answer paper Download here



Sunday, March 19, 2017









A program is a solution of a specific program which is
unique for similar type problems. So a program is more helpful to find out the
solution of a problem. A program follow some syntax rules based on which
programming language is choose by the programmer.


Before going to solve a problem, a program has Algorithm and
Flow chart.


These two are helpful to find out the flow of program, input
information and approach of problem solving.





Use of a Flowchart:





A flowchart is used geometrical figure which represents the
flow of instructions of a program. We all know a program is set of
instructions.  How the instructions could
solve the problem what the data has to be taken by the user or programmer at
run time of a program. Also it shows how many variables are used to solve the
problem and what the operation is going to perform in the program everything
has presented in a clear way by using geometrical figures.


















The above diagram shows how the program is executed and what
variables are taken as input.


Also we need algorithm for the above program.


An algorithm is used to code the program in any programming
language.




  • Start

  • Accept variable of SUM, x and y.

  • Accept input for X and Y.

  • Perform operation SUM = X+Y

  • Print SUM

  • Stop.






After the algorithm is prepared start writing the code in
any programming language based on programmer interest it may be java, c, c++….
.net,python or any.


Every programming language has its own set of syntax and
rules, based on that rules programmer has to write the code. But here we need
to observe one thing that is irrespective of the programming language first
built the algorithm if the algorithm is good no doubt about you are the good
programmer.





You will find part-1 here.









Saturday, March 11, 2017









A MIME stands for Multipurpose Internet Mail Extension. In
the context of internet or web applications the way of identifying files
according to their nature and format. While developing the web applications
specify content-type in the header part of HTTP – response. 


A MIME type is a
mechanism that can be informed to the client the variety of document
transmitted. Extensions of the files has plays a small role in the web. 





General form of MIME is type/subtype. it is the syntax for mime type





Below are few  MIME
types :


  • Text/html - for Html files

  • multipart/zip - for zip files

  • Application/msword - for word documents

  • image/jpeg - for JPEG image files



RFC defines messages have two parts one is header and a
body. These header and body represents in ASCII text format. The body of the message
is a simple text originally. RFC has decided how to send information in any
format means file or image or video. SO it was introduced MIME for sending
image type data or any other formatted data.


The message header is a series of <CRLF> terminated lines.
CRLF stands for carriage return line feed which are a pair of ASCII control
characters often used straight forward encoding of binary data into ASCII
character set.  This encoding is called
base64. In this approach every three bytes of data into 4 ascii
characters.  This is done by grouping the
binary data into 24-bit units and breaking each such unit into four 6-bits
pieces. Each 6-bit piece maps onto one of 64 valid ASCII characters;


A MIME message that consists of may be a regular text and
can be encoded using 7-bit ASCII.




























































































Sunday, March 5, 2017


Java Strings



Strings are widely used in Java programming. A string is a sequence of characters or simply says a character array. Strings are treated as Objects.
The Java platform provides the String class to create and manipulate strings.




How to create a String:




The most direct way to create a string is to write:

String greeting = "Hello world!";

Whenever it encounters a string literal in your code, the compiler creates a String object with its value in this case,

"Hello world!'.

As with any other object, you can create String objects by using the new keyword and a constructor.

The String class has eleven constructors that allow you to provide the initial value of the string using different sources, such as an array of characters.



public class StringDemo{


public static void main(String args[]){

char[] helloArray = { 'h', 'e', 'l', 'l', 'o', '.'};

String helloString = new String(helloArray);

System.out.println(helloString );

}

}

The above code snippet gives the output hello





“The String class is immutable, so that once it is created a String object cannot be changed. The String class has a number of methods, some of which will be discussed below, that appear to modify strings. Since strings are immutable, what these methods really do is create and return a new string that contains the result of the operation”



Methods used to obtain information about an object are known as accessor methods. One accessor method that you can use with strings is the length() method, which returns the number of characters contained in the string object.


After the following two lines of code have been executed, len equals 17:



String palindrome = "Dot saw I was Tod";

int len = palindrome.length();



String Concatenation



Concatenating means combine two strings one at the end of the other.

In strings concat(String str) is a method used to concatenate the strings.

The String class includes a method for concatenating two strings:


string1.concat(string2);


This returns a new string that is string1 with string2 added to it at the end.


You can also use the concat() method with string literals, as in:


"My name is ".concat("Rumplestiltskin");


Strings are more commonly concatenated with the + operator, as in


"Hello," + " world" + "!"


which results in


"Hello, world!"


The + operator is widely used in print statements. For example:


String string1 = "saw I was ";

System.out.println("Dot " + string1 + "Tod");


which prints


Dot saw I was Tod


Such a concatenation can be a mixture of any objects. For each object that is not a String, its toString() method is called to convert it to a String.





Thursday, February 16, 2017


Java Interview Questions



1. Can we write a java program without main() method?

Ans: Yes we can write java program without main() method.

public class WithoutMain{

static{

System.out.println("without main method ");

System.exit(0);

}

}





2.What is the super class of every java class?


Ans: Object is the super class of every java class.





3.What is the difference between an Interface and an Abstract class?

Ans: An abstract class can have abstract and non-abstract methods but interface can have only abstract methods.

The abstract is the keyword is used to declare abstract class.

The interface is keyword used to declare interface.

Abstract classes does not support multiple inheritance. Interface supports multiple inheritance.

An abstract class can have static methods,constructor and main method. but interface cannot have these.

abstract classes can provide implementation for interfaces but interfaces cannot provide implementation of abstract classes.







Thursday, February 2, 2017











It is like a comparison based sorting, it is the improvement
of selection sort. Heap sort is divide the elements into two regions sorted and
unsorted, and it iteratively shrinks the unsorted region by extracting the
largest elements and moving those into sorted region. 





Heap Sort was invented by J W J Williams in 1964.





Heap : A sorting algorithm that works by first organizing
the data to be sorted into a special type of binary tree called heap.  The heap itself consists of largest element
at the top position of the tree. 













Working of Heap sorting: In the first step receiving an un
sorted list and it create a Heap data structure (Max, Min heap). Once
successfully built the heap, the first element of the heap may be either
largest or smallest it depends on Max or Min heap, so put this heap into an
array. Then we again make heap using the remaining elements, to again pick the
first element of the heap and put it into the array. We keep on doing the same
repeatedly until we have the complete sorted list in our array.





Worst Case Time Complexity : O(n log n)


Best Case Time Complexity : O(n log n)


Average Time Complexity : O(n log n)


Space Complexity : O(1)







Heap sort is widely used sorting, and
it requires a constant space for sorting a list. It is a not stable sort.

















 See the below example program in Java: 





public class HeapSort
{
    private static int[] a;
    private static int n;
    private static int left;
    private static int right;
    private static int largest;

   
    public static void buildheap(int []a){
        n=a.length-1;
        for(int i=n/2;i>=0;i--){
            maxheap(a,i);
        }
    }
   
    public static void maxheap(int[] a, int i){
        left=2*i;
        right=2*i+1;
        if(left <= n && a[left] > a[i]){
            largest=left;
        }
        else{
            largest=i;
        }
       
        if(right <= n && a[right] > a[largest]){
            largest=right;
        }
        if(largest!=i){
            exchange(i,largest);
            maxheap(a, largest);
        }
    }
   
    public static void exchange(int i, int j){
        int t=a[i];
        a[i]=a[j];
        a[j]=t;
        }
   
    public static void sort(int []a0){
        a=a0;
        buildheap(a);
       
        for(int i=n;i>0;i--){
            exchange(0, i);
            n=n-1;
            maxheap(a, 0);
        }
    }
   
    public static void main(String[] args) {
        int []a1={6, 5, 3, 1, 8, 7, 2, 4};
        sort(a1);
        for(int i=0;i<a1.length;i++){
            System.out.print(a1[i] + " ");
        }
    }
}





Output of the above program :



E:\Javaprograms>javac HeapSort.java

E:\Javaprograms>java HeapSort
1 2 3 4 5 6 7 8







 See the graphical representation of Heap sort for the above program: