Btu's Profile User Rating: *****

Reputation: 36 Craftsman
Group:
Active Members
Active Posts:
250 (0.19 per day)
Joined:
16-May 11
Profile Views:
18,377
Last Active:
User is offline Oct 09 2014 08:46 AM
Currently:
Offline

Previous Fields

Country:
CA
OS Preference:
Linux
Favorite Browser:
Mozilla
Favorite Processor:
Who Cares
Favorite Gaming Platform:
Who Cares
Your Car:
Who Cares
Dream Kudos:
0

Latest Visitors

Icon   Btu Ruby is fun

Posts I've Made

  1. In Topic: Bit operations

    Posted 3 Apr 2014

    Thank you sir, this is exactly what I was hoping for..
  2. In Topic: toString() for binary tree

    Posted 29 Nov 2013

    Here is my solution.
    Works good if you use 1-2 digits.

    /**
         * a String representation of a binary tree
         */
        public String toString(){          
        	
        	
            String output = "";  
            int depth = 0;
            int arraySpots = tree.length;
            
            while (arraySpots > 0){
            	arraySpots /= 2;
            	++depth;
            }
            
            int maxWidth = (int) (Math.pow(2, depth));
        	int charWidth = 4*maxWidth;
        	int idx = 0;
        	for (int i = 0; i < depth; ++i) {
        		int level = (int) Math.pow(2, i);
        		for (int j = 0; j < level; ++j) {
        			int preSpace = (int) ((charWidth/(Math.pow(2,(i + 1))) - 1));
        			
        			for (int k = 0; k < preSpace; ++k) {
        				output += " ";
        			}
        			 
        			
        			output +=tree[idx];
        			++idx;
        			if (idx >= size()) {
        				output += "\n";
        				break;
        			}
        			for (int k = 0; k < preSpace; ++k) {
        				output +=" ";
        			}
        		}
        		output += "\n\n";
        	}
        	return output;
        }
    
    


    tester output:

                                   11                               
    
                   12                              53               
    
           20              30              60              77       
    
       50      25      35      40      75      70      83      85
    
    
  3. In Topic: ArrayBinaryTree Structure Constructor

    Posted 7 Nov 2013

    Solution finally found...

    Constructor:
    /**
         * 
         * @param element Root element
         * @param left left subtree
         * @param right right subtree
         */
        public ArrayBinaryTree(T element, ArrayBinaryTree<T> left, ArrayBinaryTree<T> right){
    	
        	this(element);
    	
    	
    		if ((left.size() + right.size() + 1) >= DEFAULT_CAPACITY)
    		expandCapacity();
    		
    		int current = 1; //current free position in parent array
    		int r = 0; //right tree index
    		int l = 0; //left thre index
    		int numberOfElements = 0; //number of elements on that level
    		int height = 0; //sub tree height
    		
    		//get max sub tree height
    		if (left.height() > right.height()){
    			height = left.height();
    		}
    		else{
    			height = right.height();
    		}
    		
    		for(int h = 1; h <= height; h++){
    			numberOfElements = (int)Math.pow(2.0, (double)(h-1));
    		
    			for(int i = 1; i <= numberOfElements; i++){
    				tree[current] = left.tree[l];
    				current++;
    				l++;
    				count++;    
    			}
    			for(int i = 1; i <= numberOfElements; i++){
    				tree[current] = right.tree[r];
    				current++;
    				r++;  
    				count++;
    			}
    		}
    
        }
    
    
  4. In Topic: How to check the actual size in hard disk?

    Posted 17 May 2013

    Check the view: dba_data_files

    select file_name, bytes/1024/1024 "MB" from dba_data_files;
    
    

    This is the size of your DB files.

    Hopefully this helps!
  5. In Topic: where to put concat function in this nest?

    Posted 16 May 2013

    Try this:
    select title, 
           '%' || to_char(retail-cost)*100 "Markup %" 
    from books;
    
    

My Information

Member Title:
D.I.C Regular
Age:
32 years old
Birthday:
April 1, 1982
Gender:
Location:
B.C., Canada
Years Programming:
3
Programming Languages:
learning C++, VB.NET, Java, SQL, PL/SQL

Contact Information

E-mail:
Click here to e-mail me
Website URL:
Website URL  http://www.bill-tucker.com

Comments

Page 1 of 1
  1. Photo

    trevster344 Icon

    21 Jul 2011 - 09:37
    Thanks for the rep buddy, much appreciated.
Page 1 of 1