Posts which you will also like.

Friday, March 30, 2012

Java Tutorial on Circular Doubly Linked List with Generics


Circular Doubly Linked List is very much similar to Doubly Linked List with few differences such as there is no end of the list i.e Head node points to Tail node and Tail node also points to Head node.So if you do not properly check the termination condition then you will probably find yourself in an infinite loop.
Circular Doubly Linked List is advanced version of Circular Linked List.
Circular Doubly Linked List
DLNode class is similar to previous one used Generic Doubly Linked List.
Complete Java code related to Circular Doubly Linked List is listed below.
Pointing upDLNode.java:
package com.techy.rajeev;

public class DLNode<T> {
    private T data;
    private DLNode<T> next;
    private DLNode<T> prev;
    DLNode(){
        next=null;
        prev=null;
        data=null;
    }
    DLNode(T data) {
        this(data, null, null);
    }
    DLNode(T data, DLNode<T> next, DLNode<T> prev) {
        this.data = data;
        this.next = next;
        this.prev = prev;
    }

    T getData() {
        return data;
    }
    public void setNextNode(DLNode<T> next) {
        this.next = next;
    }
    public DLNode<T> getPrevNode() {
        return prev;
    }
    public void setPrevNode(DLNode<T> prev) {
        this.prev = prev;
    }
    public void setData(T data) {
        this.data = data;
    }
    public DLNode<T> getNextNode() {
        return next;
    }
}



Pointing upCircularDoublyLinkedList.java:





package com.techy.rajeev;

public class CircularDoublyLinkedList<T> {
    private DLNode<T> head;

    // Returns the no. of nodes in circular Doubly linked list
    public int getSize() {
        int count = 0;
        if (head == null)
            return count;
        else {
            DLNode<T> temp = head;
            do {
                temp = temp.getNextNode();
                count++;
            } while (temp != head);
        }
        return count;
    }

    // Traversal of circular doubly linked list
    public void traverse() {
        if (head == null) {
            System.out.println("List is empty!");
        } else {
            DLNode<T> temp = head;
            do {
                System.out.print(temp.getData() + " ");
                temp = temp.getNextNode();
            } while (temp != head);
        }

    }

    /* methods related to insertion in circular doubly linked list starts. */
    public void insertAtBeg(T data) {
        DLNode<T> newnode = new DLNode<T>(data);
        if (head == null) {
            newnode.setNextNode(newnode);
            newnode.setPrevNode(newnode);
            head = newnode;
        } else {
            DLNode<T> temp = head.getPrevNode();
            temp.setNextNode(newnode);
            newnode.setPrevNode(temp);
            newnode.setNextNode(head);
            head.setPrevNode(newnode);
            head = newnode;
        }

    }

    public void insertAtEnd(T data) {
        DLNode<T> newnode = new DLNode<T>(data);
        if (head == null) {
            newnode.setNextNode(newnode);
            newnode.setPrevNode(newnode);
            head = newnode;
        } else {
            DLNode<T> temp = head.getPrevNode();
            temp.setNextNode(newnode);
            newnode.setNextNode(head);
            head.setPrevNode(newnode);
            newnode.setPrevNode(temp);
        }

    }

    public void insertAtPosition(T data, int position) {
        if(position<0||position==0){
            insertAtBeg(data);
        }    
    else if(position>getSize()||position==getSize()){
            insertAtEnd(data);
        }else{
            
            DLNode<T>temp=head;
            DLNode<T> newnode=new DLNode<T>(data);
            for(int i=0;i<position;i++){
                temp=temp.getNextNode();
            }
            
            newnode.setNextNode(temp.getNextNode());
            temp.getNextNode().setPrevNode(newnode);
            temp.setNextNode(newnode);
            newnode.setPrevNode(temp);
        }
    }

    /* methods related to insertion in circular doubly linked list ends. */

