Rotate the 90-degree output binary tree counterclockwise (Data Structure Test 2)

Source: Internet
Author: User





Rotating a 90-degree print binary tree in a counter-clockwise manner is a special medium-order traversal algorithm.

Rotate 90 degrees counter-clockwise


The implementation is also very simple, similar to the middle-order traversal algorithm. Before the output node value, use a special mark to record the layers and output appropriate spaces.

Code:

Void prtbtree (bitnode * P, int cur) // rotate the 90-degree output binary tree counterclockwise {If (p) {prtbtree (p-> RCH, cur + 1 ); for (INT I = 0; I <= cur; I ++) printf (""); printf ("% 3C", p-> data ); printf ("\ n"); prtbtree (p-> LCH, cur + 1 );}}


Rotate the 90-degree output binary tree counterclockwise (Data Structure Test 2)

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.