Monday, May 19, 2014

How to create a Singly Linked List in Java

I have started revisiting Java Basics during my summer break and currently trying to figure out the famous "Linked List".In this post we will learn about various types of linked list by using code and figures because having a visual always helps in understanding a concept.
Singly Linked List 
The node in a singly linked list comprises of  :-
- info  that stores the text or information about the node
pointer  that stores the reference to the next node.
Each linked list has a head which is usually the first element in the list and a tail which is usually null in case of singly linked list.

Singly Linked  List
The above weird looking figure is the in memory representation of a linked list,where the top part stores the info and the bottom part stores the reference to the next node it points to.Head is the first element in list and tail is usually null.The problem with singly linked list is that it can only be traversed in forward direction so you need to store the reference to its first element in a separate data structure and then traverse it node by node in forward direction by using that data structure.
JAVA CODE FOR CREATING,PRINTING SINGLY LINKED LIST

public class createLinkedList<T>{
/* Node Definition
* data stores the information about the node
* next stores the node to which current node points to
*/
private T data;
private createLinkedList<T> next;

public createLinkedList(T value){
data=value;
}
public createLinkedList<T> next(){
return next;
}
public T getValue() {
return data;
}
/*
* Setter methods for data and next
*/
public void setValue(T data){
this.data=data;
}
public void setNext(createLinkedList<T> next){
this.next=next;
}

public static void main(String[] args) {
createLinkedList<Integer> node1=new createLinkedList<Integer>(12);
createLinkedList<Integer> node2=new createLinkedList<Integer>(3);
createLinkedList<Integer> node3=new createLinkedList<Integer>(-8);
createLinkedList<Integer> node4=new createLinkedList<Integer>(6);
node1.setValue(node1.getValue());
node1.setNext(node2);
node2.setValue(node2.getValue());
node2.setNext(node3);
node3.setValue(node3.getValue());
node3.setNext(node4);
node4.setValue(node4.getValue());
node4.setNext(null);

/*
*Printing linked list
*/
createLinkedList<Integer> referenceToList=node1;
while(referenceToList!=null ){
System.out.println(referenceToList.getValue());
referenceToList=referenceToList.next();

}


}
}

Friday, May 9, 2014

Tools


While writing a computer program a programmer often has to repeat same lines of code again and again,almost always forgets closing a bracket or putting a colon at the end,just little things that always cause a big compilation error.

