Tuesday, March 12, 2013
Binary Tree
Binary Trees
A binary tree is a tree in which each node can have maximum two children.
Thus each node can have no child, one child or two children
Consider a set of numbers: 25,63,13, 72,18,32,59,67.
we store these numbers in individual nodes of a singly linked list
To search for a particular item we have to go through the list, and maybe we have to go to the end of the list as well.
Thus if there were n numbers, our search complexity would be O(n).
suppose we order these numbers:
13,18,25,32,59,63,67,72. and store these in another linked list.
search complexity is still O(n)
You simply cannot apply binary search on a linked list with O(log n) complexity.
So a linear linked structure is not helping
The value at any node is more than the values stored in the left-child nodes,
and less than the values stored in the right-child nodes
Implementation
• A binary tree has a natural implementation in linked storage.
A tree is referenced with a pointer to its root.
A tree is a node with structure that contains more trees.
We have actually a tree located at each node of a tree.
http://www.cs.ucf.edu/courses/cop3502h.02/trees1.pdf
Labels:
Data Structures and Algorithms
tree traversal
- tree traversal
tree traversal refers to the process of visiting (examining and/or updating) each node in a tree data structure,
Such traversals are classified by the order in which the nodes are visited.
Although linked lists require more memory space than arrays ( as they have to store address at each node),
they have definite advantages over arrays.
Insertion and deletion of items can be carried out with out involving considerable movement of data.
http://www.cs.ucf.edu/courses/cop3502h.02/trees1.pdf
- Tree Traversals
Linked lists are traversed sequentially from first node to the last node.
However, there is no such natural linear order for the nodes of a tree.
Different orderings are possible for traversing a binary tree.
Every node in the tree is a root for the subtree that it points to.
There are three common traversals for binary trees:
• Preorder
• Inorder
• Postorder
These names are chosen according to the sequence in which the root node and its children are visited.
http://www.cs.ucf.edu/courses/cop3502h.02/trees1.pdf
- Tree Traversals
There are 3 common tree traversals.
1. in-order: left, root, right
2. pre-order: root, left, right
3. post-order: left, right, root
Note "pre" and "post" refer to when we visit the root.
(we always go from left to right throug leaves but when it is in-order root is in the middle,pre-order it's first and post-order it's last.)
The in-order traversal always prints the values in sorted order from smallest to largest.
http://www.math.ucla.edu/~wittman/10b.1.10w/Lectures/Lec18.pdf
- Depth-first search (DFS) is an algorithm for traversing or searching a tree, tree structure, or graph.
One starts at the root (selecting some node as the root in the graph case) and explores as far as possible along each branch before backtracking.
http://en.wikipedia.org/wiki/Depth-first_search
- In graph theory, breadth-first search (BFS) is a strategy for searching in a graph when search is limited to essentially two operations:
(a) visit and inspect a node of a graph; (b) gain access to visit the nodes that neighbor the currently visited node.
The BFS begins at a root node and inspects all the neighboring nodes
http://en.wikipedia.org/wiki/Breadth-first_search
- There are three types of depth-first traversal: pre-order, in-order and post-order. For a binary tree, they are defined as operations recursively at each node, starting with the root node follows:
Pre-order:
Visit the root.
Traverse the left subtree.
Traverse the right subtree.
In-order (symmetric):
Traverse the left subtree.
Visit the root.
Traverse the right subtree.
Post-order:
Traverse the left subtree.
Traverse the right subtree.
Visit the root.
http://en.wikipedia.org/wiki/Tree_traversal
- infix traversal gives an infix expression
pre-order traversal gives an pre-order expression
post-order traversal gives an post-order expression
infix,pre-order,post-order traversal example
http://www.cs.nuim.ie/~rosemary/se202/treenotes/sld029.htm
- infix,pre-order,post-order traversal example
http://www.cs.cuw.edu/csc/csc300/PowerPoint/TREE%20TRAVERSAL%20EXAMPLE.htm
- D = node, L = left, R =right
• Preorder (DLR) traversal yields: A, H, G, I,F, E, B, C, D
• Postorder (LRD) traversal yields: G, F, E, I,H, D, C, B, A
• In-order (LDR) traversal yields: G, H, F, I,E, A, B, D, C
• Level-order traversal yields: A, H, B, G, I,C, F, E, D
https://docs.google.com/viewer?a=v&q=cache:tUIMUu37Z0oJ:www.cs.siu.edu/~mengxia/Courses%2520PPT/220/finalreview.ppt+&hl=tr&gl=tr&pid=bl&srcid=ADGEEShcYilAqNqch2AN6p2yyA1XFccuhVzGrCzXYljzzrgoZdqR87OAqbgN_osKxdp3B4Jgy_KkgYCHvIImna7DTFXFxruRbv2o2yIOiBqzf6nd-sjahVvFsq0NOpRuZEjA3MrdXXMr&sig=AHIEtbRCSWKbeBnN-GpbuR0Kj_GGrNrgUA
- Inorder Traversal - LDR
The node’s left subtree is traversed
The node’s data is processed
The node’s right subtree is traversed
Preorder Traversal - DLR
The node’s data is processed
The node’s left subtree is traversed
The node’s right subtree is traversed
Postorder Traversal - LRD
The node’s left subtree is traversed
The node’s right subtree is traversed
The node’s data is processed
https://docs.google.com/viewer?a=v&q=cache:962RB0q-kPkJ:digital.cs.usu.edu/~allan/CS2/Slides/Ch20.pdf+&hl=tr&gl=tr&pid=bl&srcid=ADGEEShPsArt6bX6XAwSHqxzO9ueMEXYOczpYtzLEzcF_Ynxbjqt6S1oSfU6KZShCTWPLazYXtcZsAoDP-iJXq5Ajh_cxtYcXFFOlTGyvNt_1NJ3I4kv2c8oTNYkz372sJqPZFI2kVG0&sig=AHIEtbRfU_jyEsuIyuN6vdEPyzXhoCCEtA
Labels:
Data Structures and Algorithms
HTML5
- What is HTML5?
Some rules for HTML5 were established:
New features should be based on HTML, CSS, DOM, and JavaScript
Reduce the need for external plugins (like Flash)
Better error handling
More markup to replace scripting
HTML5 should be device independent
The development process should be visible to the public
http://www.w3schools.com/html/html5_intro.asp
- HTML5
HTML5 is a markup language for structuring and presenting content for the World Wide Web and a core technology of the Internet.
It is the fifth revision of the HTML standard (created in 1990 and standardized as HTML 4 as of 1997) and, as of December 2012, is a W3C Candidate Recommendation.
http://en.wikipedia.org/wiki/HTML5
Labels:
web 2.0
RELAX NG
- RELAX NG
In computing, RELAX NG (REgular LAnguage for XML Next Generation) is a schema language for XML
A RELAX NG schema specifies a pattern for the structure and content of an XML document.
A RELAX NG schema is itself an XML document; however, RELAX NG also offers a popular compact, non-XML syntax
http://en.wikipedia.org/wiki/RELAX_NG
Labels:
Web Service Technologies
MTOM
MTOM
MTOM is the W3C Message Transmission Optimization Mechanism, a method of efficiently sending binary data to and from Web services.
MTOM is usually used with XOP (XML-binary Optimized Packaging).
http://en.wikipedia.org/wiki/Message_Transmission_Optimization_Mechanism
Labels:
Web Service Technologies
Subscribe to:
Posts (Atom)