Archive for the ‘Uncategorized’ Category.

Print Binary Search Tree Level By Level – Java Source Code

Print all nodes level by level


   public static void printlevelByLevel(Node root)
   {
      Node current = root;
      Queue q = new Queue();
      q.add(root);
      while(!q.isEmpty())
      {
        Node c =(Node) q.remove();
        System.out.print(c.val+",");
        if(c.left!=null)q.add(c.left);
        if(c.right!=null)q.add(c.right);
      }
   }

Print all nodes level by level and priting also when each level finishes


      public static void printlevelByLevel2Queues(Node root)
   {
      Node current = root;
      Queue q[] = new Queue[]{new Queue(),new Queue()};
      int currentQ=0;
      q[currentQ].add(root);
      while(!q[currentQ].isEmpty() || !q[1-currentQ].isEmpty() )
      {
        if(q[currentQ].isEmpty())
        {
          System.out.println("One level Finished... Switching queue...");
          currentQ = 1- currentQ;
        }
        Node c =(Node) q[currentQ].remove();
        System.out.print(c.val+",");
        if(c.left!=null)q[1-currentQ].add(c.left);
        if(c.right!=null)q[1-currentQ].add(c.right);
      }
   }

UML Resources and Tutorials

UML Tutorials

  1. ArgoUML User Manual

facebook like CSS Styling for a facebook application

How to send message from a facebook application

Just make url in the following format. If this is clicked a popup window will be opened  with message title XXXXX and message text XXXXX

http://www.facebook.com/message.php?id=<USER ID>&subject=XXXXX&msg=XXXXX

Tutorials and Resources for Facebook Application Developers

PHP MySQL Tutorials

Basic Tutorials

  1. PHP/MySQL Tutorial

Simple Select Choice and JavaScript Handler

<html>
<body>
 <script type="text/javascript">
    //<![CDATA[
    function selectClicked() {
	  name = document.getElementById('choice1').value;
      alert('Clicked value='+name);
    }

    //]]>
  </script>
<form name=form>

      <select id="choice1" name="choice1" onchange="selectClicked();">
        <option value="val0" selected>slected</option>
        <option value="val1">Land</option>
        <option value="val2">Sea</option>
        <option value="val3">Air</option>
      </select>
    </td><td>

</form>
</body>
<html>

Check whether a linked list is a palindrome

Given a linked list, find out whether it is a palindrome or not

0’s and 1’s Only Matrix Interview Questions

Given an MXN Matrix consisting of only elements 0’s or 1’s.

Find

1. Largest square matrix with 1’s

2. Largest rectagle with 1’s

3. Largest Square with borders made of 1’s

4. Largest Rectangle with borders made of 1’s

Find intersection of 2 arrays

How do you find out intersection between two arrays
Case 1:  One array huge compared to the other array
Case 2: One array sorted
Case 3: Both arrays sorted
Case 4: Unsorted and of equal length