Friday 29 January 2016

Difference between arguments and parameters in Java

Parameter is defined in the method header whereas an argument is the instance passed to the method during run-time.
public class Parameters and Arguments {

    public static int divide(int a, int b) { //a, b are parameters here
         a=5;
         b=5;
        return a%b;

    }

    public static void main(String[] args) {
        int x=divide(a, b); //a, b are arguments here
        System.out.println(x);
    }

}
Here a and b are formal parameters which is declared in the method's header. 
Whereas the a and b becomes arguments in the point of invocation.

Wednesday 27 January 2016

Possible reasons for outOfMemory error and run time and compile time errors in java

outOfJava Heap space : Java is allowed for limited usage memory. Java is divided into two regions namely, Permanent generation and Heap Space. The size for these two regions are set by JVM. OutOfMemory occurs when you add more data to heap space when it is full.
Reasons :
  • Memory leaks: When you don't specify the memory by yourself. The JVM uses the Garbage collection (GC), here the unused items are cleared in memory and again made ready in other words it automatically checks for unused items and removes them.Memory leaks occurs when GC fails to recognize the unused items and fails to remove them.Thus the java heap space increases indefinitely.


Compile time error -Occurs when the code does not follow the Java semantics and syntactic rules
  •  a class tires to extend more than one class 
  • overloading or overriding is not correct
  • referring to a out scope variable
  • inner class has the same name with enclosing class name
  • when class is not abstract but the methods in it are abstract
  • a private member of class A is referenced by  another class B
  • when creating an instance of an abstract class
  • when change the value of the final member
  • when two class or instance have same name
  • missing brackets
  • missing semicolons
  • access to private fields in other classes
  • missing classes on the classpath (at compile time)
Runtime error -
  • using variable that are actually null (may cause NullPointerException)
  • using illegal indexes on arrays
  • accessing ressources that are currently unavailable (missing files, ...)
  • missing classes on the classpath (at runtime)

Thursday 21 January 2016

Hash table in java

Hashtables are efficient implementation of array data structure (an associative array) that stores key/value pairs and searched by the key value.It uses a floating-point value, a string, another array, or a structure as the index. A hashtable has 2 elements, a key set and a value set.And find a way to represent and keys should always map to the appropriate.Next use a hash function that is perfect for you.A hash function depends upon the criteria, could be anything.
C language is not provided with keyed arrays , in order to access an element is by its index number.
Eg:- students[66];
I have provided the hashtable code in java :
public class HashEntry {
      private int key;
      private int value;

      HashEntry(int key, int value) {
            this.key = key;
            this.value = value;
      }     

      public int getKey() {
            return key;
      }

      public int getValue() {
            return value;
      }
}

public class HashMap {
      private final static int TABLE_SIZE = 100;

      HashEntry[] table;

      HashMap() {
            table = new HashEntry[TABLE_SIZE];
            for (int i = 0; i < TABLE_SIZE; i++)
                  table[i] = null;
      }

      public int get(int key) {
            int hash = (key % TABLE_SIZE);
            while (table[hash] != null && table[hash].getKey() != key)
                  hash = (hash + 1) % TABLE_SIZE;
            if (table[hash] == null)
                  return -1;
            else
                  return table[hash].getValue();
      }

      public void put(int key, int value) {
            int hash = (key % TABLE_SIZE);
            while (table[hash] != null && table[hash].getKey() != key)
                  hash = (hash + 1) % TABLE_SIZE;
            table[hash] = new HashEntry(key, value);
      }
}

Wednesday 20 January 2016

Best Java Tools For Every Java Programmers

Java is  an Object-oriented language,robust and mainly employed for creating web applications, server handling, user-end API development. The use-case and importance of Java is huge. In-order to master java practice is vital.There are many tools but I have listed most important tools.

  • Spring Framework:-The Spring Framework provides a comprehensive programming and configuration model for modern Java-based enterprise applications.
  • Hibernate:- Its an object-relation mapping framework.
  • JClarity:-Mainly used for monitoring performance.
  • SparkJava:- Light weight web application framework.
  • Thymleaf:-Java XML/XHTML/HTML5 template engine.
  • JSF and JSP.
  • Grails:-Web application framework.
  • Elastic search:- provides tools to integrate existing applications to power their interactions with incoming data
                                                                                                                               R.Udendran M.tech cse



Tuesday 19 January 2016

Advanced Data structures and Algorithms.

What is the next stage after learning basic data structures and algorithms ?
I have a collection of data structures and algorithms which are regarded as advance data structures and algorithms. I have provided advance data structures and algorithms for parallel computing too.
  • In Balanced binary search trees :AVL trees ,red black trees ,B/B+ trees.
  • In heap:Binomial heaps,Fibonacci heaps and operations,disjoint set representation.
  • In hashing:Double hashing and Universal hashing.
  • In graph algorithms :DFS ,BFS and connected Components
 Kruskal and prim algorithms - shortest path problem - Dijkstra’s and bellman - ford algorithms -Johnson’s algorithm for sparse graphs - flow networks - ford fukerson algorithm - maximum bipartite matching.
  Parallel algorithms :-
  • PRAM models - EREW, ERCW, CREW and CRCW and relation between various models handling read and write conflicts and work efficiency
  • Brent's theorem
  • Parallel merging, sorting, and connected components
  •  list rank
  •  Euler tour technique
  •  Parallel prefix computation
  • Deterministic symmetry breaking 
Pattern matching:- finite automata based methods - Rabin Karp algorithm - Knuth Morris Pratt algorithm - Boyer Moore heuristic - computational geometry - two dimensional problems - line segment intersection convex hull - Graham’s scan - Jarvis’s march technique - closest pair of points in a set

Monday 18 January 2016

Craving the next generation of computer researchers 

Today computer science college students have jobs even before they complete their course things like campus interview where the college invites various IT companies. The best part is that most students get placement but the dark side is that students don’t get to think about next stage in their education, in other words computer science students are not exposed to research areas . The important contribution they can bring to their field. Although computer science research takes time, it has the power to change the world. Since everything runs on computers , bringing out new ideas is vital.
In India , computer science students are more attracted to IT related jobs. The rate of researchers is on the decline.I read an article by Jane Richardson is director of the Oracle Academy in EMEA. The article says,”There is a clear disconnect between the perceptions of IT products and IT skills among young people today. While the likes of Facebook’s Mark Zuckerburg and YouTube’s Steve Chen have invented products in the IT space that no self-respecting teenager would live without, we are not seeing enough youngsters taking up ICT at school”. He highlighted the need and motivation for research.
  



Is this impossible to fix? maybe yes, according to me.The course curriculum  and teachers should consists the power of imparting new ideas instead of focusing only GPA. The need for viable ideas should be encouraged among students and all the benefits of being a computer science researcher.

Tips for being a researcher:
  • Always be curious and question every topic you study in computer science.
  • Choose or identify your favorite problem and work towards solution.
  • Find a mentor
  • Always seek the advice of professors
  • Pick a domain in computer science and read latest research articles
  • The conclusion section in every research papers is very important , it describes the drawbacks in that proposed idea so try to find a way to overcome it.
Author: R.udendran M.tech computer science and engineering and researcher.