current position:Home>First establish the input data into a binary sort tree, and then find the data. Enter the keyword sequence (63, 90, 70, 55, 67, 42, 98, 83, 10, 45, 58). 1. Establish a binary sort tree according to the order of the entered keywords.
First establish the input data into a binary sort tree, and then find the data. Enter the keyword sequence (63, 90, 70, 55, 67, 42, 98, 83, 10, 45, 58). 1. Establish a binary sort tree according to the order of the entered keywords.
2022-02-02 14:25:17 【CSDN Q & A】
The phenomenon and background of the problem
Problem related code , Do not paste screenshots
Operation results and error reporting contents
My solution ideas and tried methods
What I want to achieve
Refer to the answer 1:
Reference resources :
#include<stdio.h>#include<stdlib.h>#include<string.h>#include <malloc.h>#define error 0#define ok 1typedef struct BiTNode{ char data; struct BiTNode *lchild,*rchild;}BiTNode,*BiTree;int CreateBiTree(BiTree T){ char ch; fflush(stdin); scanf("%c",&ch); if(ch=='#'){ T=NULL; return ok; }else { if(!(T=(BiTNode *)malloc(sizeof(BiTNode)))) exit(error); T->data=ch; CreateBiTree(T->lchild); CreateBiTree(T->rchild); } return ok;}void PreOrderBiTree(BiTree T){ if(T) { printf("%c",T->data); PreOrderBiTree(T->lchild); PreOrderBiTree(T->rchild); }}void InOrderBiTree(BiTree T){ if(T) { InOrderBiTree(T->lchild); // The middle order traverses the left subtree printf("%c",T->data); // access node InOrderBiTree(T->rchild); // The middle order traverses the right subtree }}void PostOrderBiTree(BiTree T){ if(T) { PostOrderBiTree(T->lchild); PostOrderBiTree(T->rchild); printf("%c",T->data); }}main(){ int i; BiTree T = NULL; printf("\t Please enter each element of the tree :\n\t"); CreateBiTree(T); printf("aaaaaaaaaaa"); do { printf(" /*****************************/\n"); printf("\t1 key : Sequential output ; \n\t2 key : Middle order output ;\n\t3 key : Sequential output !\n\t0 key : Exit procedure !\n"); printf("\t Please enter your choice :\n\t"); scanf("%d",&i); switch(i) { case 1:printf("\n\t What you choose is sequential output !! \n"); printf("\n\t The output is :\n"); printf("\t"); PreOrderBiTree(T);break; case 2:printf("\n\t You choose medium order output !! \n"); printf("\n\t The output is :\n"); printf("\t"); InOrderBiTree(T);break; case 3:printf("\n\t What you choose is sequential output !! \n"); printf("\n\t The output is :\n"); printf("\t"); PostOrderBiTree(T);break; } printf("\n"); }while(i!=0); return 0;}
Refer to the answer 2:
copyright notice
author[CSDN Q & A],Please bring the original link to reprint, thank you.
https://en.primo.wiki/2022/02/202202021425164853.html
The sidebar is recommended
- How to read text from TXT document, write it into excel and run it in reverse?
- Calculation of joint torque of detal manipulator
- Give a string representing the date and ask what day of the year it is
- [Vue] setting @ media to query font size is not effective
- How to use the ecarts national map to the city? I CV changed other people's codes and key values. Now this is the case
- Hbuilderx
- Design database (agricultural products sales database, clothing sales database and stamen sales database)
- Let's see if the course sequence of distributed architect is correct
- What's the matter with me? Please answer
- Link failure of distributed task scheduling
guess what you like
-
The bean tag calls auto assembly and has been given a parameterless construction Setget, why is class still null
-
"The column vectors of a matrix whose determinant is equal to zero may not be linearly correlated"
-
PTA 7-1 string sorting (10 points)
-
Output the full arrangement of all 1 2 3 4 5 in dictionary order
-
How to create SQL trigger
-
Stm32tftlcd displays Chinese character scrolling
-
The format of the command in the CMD window is unclear
-
What does the class name in the class mean? It's not a variable or a member function
-
Seems to have started a program called [com,.] Process. But failed to stop it, which is likely to cause a memory leak. Stack trace for Thread:
-
Object oriented programming questions
Random recommended
- What are the impossible out of stack sequences when a certain in stack sequence is CADB?
- How to do this!
- Given a matrix of N x n, find the matrix after 90 degrees of rotation
- Mac Pro M1 chip 13 inch how to delete non store software?
- Is there any student to answer the single linked list in the data structure
- On the problem of incomplete display of Vue multi selection box data
- About the problem of incomplete data acquisition in Vue's select multiple selection box
- 360 fast travel assistant how to delete
- What are the experimental equipment and requirements of C language experiment report
- Why do the left and right shifts of bit operations correspond to decimal multiplication and division
- C language will not be painful, seek solutions
- Trigger implementation inserts some fields of one table into another table
- A sine wave is known, with peak to peak value of 1V and frequency of 10kHz; Now it is necessary to obtain a sine wave with three times the frequency of the sine wave and a peak to peak value of 9V. Circuit diagram and parameter calculation process
- I want to ask whether this SQL statement is correct and can you get data? This error is displayed
- Using function to store and read text file test TXT
- I have encountered several array problems in C + +. I hope the big God can solve the puzzle. It's best to have comments
- Why does WindowBuilder keep making mistakes when running on eclipse
- What if there are only 5 plug-ins in QGIS
- Use the geo path map in echorts to operate, but import your own SVG and it will not be displayed
- Panel problem of vs2022
- Design a mathutils Java class file
- Design of identity authentication based on Lamport scheme
- How does Simulink simulate the neutral point of permanent magnet synchronous motor (connected to the midpoint of bus capacitance)?
- Excuse me: it is known that 9 of the 300 experimental samples have been wrongly divided. What is the penalty factor C in the SVM model?
- Is there any common Python tutorial that even a fool can understand?
- The pointer of the derived class shows why the value of the pointer data member converted to the base class has changed. Please explain
- Initialization of structure variables, application
- How can the data in the red box be displayed in the black box classification according to the status?
- Position in CSS: after fixed, it will appear in the original position after entering the page, and then flash to the fixed position
- How do the from attribute and to attribute of QML propertyanimation change
- Want to know what this code means
- Design a mathutils Java class file
- KNN algorithm can not come up with the best model selection
- After deployment, the project automatically reads the files under the login machine disk
- C # click the button to display the name of the folder on the control
- visual studio
- The use of cleanstate
- I don't understand what this means!!
- Machine learning Jupiter notebook spam filtering analysis report
- Run result and error content Print (dict_data ['content '] ['out']) keyerror: 'content, how to solve it?