Posts

Showing posts from 2011

Configuring Apace Server to run PERL scripts

Follow following steps to run PERL script on Apace Server


Step 1:
Open <APACHE_HOME>/conf/httpd.conf file


httpd.conf - is the main configuration file for Apache HTTP Server


Step 2:
Search for "ScriptAlias /cgi-bin/" uncomment i.e. remove '#' if commented. You may need to adjust the path to run your script successfully


ScriptAlias - Provides the location for CGI programs. This should be two parts, separated by whitespace. The first part is the part used in URL that triggers execution of a CGI program; the second part is the path where those CGI programs are stored in the real filesystem


Step 3:
Search for "AddHandler cgi-script" in the document, uncomment it, if committed and append ".pl " after ".cgi"


Step 4:
Modify your PERL Script. If your script is Windows executable it does't means that it will run on Apache Server as well 'coz script relies on PERL interpreter, so we have to modify the hashbang or the shebang or  the first line …

Is Binary search tree - Java Program

/** 
  * Following method can be used to test if a tree meets the conditions to be a binary search tree (BST). 
  */ 
  public boolean isBST(TreeNode root) {
      if (root == null)
          return false;
      return( isBST(root, Integer.MIN_VALUE, Integer.MAX_VALUE) );
  }


/** 
   * Recursive Method - which validates very sub tree of a given binary tree.
   * Works in O(n) time -- visits each node only once. 


   * @param min   For left sub tree it should be Integer.MIN_Value
   *                        For right sub tree it should be node.data + 1
   * @param max For left sub tree it should be node.data
   *                     For right sub tree it should be Integer.MAX_VALUE


   *
   */ 
  private boolean isBST2(TreeNode node, int min, int max) {
    if (node==null) {
      return(true);
    }
    else {

     if (node.getData() < min || node.getData() > max)
return false;
     // left should be in range  min...node.data
      boolean leftOk = isBST(node.getLeft(), min, node.getData());


      // if …