Practices
  Home arrow Practices arrow Page 7 - Sort This Sort That
Dev Shed Forums 
Administration  
Apache  
BrainDump  
DHTML  
Flash  
Java  
JavaScript  
Multimedia  
MySQL  
Oracle  
Perl  
PHP  
Practices  
Python  
Reviews  
Security  
Style-Sheets  
Web Services  
XML  
Zend  
Zope  
Forums Sitemap 
IBM® developerWorks 
Dedicated Servers 
E-Commerce Hosting 
Linux Web Hosting 
Managed Hosting 
Small Business Hosting 
Download TestComplete 
VPS Hosting 
Weekly Newsletter

 
Developer Updates  
Free Website Content 
IBM Rational Software Development Conference
 RSS  Articles
 RSS  Forums
 RSS  All Feeds
Write For Us Get Paid 
Request Media Kit
Contact Us 
Site Map 
Privacy Policy 
Support 
 USERNAME
 
 PASSWORD
 
 
  >>> SIGN UP!  
  Lost Password? 
PRACTICES

Sort This Sort That
By: Djordje Popovic
  • Search For More Articles!
  • Disclaimer
  • Author Terms
  • Rating: 4 stars4 stars4 stars4 stars4 stars / 21
    2004-02-25

    Table of Contents:
  • Sort This Sort That
  • Sorting
  • Inserting Methods
  • Decrementing Increment or Just Shell-Sort
  • Selection Methods
  • Sorting with Binary Tree
  • Left(node) and Right(node)

  • Rate this Article: Poor Best 
      ADD THIS ARTICLE TO:
      Del.ici.ous Digg
      Blink Simpy
      Google Spurl
      Y! MyWeb Furl
    Email Me Similar Content When Posted
    Add Developer Shed Article Feed To Your Site
    Email Article To Friend
    Print Version Of Article
    PDF Version Of Article
     
     
     
    ADVERTISEMENT

    Dell PowerEdge Servers

    Sort This Sort That - Left(node) and Right(node)
    (Page 7 of 7 )

    First, something about the procedure that goes through this binary tree creating sorted array. We have a procedure get_value(node) that accepts as an argument the type of node and gets the node's data value and puts it in an array.  There are also two procedures named left(node) and right(node) that return the left or right child node of the parent node set as the argument (this means pointers to the left or right child-node). If this is clear, see the procedure for sorting.


    BINARY_TREE_SORT(root)
    if
    (root!=nullthen
     BINARY_TREE_SORT
    (left(root))
     get_value
    (root)
     BINARY_TREE_SORT
    (right(root))
    end_if

    As it is shown this procedure is recursive and accepts one argument of type node. When we start this procedure it recursively calls itself until it reaches the further-most left child-node that has no left child of it's own. Then with a get_value procedure, it stores that node's data value in the array and again calls binary_tree_sort procedure for that node’s further-most right child.  This recursion goes on until all elements (all recursion ends) are visited. This algorithm is efficient for all kinds of binary trees and also known as "inorder tree visit".

    Conclusion

    I have presented two types of sorting methods: inserting and selection methods. In the next article we will go further with inner-sorting methods and I will try to present to you some linear-complex methods for sorting such as counting-sort, bucket-sort and distribution sort. Until then enjoy your sorting!


    DISCLAIMER: The content provided in this article is not warranted or guaranteed by Developer Shed, Inc. The content provided is intended for entertainment and/or educational purposes in order to introduce to the reader key ideas, concepts, and/or product reviews. As such it is incumbent upon the reader to employ real-world tactics for security and implementation of best practices. We are not liable for any negative consequences that may result from implementing any information covered in our articles or tutorials. If this is a hardware review, it is not recommended to open and/or modify your hardware.

     

       

    PRACTICES ARTICLES

    - The System in So Many Words
    - Basic Data Types and Calculations
    - What`s the Address? Pointers
    - Design with ArgoUML
    - Pragmatic Guidelines: Diagrams That Work
    - Five-Step UML: OOAD for Short Attention Span...
    - Five-Step UML: OOAD for Short Attention Span...
    - Introducing UML: Object-Oriented Analysis an...
    - Class and Object Diagrams
    - Class Relationships
    - Classes
    - Basic Ideas
    - Choosing the Right Team
    - Trees
    - Basic Array Searching in C++

     
    Accelerating Trading Partner Performance
     
    Competing on Analytics
     
    Cost Effective Scaling with Virtualization and Coyote Point Systems
     
    Five Checkpoints to Implementing IP Telephony
     
    Hosted Email Security: Staying Ahead of New Threats
     




    © 2003-2008 by Developer Shed. All rights reserved. DS Cluster 2 hosted by Hostway