Friday, December 18, 2009

How much data/information our brain can store ?

I have been thinking, if the human brain could be theoretically modeled as an artifical neuron network, then how much storage space would it need on a computer.

According to conventional biology, the human brain has an average of 100 billion neurons, and 100 trillion synapse connections.

1,000,000,000,000 (1 trillion) connections:@ 128-bits = 1.28e14 bits
Okay, so lets bring it into the real world

In Terabytes (128-bit): 14901 terabytes
In Pentabytes (128-bit): 14.55 pentabytes

Amount of DVD's it would take to 'make a backup' of someone's brain:
3.2 million DVD's (4.7 gb)
Thats 555 years of DVD quality video :-)
Want to take backup of your brain ?? LOL!!

Friday, December 4, 2009

JIBX - Starting From Code

JIBX Starting from existing Java Code !


  • Download Jibx http://jibx.sourceforge.net/
  • Refer to Sample code which comes with Jibx \jibx_1_2_1\jibx\examples\starter
  • Start with the code and create the bindings and XSDs using BindGen tool
  • java -cp ..\..\lib\jibx-tools.jar;bin org.jibx.binding.generator.BindGen org.jibx.starter.Customer
  • You can also do this using eclipse Run Configurations, Just add all the jars which are shipped with Jibx in classpath.






  • Compile the existing class files with the generated bindings so that it will have JIBX binding attached to the class files. This will increase the size of the existing class files, plus you will see some JIBX related class files like JiBX_bindingCustomer_access.class, JiBX_bindingFactory.class.

  • java -cp .:lib/support.jar:/home/dennis/jibx/lib/jibx-bind.jar org.jibx.binding.Compile binding.xml


  • Now run the Test.java sample program which does the marshaling and un marshaling and you should be good to go.

Thursday, July 9, 2009

ArrayList Vs LinkedList Dilemma

As a java developer we always come across Collections. In interviews we say, I have always used ArrayList in my previous projects. But we may get tense if someone asks, why ?? Why ArrayList why not simple Arrays ?? Why not Linked List. Lets address the second question first.

Basics First:

1) Arraylist -

An arraylist used an array for internal storage. This means it's fast for random access (e.g. get me element #555), because the array index gets you right to that element. But then adding and deleting at the start and middle of the arraylist would be slow, because all the later elements have to copied forward or backward.
ArrayList would also give a performance issue when the internal array fills up. The arrayList has to create a new array and copy all the elements there. Each time the buffer is too small it will create a new one. Hence if we can guess the number of elements that we are going to have, then it makes sense to create a arraylist with that capacity during object creation (using the overloaded constructor or ArrayList)
  • Fast Random Access
You can perform random access without fearing for performance. Calling get(int) will just access the underlying array.
  • Adding values might be slow When you don’t know the amount of values the array will contain when you create it, a lot of shifting is going to be done in the memory space when the ArrayList manipulates its internal array.
  • Slow manipulation When you’ll want to add a value randomly inside the array, between two already existing values, the array will have to start moving all the values one spot to the right in order to let that happen.
2) Linked List -

LinkedList is made up of a chain of nodes. Each node stores an element and the pointer to the next node. A singly linked list only has pointers to next. A doubly linked list has a pointer to the next and the previous element. This makes walking the list backward easier.
Linked lists are slow when it comes to random access.
Getting element #555 means you have to walk either forward from the beginning or backward from the end (depending on whether 555 is less than or greater than half the list size), calling next or previous, until you get to that element.Linked lists are fast for inserts and deletes anywhere in the list, since all you do is update a few next and previous pointers of a node. Each element of a linked list (especially a doubly linked list) uses a bit more memory than its equivalent in array list, due to the need for next and previous pointers.
  • Fast manipulation As you’d expect, adding and removing new data anywhere in the list is instantaneous. Change two links, and you have a new value anywhere you want it.
  • No random access Even though the get(int) is still there, it now just iterates the list until it reaches the index you specified. It has some optimizations in order to do that, but that’s basically it.
3) when to use what ?

If you frequently add elements to the beginning of the List or iterate over the List to delete elements from its interior, you should consider using LinkedList. These operations require constant-time in a LinkedList and linear-time in an ArrayList. But you pay a big price in performance. Positional access requires linear-time in a LinkedList and constant-time in an ArrayList.