To help them in avoiding such little errors, computer scientists came up with automated tools which made life a lot easier.Imagine life without Eclipse,Visual Studio,Adobe's various products,Microsoft word,notepad.There are so many tools available nowadays.
For a recent project I came across some new tools that really helped me during the project phases .Some of them were


  • ouCampus for Content Management - This tool helped me a lot in creating web pages for my school project.It made adding text and multimedia very easy.This tool has been awarded (by OmniUpdate's content management)because of its functionality and is incorporated in creation of many universities websites.
  • Prezi for Presentation-I absolutely love this tool,whatever crazy idea you can come up with for the presentation,you can do it using this tool.
  • Google Analytics -Google Analytics can come real handy if you want to know from where the traffic is coming to your website.It gives all the information about page rank,demographics that can help you a lot in monitoring the website and also increasing its page view by tweaking it.
  • Adobe Photoshop for poster creation-Who does not know about the magic Adobe's Photoshop can do to images,text or should i say almost everything.We see it every day in those magazines where not so perfect people are represented as epitome of perfection by the help of Photoshop.We also used photoshop for creation of poster for our project



Some of my favorite tools are:-
  • Microsoft Office - Life would be horrible without Microsoft Office.This product is as important as food for computer savy people like me.
  • Google Apps - Google Apps is a good alternative of Microsoft Office specially for people who can't afford office.Best part of Google Apps is that all the documents are stored in the cloud.So there is less danger of loosing your hard-work in case the system crashes.Recently my friend's laptop got stolen and it had all the data in it(just before the finals),imagine his condition,he would be creating and storing everything on cloud using Google Apps from now on that's for sure.
  • Eclipse Kepler - What to say about eclipse Kepler except Intellisense,no more writing tedious lines of code again and again,no more searching for the corresponding package of the data structure or class you are using,eclipse kindly tells you what package is necessary for the code you are using,just double click on the intellisense and its included in your code(a boon,I would say).
  • Infomatica - Imagine your boss comes up to you and say,"Can you please change the primary key of table Employees?Thanks" which basically means ,"I want this done now".In a situation like this what if, you have no idea what table he is talking about,you just joined the team yesterday(No you can not go up to him and say I don't know how to do it).In this case Informatica comes in handy,it stores the whole work flow of a project,all the tables,primary key,foreign keys and that too with a human understandable visual.Just search your project workflow in meta search and you can easily find the "Employees" table and its keys(Yay...You are safe).By the way the example I gave you is based on my true life.

Usually I don't like tools that are too complicated because instead of trying to figure out how the tool works,I prefer working,so any tool that is self explanatory or has help forum is perfect.
With the advancement of technology tools are becoming better day by day,automation has reached  a new level which is great for people like me that can not memorize everything.

References
http://fc07.deviantart.net/fs71/f/2011/255/3/9/eclipse_a2_by_dj_fahr-d49mizm.png
http://www.itworld.com/sites/default/files/frustration-600x450_0.jpg
Images-
ww.zazzle.com


  

Monday, May 5, 2014

PERL


 PERL(Practical Extraction and Reporting Language)

Perl is a programming language that was created by Larry Wall in 1987 for processing text and generating reports while he was working in Unysis.Slogan of Perl is "There are more than one way to do things"; seems like that is what Lary Wall was thinking while creating Perl because Perl loans it's features from UNIX shell, awk ,sed, C++, Pascal,Lisp and SmallTalk 80(that's a lot of languages) The reason I love Perl is because of its flexibility.For example - As a coder ,it is very frustrating when you get a compilation error because you forgot to parse Integer to float(happens so many times),or when you have to think about whether I should use Integer or short or long to improve the efficiency of my program .. . well ...good news..Perl solves it all.
Just declare a variable like $var=undef;
and forget about its datatype or parsing while assignment operations because Perl does it all for you.
It automatically parses your variable name to the datatype by looking at the value that has been assigned to it and also handles the conversions on its own(Pretty amazing ..Right!!).Some people call Perl as a dirty language because of things like this ,I call it Smart and flexible.
Another feature of Perl that is a boon is CPAN(Comprehensive Perl Archive Network) which is an archive that started in October 1995,where authors like me(fledglings...as of now) and more experienced authors write modules and upload it on CPAN for public use. Example
File Handle Input/Output
Networking Devices
Documentation
Server Damon Utilities
World Wide Web etc
Just download it and use it as your own without fear of copy right issues or anything else.For example Perl "sort" operation implements the  MergeSort module by default hence giving time Complexity O(nlogn) which is as good as it gets without worrying about running complexity for sorting.Even while reading files you don't have to worry about whether it supports UTF-8 ,binary,html,xml encoding; just open a filehandler and read it unlike Scanner class in Java which can be sometimes troublesome with the encoding.
Code for reading a file in perl
open(filehandler,"<Filename");
while($line=<filehandler>){
print $line;
}
Just try this amazing language out,I know you will fall in love with it too.






References-
http://www.perl.org/
http://en.wikipedia.org/wiki/Perl

Beta Testing



Software Development Life Cycle can be divided into various phases - requirement, design, development, testing and implementation.Since Testing is a very important aspect of SDLC,various techniques have been developed over a period of time,for example ,unit testing,black box testing,white box testing,alpha testing,beta testing etc.

Beta Testing can be defined as a test for a computer product prior to commercial release.Beta testing is the last stage of testing,and normally can involve sending the product to test sites outside companies for real world exposure or offering the product for a free trial download over the Internet.

Recently Apple distributed the next update to the company's MAC operating system OS X 10.9.3 for beta testing to users that possessed an Apple ID ,signed up to participate and adhere to a confidentiality agreement associated with Beta testing process.
Similarly there are a lot of companies that give people the opportunity to participate in Beta testing their software like Facebook,Kaspersky,free dictionary even gaming products like XBox.You can go to the company's websites and see if there are any open opportunities for Beta testing,for example,right now Kaspersky needs Beta testers for their product (http://www.kaspersky.com/downloads/beta_testing)
When taking part in the beta testing it is necessary to:a)download and install the product you are interested in testing;b)spend a certain amount of time on familiarizing yourself with the product and testing it;c)prepare and send out bug reports on any errors found;d)provide suggestions on ways to improve the product being tested; and,e)report on compatibility issues (specifically related to your configuration).

References
https://cio.gov/software-development-life-cycle/http://www.pcmag.com/article2/0,2817,2456951,00.asphttp://www.kaspersky.com/downloads/beta_testing