    /* methods related to deletion in circular doubly linked list starts. */
    // Removal based on a given node for internal use only
    @SuppressWarnings("unused")
    private void remove(DLNode<T> node) {
        if(node.getPrevNode()==node||node.getNextNode()==node)
            head=null;
        else{
            DLNode<T> temp=node.getPrevNode();
            temp.setNextNode(node.getNextNode());
            node.getNextNode().setPrevNode(temp);
            }
        node=null;
    }
    public void removeAtBeg(){
        if(head==null)
            System.out.println("List is already empty!");
        else{
            DLNode<T> temp=head.getNextNode();
            head.getPrevNode().setNextNode(temp);
            temp.setPrevNode(head.getPrevNode());
            head=temp;
        }
    }
    public void removeAtEnd(){
        if(head==null)
            System.out.println("List is already empty!");
        else{
            DLNode<T> temp=head.getPrevNode();
            temp.getPrevNode().setNextNode(head);
            head.setPrevNode(temp.getPrevNode());
            temp=null;
        }
    }
    // Removal based on a given position
    public T remove(int position) {
        T data = null;
        if (position == 0) {
            data = head.getData();
            removeAtBeg();
        } else if (position == getSize()-1) {
            data=head.getPrevNode().getData();
            removeAtEnd();
        } else {
            DLNode<T> temp = head;
            for (int i = 0; i < position; i++) {
                temp = temp.getNextNode();
            }
            data=temp.getData();
            DLNode<T> node = temp.getNextNode();
            node.setPrevNode(temp.getPrevNode());
            temp.getPrevNode().setNextNode(node);
            temp = null;
        }
        return data;// Deleted node's data
    }
    /* methods related to deletion in circular doubly linked list ends. */

}


Pointing upMainClass.java




package com.techy.rajeev;
//Circular Doubly Linked list is used here.
public class MainClass {
    public static void main(String args[]){
        CircularDoublyLinkedList< Integer> cdll=new CircularDoublyLinkedList<Integer>();
        cdll.insertAtBeg(32);
        cdll.insertAtBeg(35);
        cdll.insertAtBeg(45);
        cdll.insertAtEnd(12);
        cdll.insertAtEnd(10);
        cdll.insertAtEnd(9);
        cdll.traverse();
        System.out.println();
        System.out.println("Size is:"+cdll.getSize());
        cdll.insertAtPosition(11,5);//Index starts from zero.
        System.out.println();
        cdll.traverse();
        System.out.println("\nSize is:"+cdll.getSize());
        System.out.println();
        System.out.println("Deleted:"+cdll.remove(5));
        //Index for deletion also starts from zero
        cdll.removeAtBeg();
        cdll.traverse();
        cdll.removeAtEnd();
        System.out.println();
        cdll.traverse();
        System.out.println("Size is:"+cdll.getSize());
    }
}


Pointing upOUTPUT:


45 35 32 12 10 9 11

Size is:7


Deleted:9

35 32 12 10 11


35 32 12 10 Size is:4

More on this at techcresendo.com
Read More ->>

Wednesday, March 28, 2012

How to know IPAddress,Owner,DNS,Whois,Web Host of a Website?



Have you ever wondered where Facebook ,Google,Yahoo,Twitter hosted their website?What is their IP address?Domain name server?
Who is the owner? etc.etc….
This post will let know how to find the hosting information and other related stuff for a website.
There are lots of commands available with Windows and Linux platform to get all these information but here we will get the insight of some web tools for the same.

Whoishostingthis.com:
This is an excellent website which can tell you
  1. 1.Web Host of a website
  2. 2.IP Address
  3. 3.Name Server
Using this website you can also perform Whois query.This image shows the result of google.
whoishostingthis

dnstools.com:
This website provides following query parameters for a website which you can fire to get the information about that website:

1.Resolve/Resolve Lookup
2.Whois(Domain Name)
3.Whois(IP Owner)
4.Check port
5.Ping
dnstools
Netcraft Web Server Query
network
This website provides OS, Web Server and Hosting History for any web site.Type a URL and Netcraft will tell you the site's OS, web server, and a graphical view of the time since last reboot for each of the computers serving the site.

