Section tree header file C ++

Source: Internet
Author: User

The Interval Tree is also an extended data structure based on a binary tree. Each node stores the interval information.

This routine is mainly written for the next thing. Of course, it is also worth a long time.

// Intervaltree. H -- Interval Tree header file <br/> # include <iostream> </P> <p> namespace tree <br/>{< br/> typedef int item; <br/> typedef struct node <br/> {<br/> item min, Max; <br/> item maxofall; <br/> int number; <br/> struct node * left, * right; <br/>} node; <br/> const item negative_infinity = 1 <31; <br/> class intervaltree <br/> {<br/> PRIVATE: <br/> node * m_root; <br/> item m_min, m_max; <br/> int m_number; <Br/> bool m_outofspace; <br/> bool m_hasdiscovered; <br/> bool m_overlap (const item min, const item max) const; <br/> item m_max (const item A, const item B, const item c) const; <br/> node * m_makenode (void) const; <br/> node * m_updata (node * const PN) const; <br/> node * m_insert (node * PN ); <br/> node * m_delete (node * PN); <br/> node * m_search (node * PN) const; <br/> int m_searchall (Const node * const PN); <br/> void m_findnewminandmax (const node * PN); <br/> void m_release (const node * const PN) const; <br/> void m_inordertraversal (const node * const PN) const; <br/> Public: <br/> intervaltree (void ); <br/> bool insert (const item min, const item Max, const int number); <br/> bool Delete (const item min, const item max ); <br/> // Following function is the answer of <introd Uction to algorithms Second Edition> 14.3-3 <br/> node * search (const item min, const item max ); <br/> // Following function is the answer of <Introduction to algorithms Second Edition> 14.3-4 <br/> // or it can export element of nodes to screen or other data structural, it's easy. <br/> int searchall (const item min, const item max); <br/> void inordertraversal (void) const; <br/> ~ Intervaltree (void); <br/>}; <br/>}

Contact Us

The content source of this page is from Internet, which doesn't represent Alibaba Cloud's opinion; products and services mentioned on that page don't have any relationship with Alibaba Cloud. If the content of the page makes you feel confusing, please write us an email, we will handle the problem within 5 days after receiving your email.

If you find any instances of plagiarism from the community, please send an email to: info-contact@alibabacloud.com and provide relevant evidence. A staff member will contact you within 5 working days.

A Free Trial That Lets You Build Big!

Start building with 50+ products and up to 12 months usage for Elastic Compute Service

  • Sales Support

    1 on 1 presale consultation

  • After-Sales Support

    24/7 Technical Support 6 Free Tickets per Quarter Faster Response

  • Alibaba Cloud offers highly flexible support services tailored to meet your exact needs.