Monthly Archives: September 2014

Binary Search Trees : Insertion and Reversal

Recently I was asked by a fellow colleague if I knew how to reverse a binary search tree in Java. I knew the process and had an idea about binary search trees but I was really unable to write a code for that[it was a time limit question]. So after looking at a few articles and understanding the reversal algorithm, I was able to do it with recursion.

So lets recall once what is it we are talking about:

What is a Binary Search Tree (BST)?

Binary Search Tree (BST) is a binary tree data structure with a special feature where in the value store at each node is greater than or equal to the value stored at its left sub child and lesser than the value stored at its right sub child.

What is the solution ?

So, first of all I create a Node type of class


class Node
{
Node left;
Node right;
int value;
Node(int value)
{
this.value=value;
}
}

Now I create a new class in which I define an insert , print and reversal method as :

 


public void insert(Node node,int value)
{
if (value < node.value) { if (node.left !=null) { insert(node.left,value); } else { System.out.println(" Inserted " + value + " to left of node " + node.value); node.left=new Node(value); } } else if (value > node.value) {
if (node.right!=null) {
insert(node.right,value);
}
else {
System.out.println(" Inserted " + value + "to right of node " + node.value);
node.right=new Node(value);
}
}
}
public void printInOrder(Node node) {
if (node != null) {
printInOrder(node.left);
System.out.println(" Traversed " + node.value);
printInOrder(node.right);
}
}
public void reverse(Node node)
{
Node tmp;
if (node!=null) {
tmp=node.left;
node.left=node.right;
node.right=tmp;
reverse(node.left);
reverse(node.right);

}
}

And finally comes the main method as:


Node rootnode= new Node(25);
System.out.println(rootnode.value);
insert(rootnode, 11);
insert(rootnode, 15);
insert(rootnode, 16);
insert(rootnode, 23);
insert(rootnode, 79);
System.out.println("Traversing tree in order");
printInOrder(rootnode);
System.out.println("Traversing tree in reverse order");
reverse(rootnode);
printInOrder(rootnode);

So, finally I could obtain the reversal of binary tree with the help of our valuable resources available in internet. 🙂

WebSphere Concepts: Cell, Node, Cluster, Server…

Understanding Websphere Basic Terminologies

IT Developer World

Quick post… If you are not familiar with WebSphere at first you might get confused with its concepts: cell, deployment manager, node, node agent, cluster, server, …

First of all, lets start with the concept of a Cell:

A Cell is a virtual unit that is built of a Deployment Manager and one or more nodes. I guess a picture will help making things clearer:

WebSphere Cell

But still there are a few concepts that need to be explained. The next obvious one is the Deployment Manager.

The Deployment Manager is a process (in fact it is an special WebSphere instance) responsible for managing the installation and maintenance of Applications, Connection Pools and other resources related to a J2EE environment. It is also responsible for centralizing user repositories for application and also for WebSphere authentication and authorization.

The Deployment Manager communicates with the Nodes through another special WebSphere process, the Node Agent

View original post 163 more words

Behavioral Biometrics : Is this a solution for the future ?

I remember a time when creating an email-id was a huge task. There weren’t so many security features. We used to have one email-id and one password. Eventually, the internet of things grew so much that we are now in an environment where we have multiple accounts and their respective credentials. Just in office for security sake we might have 3-4 credentials just to login to the appropriate tool to start your work. And that too, we should keep changing it within the time to avoid security breach. Apart from these, you might have 2-3 email accounts, plus 4-5 social accounts, few accounts in the online sites, blah blah. Though some sites might offer logging in through one of the social sites still if we count the no of credentials , there would be many at the end of the day. I wonder if a person keeps a set of different credentials for each, how many passwords he has to remember. And if he keeps the similar passwords in a number of places then there could be a threat of security breach, if any of the accounts is compromised.

Recently, I was thinking over the same problem and did a little bit of R&D on the same. (I have got the habit of stating most of my goggle searches as R&D one among the office terminologies. 😀 )

So , after doing the research a little bit I came across few of the solutions readily available:

  1. Using a password manager. There are many easily available in the internet. Correct, but if we are talking about a problem like password compromising does this stand effective. After all even this has a master password.
  2. One guy wrote of storing all the passwords in a piece of paper so that they can’t be compromised. Good, but what if I have kept this paper in my room and I want to access it when I am out of station. Carrying the paper always with me is definitely not a good solution.
  3. Using biometrics like – fingerprints, retina e.t.c. . This is possible at a very few places as this involves more cost.

Behavioral biometrics – and what is this !!! I heard this term for the very first time.

 

Handwritten signature is the most basic form of behavioral biometric which is prevalent since a long time and till date. Keystrokes dynamics is another form of behavioral biometrics. It depicts the  pattern in which a person is typing and that varies from person to person.

But still the question is : which is the best way to distinguish between the real identity and an imposter.  

Think !!  😉