whois
This website provides whois lookup for any website.It also shows the information whether entered website is available or not means registered to any one or not(Domain name availability). Domain and Seo tools are also provided by WHOis.net.
DomJax- doomjax
Checks domain name availability and also runs an automatic whois report for any domain that's taken - hover the mouse over the domain name and DomJax pops up a neat "thought bubble" which has all the information about that domain like who owns it, when it will expire and how to contact the owner.

DNSstuff:dnsstuff
This excellent website provides

  • Whois lookup
  • Traceroute
  • IP information
It also provides some lookup tools for forensic analysis of name and email servers,Tracking and Authentication,Monitoring and alerts services of DNS and email.
AJAX DNS - An excellent set of common DNS commands and tools packed in a non-geeky interface. See all DNS records,Whois information and Reverse DNS records for a domain,DNS Traversal, HTTP headers, ping a domain or view the whois details for a domain.

More on this at techcresendo.com
Read More ->>

Sunday, March 25, 2012

Java Tutorial on Generic Doubly Linked List


In this Java tutorial We discuss Doubly Linked List.Doubly linked list is a two way linked list where each node in the list has two links.
doublylinkedlist_03
With the help of double links we can traverse the list in both forward and backward direction in O(n) time.
If We maintain two pointers for head and tail then insertion and deletion at beginning and end can be done in O(1) time.

Sad smileBut doubly linked list has some disadvantage also e.g.
1.It requires much memory since we have to maintain two reference for each node: one for forward node and one for backward node.
2.Insertion and deletion requires much more effort since we have to change four reference for each insertion and deletion except at beginning and at end.
doublylinkedlist from techyrajeev
techyrajeev doublylinkedlist image
We can implement the Generic Doubly Linked list using java.Complete java code listing is given below.


Pointing upDLNode.java: This java file represents the node which has double links next and prev.



package com.techy.rajeev;

public class DLNode<T> {
    private T data;
    private DLNode<T> next;
    private DLNode<T> prev;
    DLNode(){
        next=null;
        prev=null;
        data=null;
    }
    DLNode(T data) {
        this(data, null, null);
    }
    DLNode(T data, DLNode<T> next, DLNode<T> prev) {
        this.data = data;
        this.next = next;
        this.prev = prev;
    }

    T getData() {
        return data;
    }
    public void setNextNode(DLNode<T> next) {
        this.next = next;
    }
    public DLNode<T> getPrevNode() {
        return prev;
    }
    public void setPrevNode(DLNode<T> prev) {
        this.prev = prev;
    }
    public void setData(T data) {
        this.data = data;
    }
    public DLNode<T> getNextNode() {
        return next;
    }
}



Pointing upDoublyLinkedList.java:




package com.techy.rajeev;

public class DoublyLinkedList<T> {
    private DLNode<T> head;
    private DLNode<T> tail;
    //Returns the no. of nodes in Doubly linked list
    public int getSize(){
        int count = 0;
        if(head==null)
            return count;
        else{
            DLNode<T> temp=head;
            do{
                temp=temp.getNextNode();
                count++;
            }while(temp!=tail);
        }
        return count;
    }
    //Traverse from head
    public void traverseF(){
        DLNode<T> temp=head;
        while(temp!=null){
            System.out.print(temp.getData()+" ");
            temp=temp.getNextNode();
        }
    }
    //Traverse from tail
    public void traverseB(){
        DLNode<T> temp=tail;
        while(temp!=null){
            System.out.print(temp.getData()+" ");
            temp=temp.getPrevNode();
        }
    }
    /* methods related to insertion in doubly linked list starts.*/
    public void insertAtBeg(T data){
        DLNode<T> newnode=new DLNode<T>(data);
        if(head==null){
            head=newnode;
            tail=newnode;
            newnode.setNextNode(null);
            newnode.setPrevNode(null);
        }else{
             newnode.setNextNode(head);
             head.setPrevNode(newnode);
             head=newnode;
        }
            
    }
    public void insertAtEnd(T data){
        DLNode<T> newnode=new DLNode<T>(data);
        if(tail==null){
            head=newnode;
            tail=newnode;
            newnode.setNextNode(null);
            newnode.setPrevNode(null);
        }else{
            newnode.setPrevNode(tail);
            tail.setNextNode(newnode);
            tail=newnode;
        }
    }
    public void insertAtPosition(T data,int position){
        if(position<0||position==0){
            insertAtBeg(data);
        }    
    else if(position>getSize()||position==getSize()){
            insertAtEnd(data);
        }else{
            
            DLNode<T>temp=head;
            DLNode<T> newnode=new DLNode<T>(data);
            for(int i=0;i<position-1;i++){
                temp=temp.getNextNode();
            }
            
            newnode.setNextNode(temp.getNextNode());
            temp.getNextNode().setPrevNode(newnode);
            temp.setNextNode(newnode);
            newnode.setPrevNode(temp);
        }
    }
    /* methods related to insertion in doubly linked list ends.*/
    
