Data Structure Tree Basics

Data Type-List
Data Strucutre-Linked List

Tree:
As a data type, a tree has a value and children, and the children are themselves trees; the value and children of the tree are interpreted as the value of the root node and the subtrees of the children of the root node.
As a data structure, a linked tree is a group of nodes, where each node has a value and a list of references to other nodes (its children). This data structure actually defines a directed graph,[a] because it may have loops or several references to the same node, just as a (corrupt) linked list may have a loop. Thus there is also the requirement that no two references point to the same node (that each node has at most a single parent, and in fact exactly one parent, except for the root), and a tree that violates this is “corrupt”.
a tree is always non-empty, but a reference to a tree may be null.
Recursive
As a Data Type

  • t: v [t[1], …, t[k]] -(A tree t consists of a value v and a list of other trees.)
  • f: [t[1], …, t[[k]]
    t: v f -(a tree can be defined in terms of a forest (a list of trees), where a tree consists of a value and a forest (the subtrees of its children):

As a data structure

  • n: v [&n[1], …, &n[k]] -((A node n consists of a value v and a list of other references to other nodes.)
  • Terminology
    node:
    An internal node (also known as an inner node, inode for short, or branch node) is any node of a tree that has child nodes.
    External node (also known as an outer node, leaf node, or terminal node) is any node that does not have child nodes.
    height of a node is the length of the longest downward path to a leaf from that node. The height of the root is the height of the tree
    The depth of a node is the length of the path to its root (i.e., its root path

    Ref:
    http://mathworld.wolfram.com/RootedTree.html
    http://en.wikipedia.org/wiki/Tree_(data_structure)

    JAVA Performance -Memory,Runtime

    Escape Analysis

    • The JVM uses therefore internally escape analysis to check if an object is used only with a thread or method. If the JVM identify this it may decide to create the object on the stack, increasing performance of the Java program.

    Garbage collector

    • java -verbose:gc myProgram
    • How to enable Garbage Collection (GC) logs To enable GC logs, the -Xloggc:logFileName option will have to be passed when java command is being executed. Additionally if the detailed log of the GC is required, then an additional -XX:+PrintGCDetails option will have to be passed.Example: java -Xloggc:D:/log/myLogFile.log -XX:+PrintGCDetails myProg

    calculate Interest on your Policy

    What is the interest earned on this investment ? 31,000 per year for 30 years becomes 23,10,000 .

    Annuity formula is :

    Maturity value = Amount paid per year * [ {(1+r)^n – 1}/r ] * (1+r)
    Here n = 30 years
    and r = rate of interest earned

    Putting all these values

    23,10,000 = 31,000 * [{(1+r)^30 -1}/r] * (1+r)

    The value of r which satisfies this equation is 5.4 .

    ref:http://www.jagoinvestor.com/2008/10/why-endowment-policy-are-never-best_08.html
    know your maturity amount : http://licpolizy.com

    My First Post

    Perform Logarithms in Your Head

    1. When someone gives you any positive number, you should immediately ‘write’ that number in scientific notation in your head.

    2. Next, focus only on the exponent of the number (written in scientific notation). This number will be the basis of you answer.

    3. Estimate the logarithm of the abscissa in your head (thats the number between 1 and 9.999999…, not part of the exponent). Note: you’ll need to memorize the table below (its not that hard).

    4. Add the logarithm of the abscissa to the exponent you found in step 2.

    What follows are the values for the logs you’ll need to have memorized for step 3…

    log(1)=0
    log(2)=.3010
    log(3)=.4771
    log(4)=.6020
    log(5)=.6990
    log(6)=.7781
    log(7)=.8451
    log(8)=.9031
    log(9)=.9542

    As an example, lets find the logarithm of 29,012. Written in scientific notation, that would be 2.9012 X 10^4. So, the exponent is 4. Now, we need to concentrate on the abscissa (2.9012 is very very close to 3). From our table above (which we have memorized for the trick), the logarithm of 3 is 0.4771. So, we add the exponent (4), to the log of the abscissa (0.48), to get a value of 4.4771

    Perform Logarithms in Your Head