高手指点二元高度(binary height)

大家好:
我在看<<oracle database 10g performance tuning tips & techniques>>时,看到索引那一章时,关于索引的二度高度,讲的不够细致,请高手指点一下,为什么删除了表中的20%-25%的数据后会增加二度高度的值?
还有直方图的那一节也讲的不够详细,谁能详细的给讲一下直方图创建后是如何提高的性能,如果能细致的讲一下,更是感激不尽.
谢谢各位大侠了!

为什么没有回答呢?是不是我问的不够详细,大家没有看懂呀?

Similar Messages

  • Having trouble finding the height of a Binary Tree

    Hi, I have an ADT class called DigitalTree that uses Nodes to form a binary tree; each subtree only has two children at most. Each node has a "key" that is just a long value and is placed in the correct position on the tree determined by its binary values. For the height, I'm having trouble getting an accurate height. With the data I'm using, I should get a height of 5 (I use an array of 9 values/nodes, in a form that creates a longest path of 5. The data I use is int[] ar = {75, 37, 13, 70, 75, 90, 15, 13, 2, 58, 24} ). Here is my code for the whole tree. If someone could provide some tips or clues to help me obtain the right height value, or if you see anything wrong with my code, it would be greatly aprpeciated. Thanks!
    public class DigitalTree<E> implements Copyable
       private Node root;
       private int size;
       public DigitalTree()
           root = null;
           size = 0;
       public boolean add(long k)
           if(!contains(k))
                if(this.size == 0)
                    root = new Node(k);
                    size++;
                    System.out.println(size + " " + k);
                else
                    String bits = Long.toBinaryString(k);
                    //System.out.println(bits);
                    return add(k, bits, bits.length(), root);
                return true;
           else
               return false;
       private boolean add(long k, String bits, int index, Node parent)
           int lsb;
           try
               lsb = Integer.parseInt(bits.substring(index, index - 1));
           catch(StringIndexOutOfBoundsException e)
               lsb = 0;
           if(lsb == 0)
               if(parent.left == null)
                   parent.left = new Node(k);
                   size++;
                   //System.out.println(size + " " + k);
                   return true;
               else
                   return add(k, bits, index-1, parent.left);
           else
               if(parent.right == null)
                   parent.right = new Node(k);
                   size++;
                   //System.out.println(size + " " + k);
                   return true;
               else
                   return add(k, bits, index-1,  parent.right);
       public int height()
           int leftHeight = 0, rightHeight = 0;
           return getHeight(root, leftHeight, rightHeight);
       private int getHeight(Node currentNode, int leftHeight, int rightHeight)
           if(currentNode == null)
               return 0;
           //else
           //    return 1 + Math.max(getHeight(currentNode.right), getHeight(currentNode.left));
           if(currentNode.left == null)
               leftHeight = 0;
           else
               leftHeight = getHeight(currentNode.left, leftHeight, rightHeight);
           if(currentNode.right == null)
               return 1 + leftHeight;
           return 1 + Math.max(leftHeight, getHeight(currentNode.right, leftHeight, rightHeight));
       public int size()
           return size;
       public boolean contains(long k)
            String bits = Long.toBinaryString(k);
            return contains(k, root, bits, bits.length());
       private boolean contains(long k, Node currentNode, String bits, int index)
           int lsb;
           try
               lsb = Integer.parseInt(bits.substring(index, index - 1));
           catch(StringIndexOutOfBoundsException e)
               lsb = 0;
           if(currentNode == null)
               return false;
           else if(currentNode.key == k)
               return true;
           else
               if(lsb == 0)
                   return contains(k, currentNode.left, bits, index-1);
               else
                   return contains(k, currentNode.right, bits, index-1);
       public Node locate(long k)
            if(contains(k))
                String bits = Long.toBinaryString(k);
                return locate(k, root, bits, bits.length());
            else
                return null;
       private Node locate(long k, Node currentNode, String bits, int index)
           int lsb;
           try
               lsb = Integer.parseInt(bits.substring(index, index - 1));
           catch(StringIndexOutOfBoundsException e)
               lsb = 0;
           if(currentNode.key == k)
               return currentNode;
           else
               if(lsb == 0)
                   return locate(k, currentNode.left, bits, index-1);
               else
                   return locate(k, currentNode.right, bits, index-1);
       public Object clone()
           DigitalTree<E> treeClone = null;
           try
               treeClone = (DigitalTree<E>)super.clone();
           catch(CloneNotSupportedException e)
               throw new Error(e.toString());
           cloneNodes(treeClone, root, treeClone.root);
           return treeClone;
       private void cloneNodes(DigitalTree treeClone, Node currentNode, Node cloneNode)
           if(treeClone.size == 0)
               cloneNode = null;
               cloneNodes(treeClone, currentNode.left, cloneNode.left);
               cloneNodes(treeClone, currentNode.right, cloneNode.right);
           else if(currentNode != null)
               cloneNode = currentNode;
               cloneNodes(treeClone, currentNode.left, cloneNode.left);
               cloneNodes(treeClone, currentNode.right, cloneNode.right);
       public void printTree()
           System.out.println("Tree");
       private class Node<E>
          private long key;
          private E data;
          private Node left;
          private Node right;
          public Node(long k)
             key = k;
             data = null;
             left = null;
             right = null;
          public Node(long k, E d)
             key = k;
             data = d;
             left = null;
             right = null;
          public String toString()
             return "" + key;
    }

    You were on the right track with the part you commented out; first define a few things:
    1) the height of an empty tree is nul (0);
    2) the height of a tree is one more than the maximum of the heights of the left and right sub-trees.
    This translates to Java as a recursive function like this:
    int getHeight(Node node) {
       if (node == null) // definition #1
          return 0;   
       else // definition #2
          return 1+Math.max(getHeight(node.left), getHeight(node.right));
    }kind regards,
    Jos

  • Binary tree - a spesific node's height !

    hello !
    im looking for a method to deterine a certain node's hight in a binary tree (that is its distance from the root )
    please enlighten me on how to do this if you can
    thank you

    > Traverse the BT and with every step increase a
    counter. When you get to the node you're looking for,
    return the counter.
    Or just add an attribute to you TreeNode class which holds the value for the degree/height of the node.

  • Getting the height of a binary tree

    So I am trying to create a method in my binary tree class that returns and integer that represents the height of the tree.
    I tried to do this recursively and it seems the numbers are close to the actual ones, but never exact and I haven't really been able to find out where the problem lies. This is my code:
    public int getHeight()
              int height;
              height = getHeightRecur(root);
              return height;
         public int getHeightRecur(BinTreeNode node)
              int theight;
              if(node == null)
                   theight = 0;
              else
                   theight = 1 + getMax(getHeightRecur(node.leftN), getHeightRecur(node.rightN));
              return theight;
         private int getMax(int x, int y)
              int result = 0;
              if(x>y)
                   result = x;
              if(y>x)
                   result = y;
              return result;
         }

    j2ee_ubuntu wrote:
    it may help at some extent..
    private int getMax(int x, int y)
              int result = 0;
              if(x>y)
                   result = x;
              else if(y>x)
                   result = y;
    else //when both are equal
    result =x; OR result = y;//You can use one of them
              return result;
         }Edited by: j2ee_ubuntu on Nov 6, 2008 12:30 AMWhy not just use [ Math.max|http://java.sun.com/javase/6/docs/api/java/lang/Math.html#max(int,%20int)] or write
    public static int max(int a, int b) {
        return (a >= b) ? a : b;
    }

  • How can i find out the height lenght width of that logo in so10 ?

    I have TextName is there in so10.
    How can i find out the height lenght width of that logo ?

    Hi Sam,
    In SE80, you should have a Repository for MIMES, including images.You should find your image here .
    you have to use the following method to get the image as a binary string and then use gui_download to download it to local system
    call method cl_ssf_xsf_utilities=>get_bds_graphic_as_bmp
    exporting
    p_object = fs_stxbitmaps-tdobject
    p_name = fs_stxbitmaps-tdname
    p_id = fs_stxbitmaps-tdid
    p_btype = fs_stxbitmaps-tdbtype
    receiving
    p_bmp = loc_graphic_xstr
    exceptions
    not_found = 1
    others = 2.
    Thn you can find the size of the logo.
    Regards
    Naresh

  • Basic binary search tree question

    Hi,
    I was just wondering, if there's a binary search tree that holds objects can the binary search tree be based on any of the attributes in those objects.
    So for example say we have a Person object and it has the attributes name, age, and height. Can we make a binary search tree based on the age or a search tree based on just the height.
    And lastly how would that be done in the comparable method.
    Thanks.

    Of course it depends on what (and whether) the Person class implements for Comparable. If you want to base the tree on the default comparison (i.e., the one that compareTo does) then you don't need a separate Comparator.
    When you write your binary tree implementation, it's wise to make it smart enough to either take a Comparator, or to use the default comparison (if the objects being tracked implement Comparable).
    Note that Comparators and Comparable have nothing to do with trees per se. It's not like a tree necessarily needs one or the other. It's simply very smart to use the existing Java framework to determine an order among objects.

  • Binary tree using inorder traversal algorithm

    I need to draw a Binary tree using Inorder traversal algorithm.. in java applets using rectangles and ellipse objects.. can anyone help me about this ? I will be really thankful to yu

    I think this is my psychic Sunday, so here's my attempt at answering
    this vaguely stated question. First have a look at this fine piece of
    ASCII art:--------------------------------------------   ^         ^
    | A                    T                     |   |         |
    |                                            |   |        root
    ---------L-----------------------R---------+   |         v
    | B                    |  C                  |   |
    |                      |                     |   |
    |                      |                     | height
    |                      |                     |   |
    |                      |                     |   |
    |                      |                     |   |
    |                      |                     |   |
    |                      |                     |   |
    |                      |                     |   |
    |                      |                     |   |
    -------------------------------------------+   v
    <--------------------width------------------->Suppose you have a rectangle 'width' wide and 'height' high. The root
    of the tree can be drawn at position T and (if present), two lines can be
    drawn to the positions L and R respectively. Now recursively call your
    same method using the computed rectangle A and B for the left and
    right subtrees L and R respectively.
    kind regards,
    Jos

  • How to Pretty Print a Binary Tree?

    I'm trying to display a Binary Tree in such a way:
    ________26
    ___13_________2
    1_______4 3_________1
    (without the underscores)
    however I cannot figure out the display method.
    class BinaryNode
              //Constructors
              BinaryNode leftChild, rightChild;
    Object data;
         BinaryNode()
    leftChild = null;
    data = null;
    rightChild = null;
              BinaryNode( Object d, BinaryNode left, BinaryNode right)
    leftChild = left;
    data = d;
    rightChild = right;
              //Height
              public static int Height(BinaryNode root)
    if (root == null)
    return 0;
    if ((Height(root.leftChild)) > Height(root.rightChild))
    return 1 + Height(root.leftChild);
    return 1 + Height(root.rightChild);
              //Count
    public static int Count(BinaryNode root)
    if(root==null)
    return 0;
    return 1 + Count(root.leftChild) + Count(root.rightChild);
              //Display
              public static void Display(BinaryNode root)
              int level = 2^(Level(root)-1)
              for (int i = 1; i<Height(root)+1; i++)
              System.out.printf("%-4s%
              Display(root, i);
              System.out.println();
              public static void Display(BinaryNode root, int level)
              if (root!=null)
              if(level==1)
              System.out.print(root.data + " ");
              else
              Display(root.leftChild, level-1);
              Display(root.rightChild, level-1);
              //Level
              public static int Level(BinaryNode root)
              if(root==null)
              return 0;
              if(root.leftChild == null && root.rightChild == null)
              return 1;
              return Level(root.leftChild) + Level(root.rightChild);
    Edited by: 815035 on Nov 23, 2010 12:27 PM

    The example of what the OP wants it to look like I thought was quite plain. Its right at the top of the post.
    Unfortunately it is also quite difficult to accomplish using System.out.print statements.
    You have to print out the root of the tree first (its at the top)
    However you don't know how far along to the right you need to print it without traversing the child nodes already (you need to know how deep the tree is, and how far to the left the tree extends from the root)
    So you will need to traverse the tree at least twice.
    Once to work out the offsets, and again to print out the values.
    The working out of offsets would have to be a depth search traversal I think
    The printing of the values in this fashion would be a breadth first traversal.
    I remember (ages ago) doing a similar assignment, except we printed the tree sideways.
    ie the root was on the left, the leaves of the tree on the right of the screen.
    That meant you could do an inorder depth traversal of the tree to just print it once.
    hope this helps,
    evnafets

  • Recover a Binary Tree

    Ok people I need help!
    I want to create, from a pre-order and in-order sequences, the post-order sequence! Obviously there are no repeated elements (characters from A to Z at this case).
    The tree root it's the first character from pre-order and after that it's easy to take left and right sequences.
    I found an interesting explanation: http://www.dcs.kcl.ac.uk/staff/pinz...st/html/l7.html
    I've tried everything to make it recursive I think that's the best way to do it but somehow I can't make it work! My last code:
    import java.io.*;
    import java.util.*;
    public class Problem
            static String readLn (int maxLg)  // utility function to read from stdin
                byte lin[] = new byte [maxLg];
                int lg = 0, car = -1;
                try
                    while (lg < maxLg)
                        car = System.in.read();
                        if ((car < 0) || (car == '\n')) break;
                        lin [lg++] += car;
                catch (IOException e)
                    return (null);
                if ((car < 0) && (lg == 0)) return (null);  // eof
                return (new String (lin, 0, lg));
            public static void main (String []args)
                    for (int set = Integer.parseInt(readLn(10).trim()); set != 0; set--)
                            StringTokenizer tok = new StringTokenizer(readLn(100).trim()," ");
                            String preOrd = tok.nextToken();
                            String inOrd = tok.nextToken();
                            char root = preOrd.charAt(0);
                            BinaryNode tree = new BinaryNode(root);
                            // Left and right from inOrd
                            tok = new StringTokenizer(inOrd,Character.toString(root));
                            String inOrdLeft = tok.nextToken();
                            String inOrdRight = tok.nextToken();
                            // Take left and right from preOrd
                            String preOrdLeft = preOrd.substring(1,inOrdLeft.length()+1);
                            String preOrdRight = preOrd.substring(inOrdLeft.length()+1);
                            tree.left = work (preOrdLeft, 0, inOrdLeft);
                            tree.right = work (preOrdRight, 0, inOrdRight);
                            tree.printPostOrder();
                            System.out.println();
            public static BinaryNode work (String preOrd, int preOrdPoint, String inOrd)
                    char    nodeChr = preOrd.charAt(preOrdPoint);
                    String  nodeStr = Character.toString(nodeChr);
                    //System.out.println("Root: "+nodeStr+" preOrd: "+preOrd+" inOrd: "+inOrd);
                    BinaryNode tempTree = new BinaryNode(nodeChr);
                    StringTokenizer tok = new StringTokenizer(inOrd,nodeStr);  
                    try
                            String newInOrdLeft = tok.nextToken();
                            if (newInOrdLeft.length() == 1) { tempTree.left = new BinaryNode(newInOrdLeft.toCharArray()[0]); }
                            else if (newInOrdLeft.length() != 0) { tempTree.left = work(preOrd, preOrdPoint+1, newInOrdLeft); }
                    catch (NoSuchElementException e) {}
                    try
                            String newInOrdRight = tok.nextToken();
                            if (newInOrdRight.length() == 1) { tempTree.right = new BinaryNode(newInOrdRight.toCharArray()[0]); }
                            else if (newInOrdRight.length() != 0) { tempTree.right = work(preOrd, preOrdPoint+1, newInOrdRight); }
                    catch (NoSuchElementException e) {}
                    return tempTree;
    class BinaryNode
            char chr;
            BinaryNode left = null;
            BinaryNode right = null;
            BinaryNode()
            BinaryNode(char c)
                    this(c, null, null);
            BinaryNode(char c, BinaryNode lt, BinaryNode rt)
                    chr = c;
                    left = lt;
                    right = rt;
            static int size(BinaryNode t)
                    if (t == null) { return 0; }
                    else { return size(t.left) + 1 + size(t.right); }
            static int height(BinaryNode t)
                    if (t == null) { return 0; }
                    else { return 1 + Math.max(BinaryNode.height(t.left), BinaryNode.height(t.right)); }
            void printPostOrder () {
                    if( left != null )
                            left.printPostOrder( ); // Left
                    if( right != null )
                            right.printPostOrder( ); // Right
                    System.out.print(chr); // Node
            static BinaryNode insert (char c, BinaryNode t)
                    Character tmp = new Character(c);
                    if (t == null)
                            t = new BinaryNode(c, null, null);
                    else if (tmp.compareTo(new Character(t.chr)) < 0)
                            t.left = insert(c, t.left );
                    else if (tmp.compareTo(new Character(t.chr)) > 0)
                            t.right = insert(c, t.right);
                    return t;
    }

    I don't know if this is a translation of your C code, but it can reconstruct any binary tree (with letters as nodes and no duplicates) from preorder and inorder traversals. Hope it helps.
    import java.util.*;
    public class ReconstructTree {
        public ReconstructTree() {
        public static void main(String[] args)
            String preorder = "ABDGKLRVWSXCEHMNFIOTUJPYQZ";
            String inorder = "KGVRWLSXDBAMHNECTOUIFPYJZQ";
            Map table = new HashMap();
            Map table2 = new HashMap();
            for(int i=0; i<inorder.length(); i++)
                table.put("" + inorder.charAt(i), new Integer(i));
                table2.put(new Integer(i), "" + inorder.charAt(i));
            List temppreorder = new ArrayList();
            for(int i=0; i<preorder.length(); i++)
                temppreorder.add(table.get("" + preorder.charAt(i)));
            Node root = constructTree(temppreorder);
            printPostOrder(root, table2);
        public static void printPostOrder(Node root, Map table)
            if(root == null)
                return;
            Node left = root.getLeft();
            Node right = root.getRight();
            printPostOrder(left, table);
            printPostOrder(right, table);
            System.out.print(table.get(new Integer(Integer.parseInt("" + root.getValue()))));
        public static Node constructTree(List preorder)
            Iterator it = preorder.iterator();
            int r = ((Integer)it.next()).intValue();
            Node root = new Node(r);
            Node node = root;
            while(it.hasNext())
                node = root;
                int a = ((Integer)it.next()).intValue();
                while(true)
                    r = node.getValue();
                    if(a < r)
                        if(node.getLeft() == null)
                            node.setLeft(new Node(a));
                            break;
                        else
                            node = node.getLeft();
                    else
                        if(node.getRight() == null)
                            node.setRight(new Node(a));
                            break;
                        else
                            node = node.getRight();
            return root;
        public static class Node
            private Node left = null;
            private Node right = null;
            private int value;
            public Node(int v)
                value = v;
            public int getValue()
                return value;
            public Node getLeft()
                return left;
            public Node getRight()
                return right;
            public void setLeft(Node l)
                left = l;
            public void setRight(Node r)
                right = r;
    }

  • Converting bytearray into binary format

    Hi I have a byteaary , I want to convert this byteArray data into binary format (01010101) , Please help me
    [Bindable]
                private var imgByte:ByteArray;
    bitmapData     = new BitmapData(pic.width, pic.height);
                     bitmapData.draw(pic,new Matrix());
                    var jpg:JPEGEncoder = new JPEGEncoder();
                    imgByte = jpg.encode(bitmapData) ;
    var i:int=imgByte.readByte()
    Alert.show(i.toString(2));
    thanks in advance

    Didn't toString(2) work?

  • MVC Display Binary Image from ViewBag

    I am having problem when displaying the binary image in MVC view. I stored images in database as binary format and then assigned to ViewBag in Controller. How do I assign viewbag data to image in View?
    Controller
    ItemBO mibo = new ItemBO();
    ViewBag.Picture1 = Convert.ToByte(mibo.GetImage(1));
    View
    var elem = document.createElement("img");
    elem.setAttribute("src", @ViewBag.Picture1);
    elem.setAttribute("style", "height:100%");
    elem.setAttribute("alt", "Image");
    document.getElementById("mydiv").appendChild(elem);
    Above code doesn't work as I expected. Any help would be appreciated.

    MVC section is at the below link.
    http://forums.asp.net/

  • How to render image from binary property of node?

    Hello!
    How to put the image to the page from binary property of node in cms? How tags can i use?

    Hi,
    I have an additional question, regarding the images of a page. As stated above, rendering them works fine. But now I would also like to have them resized within certain boundaries. Is there a way to define the min/max width/height in the design of the page component for these images?
    I tried adding a node (name='image', jcr:primaryType=nt:unstructured) to /etc/designs/<myproject>/jcr:content/<mypagecomponent>. I then added minHeight, minWidth, maxHeight, ... properties to that node, but it seems they are not being picked up by the img.png.java servlet from the libs/foundation/page component.
    I created this design node based on a similar node which was added in the design of <mypagecomponent> for an 'image' in a 'par' when I changed the design of it.
    So I'm wondering if it is at all possible to define a design for the image of a page and if it, how I should do it.
    Kind regards,
    Luc

  • Read Binary(raw Image) data from a file

    Hi
    PLEASE HELP, I want to Read Binary(Raw Image)data (16 bit integer) from a file and display on the JPanel or JFrame.

    Hi, you'll need to use MemoryImageSource.
    You read each RGB triple and add it to a pixel[].
    Heres the roughg idea.
    Hope that helps.
    Harley.
    int width,height;
    int[] pixels = new int[width*height];
    while(!fileDone)
    for(int i=0; i<(width*height) i++){
    int rgb = inputStream.readInt();
    pixels[i] = rgb;
    DirectColorModel colorModel = new DirectColorModel(16,0xff00,0x00ff,0x00ff);
    MemoryImageSource memImage = new MemoryImageSource(width,height,pixels,0,width));

  • Here's an animated binary and octal counter

    I was inspired by the "Milliseconds.fx" code example in the NetBeans pack and coded this animated counter. I've done binary and octal so far, but I'm going to work on abstracting a base class before doing decimal and hex. I know it's not all elegant and perfect, but it was a lot of fun.
    * Main.fx
    * Created on Jan 7, 2009, 6:22:07 PM
    import javafx.animation.Interpolator;
    import javafx.animation.Timeline;
    import javafx.scene.CustomNode;
    import javafx.scene.Group;
    import javafx.scene.layout.HBox;
    import javafx.scene.layout.VBox;
    import javafx.scene.Node;
    import javafx.scene.Scene;
    import javafx.scene.text.Font;
    import javafx.scene.text.Text;
    import javafx.stage.Stage;
    * @author Sidney Harrell
    var time: Integer on replace OldValue{
        binaryCounter.flip(time);
        octalCounter.flip(time);
    def binaryCounter = BinaryCounter{};
    def octalCounter = OctalCounter{};
    def timer = Timeline {
        keyFrames: [
            at (0s) {time => 0},
            at (6000s) {time => 100000 tween Interpolator.LINEAR }
    class OctalCounter extends CustomNode {
        def string = ["0", "1", "2", "3", "4", "5", "6", "7"];
        var digits: String[];
        var octalPlaceValues: Integer[] = [
            134217728
            16777216, 2097152
            262144,32768
            4096,512, 64
            8, 1];
        var digitNodes: Text[];
        var temp: Integer;
        public function flip(time:Integer) {
            if (time > octalPlaceValues[0] * 8) {
                temp=time mod octalPlaceValues[0] * 8;
            } else {
                temp=time;
            for (i in [0..9]) {
                if ((temp != 0)and(temp / octalPlaceValues[i] != 0)) {
                    digits[i] = string[temp / octalPlaceValues];
    temp = temp - octalPlaceValues[i]*(temp/octalPlaceValues[i]);
    } else {
    digits[i] = string[0];
    public override function create(): Node {
    for( i in [0..9]) {
    insert string[0] into digits;
    for (i in [0..9]) {
    insert Text {
    font: Font {
    size: 24
    x: 10,
    y: 30
    content: bind digits[i]
    } into digitNodes;
    return Group {
    content: HBox{
    spacing: 10
    content:[
    digitNodes
    Stage {
    title: "Binary Counter"
    width: 450
    height: 120
    scene: Scene {
    content: VBox {
    spacing: 10;
    content: [
    binaryCounter
    octalCounter
    timer.play();
    class BinaryCounter extends CustomNode {
    def string = ["0", "1", "2", "3", "4", "5", "6", "7", "8", "9",
    "A", "B", "C", "D", "E", "F"
    var digits: String[];
    var binaryPlaceValues: Integer[] = [16384 * 2 * 2, 16384 * 2, 16384, 8192, 4096, 2048, 1024,
    512, 256, 128, 64, 32, 16, 8, 4, 2, 1];
    var digitNodes: Text[];
    var temp: Integer;
    public function flip(time:Integer) {
    if (time > binaryPlaceValues[0] * 2) {
    temp=time mod binaryPlaceValues[0] * 2;
    } else {
    temp=time;
    for (i in [0..16]) {
    if ((temp != 0)and(temp / binaryPlaceValues[i] != 0)) {
    digits[i] = string[
    temp / binaryPlaceValues[i]];
    temp = temp - binaryPlaceValues[i];
    } else {
    digits[i] = string[0];
    public override function create(): Node {
    for( i in [0..16]) {
    insert string[0] into digits;
    for (i in [0..16]) {
    insert Text {
    font: Font {
    size: 24
    x: 10,
    y: 30
    content: bind digits[i]
    } into digitNodes;
    return Group {
    content: HBox{
    spacing: 10
    content:[
    digitNodes

    As promised, completed with all four major bases.
    import javafx.animation.Interpolator;
    import javafx.animation.Timeline;
    import javafx.scene.CustomNode;
    import javafx.scene.Group;
    import javafx.scene.layout.HBox;
    import javafx.scene.layout.VBox;
    import javafx.scene.Node;
    import javafx.scene.Scene;
    import javafx.scene.text.Font;
    import javafx.scene.text.Text;
    import javafx.stage.Stage;
    * @author Sidney Harrell
    def binaryCounter = BinaryCounter{};
    def octalCounter = OctalCounter{};
    def decimalCounter = DecimalCounter{};
    def hexCounter = HexCounter{};
    var time: Integer on replace OldValue{
        binaryCounter.flip(time);
        octalCounter.flip(time);
        decimalCounter.flip(time);
        hexCounter.flip(time);
    def timer = Timeline {
        keyFrames: [
            at (0s) {time => 0},
            at (6000s) {time => 100000 tween Interpolator.LINEAR }
    Stage {
        title: "Counters"
        width: 530
        height: 200
        scene: Scene {
            content: VBox {
                spacing: 10;
                content: [
                    binaryCounter
                    octalCounter
                    decimalCounter
                    hexCounter
    timer.play();
    abstract class Counter extends CustomNode {
        def digits = ["0", "1", "2", "3", "4", "5", "6", "7", "8", "9",
            "A", "B", "C", "D", "E", "F"];
        var placeValues: Integer[];
        var representation: String[];
        var digitNodes: Text[];
        var temp: Integer;
        var base: Integer;
        var places: Integer;
        public function flip(time:Integer) {
            if (time > placeValues[0] * base) {
                temp=time mod placeValues[0] * base;
            } else {
                temp=time;
            for (i in [0..places]) {
                if ((temp != 0)and(temp / placeValues[i] != 0)) {
                    representation[i] = digits[temp / placeValues];
    temp = temp - placeValues[i]*(temp/placeValues[i]);
    } else {
    representation[i] = digits[0];
    class OctalCounter extends Counter {
    public override function create(): Node {
    base = 8;
    places = 9;
    placeValues = [134217728, 16777216, 2097152, 262144, 32768,
    4096, 512, 64, 8, 1];
    for( i in [0..places]) {insert digits[0] into representation;};
    for (i in [0..6]) {insert Text {font: Font {size: 24}; x: 10, y: 30 content: digits[0]} into digitNodes;};
    for (i in [0..places]) {insert Text {font: Font {size: 24}; x: 10, y: 30 content: bind representation[i]} into digitNodes;};
    insert Text {font: Font {size: 24}; x: 10, y: 30 content: "octal"} into digitNodes;
    return Group {content: HBox{spacing: 10 content:[digitNodes];}};
    class BinaryCounter extends Counter {
    public override function create(): Node {
    base = 2;
    places = 16;
    placeValues = [16384 * 2 * 2, 16384 * 2, 16384, 8192, 4096, 2048, 1024,
    512, 256, 128, 64, 32, 16, 8, 4, 2, 1];
    for( i in [0..places]) {insert digits[0] into representation;};
    for (i in [0..places]) {insert Text {font: Font {size: 24}; x: 10, y: 30 content: bind representation[i]} into digitNodes;};
    insert Text {font: Font {size: 24}; x: 10, y: 30 content: "binary"} into digitNodes;
    return Group {content: HBox{spacing: 10 content:[digitNodes];}};
    class DecimalCounter extends Counter {
    public override function create(): Node {
    base = 10;
    places = 8;
    placeValues = [100000000, 10000000, 1000000, 100000, 10000, 1000,
    100, 10, 1];
    for( i in [0..places]) {insert digits[0] into representation;};
    for (i in [0..7]) {insert Text {font: Font {size: 24}; x: 10, y: 30 content: digits[0]} into digitNodes;};
    for (i in [0..places]) {insert Text {font: Font {size: 24}; x: 10, y: 30 content: bind representation[i]} into digitNodes;};
    insert Text {font: Font {size: 24}; x: 10, y: 30 content: "decimal"} into digitNodes;
    return Group {content: HBox{spacing: 10 content:[digitNodes];}};
    class HexCounter extends Counter {
    public override function create(): Node {
    base = 16;
    places = 6;
    placeValues = [16777216, 1048576, 65536, 4096, 256, 16, 1];
    for( i in [0..places]) {insert digits[0] into representation;};
    for (i in [0..9]) {insert Text {font: Font {size: 24}; x: 10, y: 30 content: digits[0]} into digitNodes;};
    for (i in [0..places]) {insert Text {font: Font {size: 24}; x: 10, y: 30 content: bind representation[i]} into digitNodes;};
    insert Text {font: Font {size: 24}; x: 10, y: 30 content: "hex"} into digitNodes;
    return Group {content: HBox{spacing: 10 content:[digitNodes];}}
    Edited by: sidney.harrell on Jan 12, 2009 7:49 PM
    added missing closing brace                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                           

  • Writting Methods of Binary Tree

    I am using java code to write some binary tree methods.
    Got stuck in some of the following methods.
    Hopefully i can get some help here.
    Public int width(){
    // Return the maximun number of nodes in each level
    Public boolean checkIsFullTree(){
    // Return true if the tree is a full tree (If all leaves are at the same depth then the tree is full)
    Public boolean checkIsCompleteTree(){
    // Return true if the tree is a full tree (If all leaves are at the same depth then the tree is full and is filled from left to right)
    at last
    Public int internalPathLength(){
    // Return The sum of all internal nodes of the paths from the root of an extended binary tree to each node.
    other words, the sum of all depths of nodes.
    Looking forawad to see some replies. Chrees

    I have came up with some ideas.
    Public boolean checkIsFullTree(TreeNode t, int currentHeight ) {
    int maxHeight = height(); // Maximum height.
    int currentHeight=currentHeight;
    if (t == null){
    return false;
    if (t.left() ! = null){
    currentHeight++;
    checkIsFullTree(t.left(), currentHeight);
    if (t.right() ! = null){
    currentHeight++;
    checkIsFullTree(t.right(), currentHeight);
    if ( t.left() == null && t.right() == null){
    if (currentHeight == maxHeight) {
    check = true;
    }else{
    check = false;
    But i am missing sometime here i guess.
    }

Maybe you are looking for

  • Error in Integration of Defect Module of HP QC with SolMan Ehp 1

    Hi, We are using QC version 10 patch 12 and connected with SolMan Ehp 1 for testing. We are facing a problem in integrating the defect module of QC with Service desk of SolMan. The required settings are done in SPRO -> SAP Solution Manager -> Scenari

  • Unlimited Data Plan - If Grandfathered, For how Long?

    Does anyone know how long one is grandfathered for if they had the Unlimited Data Plan prior to July 7th? I heard that it was only until your contract was up for renewal and then you would have to select one of the tiered options. Is that true? Thank

  • How to convert MM:SS into Seconds with varying values of Minutes length.

    I have one table in Oracle where there is one Column "Duration" and it is having entries like 59:00, 30:00, 59:05 30 120:45 etc. These entries are in Minutes and Seconds with MM:SS Format.Where MM:SS stands for Minute and SS is seconds only. Minutes

  • Mail 5: Change font size in Mailboxes column?

    Pretty happy with Mail 5 so far (one day in). Is there any way to change the font size for the left Mailboxes column? It's larger than the other two, and larger than I prefer.

  • Vevo App issues with Apple TV 6.02 update

    I have 2 Apple TVs.  One is running the 6.0 software and the newest Apple TV that we got for Christmas is running 6.02.  The Vevo app doesn't appear to be working correct on version on 6.02.  The videos have some sort of lag.  It is almost as if they