    /* methods related to deletion in doubly linked list starts.*/
    //Removal based on a given node for internal use only
    @SuppressWarnings("unused")
    private void remove(DLNode<T> node){
        if(node.getPrevNode()==null)
            head=node.getNextNode();
        else if(node.getNextNode()==null)
            tail=node.getPrevNode();
        else{
            DLNode<T> temp=node.getPrevNode();
            temp.setNextNode(node.getNextNode());

          node.getNextNode().setPrevNode(temp);

           }
        node=null
    }
    //Removal based on a given position
    public T remove(int position){
        T data=null;
        if(position==1){
            data=head.getData();
            head=head.getNextNode();
        }else if(position==getSize()){
            data=tail.getData();
            tail=tail.getPrevNode();
            tail.setNextNode(null);
        }else{
            DLNode<T> temp=head;
            for(int i=0;i<position;i++){
                temp=temp.getNextNode();
            }
            DLNode<T> node=temp.getNextNode();
            node.setPrevNode(temp.getPrevNode());
            temp.getPrevNode().setNextNode(node);
            temp=null;
        }
        return data;//Deleted node's data
    }
    /* methods related to deletion in doubly linked list ends.*/
    
}

High fiveMainClass.java:

This is the class in which you can see the actual working of DoublyLinked List.



package com.techy.rajeev;

public class MainClass {
    public static void main(String args[]){
        DoublyLinkedList< Integer> dll=new DoublyLinkedList<Integer>();
        dll.insertAtBeg(32);
        dll.insertAtBeg(35);
        dll.insertAtBeg(45);
        dll.insertAtEnd(12);
        dll.traverseF();
        System.out.println();
        dll.traverseB();
        System.out.println("Size is:"+dll.getSize());
        dll.insertAtPosition(46,0);
        System.out.println();
        dll.traverseF();
        System.out.println("Removed at pos 5:"+dll.remove(5));
        System.out.println("Size is:"+dll.getSize());
        dll.traverseF();
        dll.remove(1);
        System.out.println();
        dll.traverseF();
        
    }
}

Clockoutput:

45 35 32 12
12 32 35 45 Size is:4

46 45 35 32 12 Removed at pos 5:12
Size is:4
46 45 35 32
45 35 32
Read More ->>

Friday, March 23, 2012

Binary Search Technique with Algorithmic Analysis


Binary searching is a searching method which is based on divide and conquer approach and It is most suitable when items are stored in sorted order i.e either increasing or decreasing manner.
Binary search technique has time complexity of O(logn) (on base 2) which if much better than other searching techniques.
Binary search can be implemented in two ways : in recursive way or in iterative way.
Complete Source code for Binary Search  is listed here.

Pointing upBinary Search Recursive: 

int Bsearchrec(int arr[],int low,int high,int item){ int mid=low+(high-low)/2;
if(arr[mid]==item)
        return mid;
else if(arr[mid]<item)
        return Bsearchrec(arr,mid+1,high,item)
else
        return Bsearchrec(arr,low,mid-1,item)
return -1; // control will reach here only if item not found
}
Pointing upBinary Search Iterative: 



 int Bsearchiter(int arr[],int size,int item){
 int low=0;int high=size-1;
 while(low<=high){                 
                         mid=low+(high-low)/2;                 
                         if(arr[mid]==item)                        
                             return mid;                 
                         else if(arr[mid]<item)                         
                             low=mid+1;                
                         else  high=mid-1;      
                         }  
        return –1;// Unsuccessful result
}


SunAlgorithmic analysis of Binary Search:


If we analyse the Binary Search carefully we would find that each time size of array to search is decreased by half.After ith opertaion we have problem of size 1 i.e reached the goal state.

Initially we have

           1opertaion: Problem of size=n/2(size of array)
           2opertation: Problem of size=n/4
           3opertation: Problem of size=n/8
            ……………………………………
           ……………………………………

           ith operation: Problem of size=n/2^i

ith stage is the stage when we have problem of size=1

=> n/2^i=1

=>n=2^i

=>Taking logarithms on both side

=>logn=log(2^i)

=>ilog2=logn

=>i=logn/log2

=>i=logn(on base 2)

It means total running time is O(logn) (on base 2).

If we go by recurrence relation them we find following recurrence relation:

T(n) =T(n/2)+ ?(1)

Solution of this recurrence is also T(n) = O(logn).
Read More ->>

Tuesday, March 20, 2012

10 Most widely used open source software for an start up company


Small and Medium enterprise which do not want to spent too much on buy costly software go for the open source tools.In this post I have provided a list of most widely used open source tools which could be very beneficial for an individual entrepreneur or an start-up organization.
UBUNTU:  ubuntu
It is most widely used open source operating system and provides community and professional support. It is available for mobile platform as well as for desktops. Its new version available at the end of each six month.Ubuntu is very easy to integrate, and provides you tools to create documents, spread sheets and presentations and share them with Windows users stress-free.

Meaning of Ubuntu:Ubuntu is derived from an ancient African word meaning 'humanity to others'. It also means 'I am what I am because of who we all are'.

Blender:
blender
Blender is an open source cross platform tool for 3D designing. It is available for all widely used Operating Systems under GNU General Public License. Blender is an integrated application that enables the creation of a broad range of 2D and 3D content. Blender provides a broad spectrum of modeling, texturing, lighting, animation and video post-processing functionality in one package.Through it's open architecture, Blender provides cross-platform interoperability, extensibility, an incredibly small footprint, and a tightly integrated workflow. Blender is one of the most popular Open Source 3D graphics application in the world.Blender is also fully integrated creation suite, offering a broad range of essential tools for the creation of 3D content, including modeling, uv-mapping, texturing, rigging, skinning, animation, particle and other simulation, scripting, rendering, compositing, post-production, and game creation.
GIMP:
  gimp                                                          GIMP is acronym for GNU image manipulation program.It has capability of photo retouching, image composition and image authoring much like AdobePhotoshop and available for multiple platforms.We can use it  as a simple paint program, an expert quality photo retouching program, an online batch processing system, a mass production image renderer, an image format converter, etc. Gimp is developed on UNIX platform but since it is of cross platform nature it can also run on Windows and Mac OS.File formats supported in GIMP include bmp, gif, jpeg, mng, pcx, pdf, png, ps, psd, svg, tiff, tga, xpm, and many others.It has also in built scripting capability based on Perl,Python and Scheme.


OPENOFFICE.org:
openofficeIt is used for word processing, spreadsheets, presentations, graphics, databases and more.It is cross platform software and available in many languages. It stores all your data in an international open standard format and can also read and write files from other common office software packages such as Microsoft™ Office suite. It can be downloaded and used completely free of charge for any purpose. Currently availabe OpenOffice.org 3 is released under the LGPL licence.

Zimbra:
zimbraZimbra is a next-generation collaboration server that provides organizations greater overall flexibility and simplicity with integrated email, contacts, calendaring, sharing and document management plus mobility and desktop synchronization to users on any computer.We can very easily set up our Yahoo Mail ,GMail and other accounts with Zimbra.

GNUCash:
gnucashIt is small-business financial-accounting software.It is licensed under GNU GPL and provides cross platform support.With GNUCash we can track bank accounts, stocks, income and expenses. As quick and intuitive to use as a checkbook register, it is based on professional accounting principles to ensure balanced books and accurate reports.

GNUCash provides following functionality :


  • Double-Entry Accounting
  • Stock/Bond/Mutual Fund Accounts
  • Small-Business Accounting
  • Reports, Graphs
  • QIF/OFX/HBCI Import, Transaction Matching
  • Scheduled Transactions
  • Financial Calculations   
 WordPress: 

wordpress
 Word is open source web tool which can be used to create professional blogs and also as CMS. It has thousands of plugins and themes,widgets available which can be used for professional quality blogs.It is based on the php and Mysql. WordPress was started in 2003 with very few users but now it has much more users than google’s Blogger.



 Drupal:

drupa
 Drupal is also open source software licenced under GNU GPL developed by a community of 630,000+ users and developers. Drupal is used by various organizations such as MTV,Harvard,MIT,San Jose State University, Sony Music,Warner Brothers,Ubuntu,Brainstorm etc.

Currently released version is Drupal can run on Apache or Microsoft IIS.Drupal provides drag and drop interface for the frequently used administrative tasks and It also has the support for the integration of WYSIWYG editors which makes the life of novice user much more easier.





OrangeHRM:

orange hrm
OrangeHRM is a Human Resource Management Information System that provides a vast range of feature to manage the crucial organization asset i.e Employees.Its developers claim that it has 1,000,000 users globally and OrangeHRM is the world’s most popular Open Source Human Resource Management Software (HRMS). OrangeHRM offers features such as Personal Information Management,Employee self service,Leave Management, Time and attendance tracking,Health,Saving plans and recruitment for new employees.

SugarCRM:
Sugar is an affordable and easy to use customer relationship management (CRM) platform, designed to help your business communicate with prospects, share sales information, close deals and keep customers happy. Thousands of successful companies use Sugar everyday to manage sales, marketing and support.
Capture8As an open-source, web-based CRM solution, Sugar is easy to customize and adapt to your changing needs. Ideal for small and medium-sized companies, large enterprises and government organizations, Sugar can run in the cloud or on-site.


More on this at techcresendo.com
Read More ->>

Monday, March 5, 2012

Get Satanic version of Ubuntu: Linux for Beasts



Ubuntu Satanic Edition is an Ubuntu based operating system with very dark bloody themes.It has also heavy music albums  from Indian band Theorized, T.A.N.K from Germany, Lost World Order from France and New York thrashers Deathalizer.


It is Gnome 2 based Ubuntu operating system and comes as live CD and DVD .
Satanic Edition has many applications are included, plus thousands more available to download and install at the click of a button.All of them are open source and free.
Installation of Satanic Ubuntu can be done in same way as Ubuntu e.g. boot directly from CD/DVD or install from CD/DVD or installed inside Windows.
If you already have Ubuntu installed, you can simply add the packages related to Satanic Ubuntu by following these instructions.
You can download the Satanic Ubuntu Cd and Dvd from the following link:

                                                              Download Undead CD

                                                              Download Undead DVD

Get a look of this OS for beasts:



Read More ->>

Get Open source version of Microsoft Windows :ReactOs


ReactOS is an open source operating system developed by ReactOS Foundation based on the design of Windows® XP/2003. It is not based on linux kernel rather it follows Windows-NT® architecture designed by Microsoft.
It provides similar user interface and look and feel as Windows® XP/2003 and is binary compatible with Windows®.


This means ReactOS will allow your Windows® applications and drivers to run as they would on your Windows system.
ReactOS is licensed under GNU GPL(General Public License).
ReactOS currently only supports the x86 processor architecture and some other architectures support are under development.



Developers of ReactOS claim that they  have not looked at Windows® source code. They have used the public documentation of Windows® OSes to understand the Windows® architecture.
It is currently in alpha stage of development and not recommended for daily use since some functionality are still to be implemented. 
Still you can give it a try and test it for fun:
You can download it from here:

                                                              Download ReactOS

Read More ->>
DMCA.com Protected by Copyscape Online Plagiarism Tool