SlideShare a Scribd company logo
1 of 3
Download to read offline
Help with implementing the four function the first is an example
thanks
def inorder(T,f):
if not is_bst(T):
return
if not T:
return
inorder(T[1],f)
f(T[0])
inorder(T[2],f)
# programming project: provide implementations for the functions below
# and add tests for these functions to the code in the block
# that starts "if __name__ == '__main__'"
def preorder(T,f):
pass
def postorder(T,f):
pass
def tree_height(T):
pass
def balance(T):
# returns the height of the left subtree of T
# minus the height of the right subtree of T
pass
Solution
class Node:
def _init_(self,val):
self.value=val
self.leftChild=None
self.rightChild=None
def preorder(self):
if self:
print(str(self.value))
if self.leftChild:
self.leftChild. preorder()
if self.rightChild:
self. rightChild. preorder()
def postorder(self):
if self:
if self.leftChild:
self.leftChild. postorder ()
if self.rightChild:
self. rightChild. postorder ()
print(str(self.value))
def inorder(self):
if self:
if self.leftChild:
self.leftChild. inorder ()
print(str(self.value))
if self.rightChild:
self. rightChild. inorder ()
def height(self,root):
if root is None:
reture 0
else:
return max(self.height(root.left),self.height(root.right))+1
det balance(self,root):
if root is None:
return 0
else:
leftHeight= height(root.left)
rightHeight= height(root.right)
if leftHeight- rightHeight<=1 :
return 1
else:
return 0
class Tree:
def _init_(self):
self.root=None
def preorder(self):
print(“Preorder)”
self.root.preorder()
def postorder(self):
print(“Postorder)”
self.root. postorder ()
def inorder(self):
print(“Inorder)”
self.root. inorder ()
bst=Tree()
bst.preorder()
bst.postorder()
bst.inorder()
print("Height of tree is " (height (bst)))
if (balance(bst):
print (“Tree is balance”)
else
print (“Tree is not balance”)

More Related Content

Similar to Help with implementing the four function the first is an exampleth.pdf

Paolo Galeone - Dissecting tf.function to discover auto graph strengths and s...
Paolo Galeone - Dissecting tf.function to discover auto graph strengths and s...Paolo Galeone - Dissecting tf.function to discover auto graph strengths and s...
Paolo Galeone - Dissecting tf.function to discover auto graph strengths and s...MeetupDataScienceRoma
 
# Imports# Include your imports here, if any are used. import.pdf
 # Imports# Include your imports here, if any are used. import.pdf # Imports# Include your imports here, if any are used. import.pdf
# Imports# Include your imports here, if any are used. import.pdfgulshan16175gs
 
python practicals-solution-2019-20-class-xii.pdf
python practicals-solution-2019-20-class-xii.pdfpython practicals-solution-2019-20-class-xii.pdf
python practicals-solution-2019-20-class-xii.pdfrajatxyz
 
pandas dataframe notes.pdf
pandas dataframe notes.pdfpandas dataframe notes.pdf
pandas dataframe notes.pdfAjeshSurejan2
 
TensorFlow for IITians
TensorFlow for IITiansTensorFlow for IITians
TensorFlow for IITiansAshish Bansal
 
Fp in scala part 2
Fp in scala part 2Fp in scala part 2
Fp in scala part 2Hang Zhao
 
Types by Adform Research
Types by Adform ResearchTypes by Adform Research
Types by Adform ResearchVasil Remeniuk
 
Need help filling out the missing sections of this code- the sections.docx
Need help filling out the missing sections of this code- the sections.docxNeed help filling out the missing sections of this code- the sections.docx
Need help filling out the missing sections of this code- the sections.docxlauracallander
 
Functions, Types, Programs and Effects
Functions, Types, Programs and EffectsFunctions, Types, Programs and Effects
Functions, Types, Programs and EffectsRaymond Roestenburg
 
import os import matplotlib-pyplot as plt import pandas as pd import r.docx
import os import matplotlib-pyplot as plt import pandas as pd import r.docximport os import matplotlib-pyplot as plt import pandas as pd import r.docx
import os import matplotlib-pyplot as plt import pandas as pd import r.docxBlake0FxCampbelld
 
Working with tf.data (TF 2)
Working with tf.data (TF 2)Working with tf.data (TF 2)
Working with tf.data (TF 2)Oswald Campesato
 
solution-of-practicals-class-xii-comp.-sci.-083-2021-22 (1).pdf
solution-of-practicals-class-xii-comp.-sci.-083-2021-22 (1).pdfsolution-of-practicals-class-xii-comp.-sci.-083-2021-22 (1).pdf
solution-of-practicals-class-xii-comp.-sci.-083-2021-22 (1).pdfparthp5150s
 

Similar to Help with implementing the four function the first is an exampleth.pdf (20)

Paolo Galeone - Dissecting tf.function to discover auto graph strengths and s...
Paolo Galeone - Dissecting tf.function to discover auto graph strengths and s...Paolo Galeone - Dissecting tf.function to discover auto graph strengths and s...
Paolo Galeone - Dissecting tf.function to discover auto graph strengths and s...
 
ECE-PYTHON.docx
ECE-PYTHON.docxECE-PYTHON.docx
ECE-PYTHON.docx
 
# Imports# Include your imports here, if any are used. import.pdf
 # Imports# Include your imports here, if any are used. import.pdf # Imports# Include your imports here, if any are used. import.pdf
# Imports# Include your imports here, if any are used. import.pdf
 
python practicals-solution-2019-20-class-xii.pdf
python practicals-solution-2019-20-class-xii.pdfpython practicals-solution-2019-20-class-xii.pdf
python practicals-solution-2019-20-class-xii.pdf
 
Ch8a
Ch8aCh8a
Ch8a
 
Chapter 02 functions -class xii
Chapter 02   functions -class xiiChapter 02   functions -class xii
Chapter 02 functions -class xii
 
pandas dataframe notes.pdf
pandas dataframe notes.pdfpandas dataframe notes.pdf
pandas dataframe notes.pdf
 
Programs.doc
Programs.docPrograms.doc
Programs.doc
 
AI-Programs.pdf
AI-Programs.pdfAI-Programs.pdf
AI-Programs.pdf
 
TensorFlow for IITians
TensorFlow for IITiansTensorFlow for IITians
TensorFlow for IITians
 
Fp in scala part 2
Fp in scala part 2Fp in scala part 2
Fp in scala part 2
 
Functions in python3
Functions in python3Functions in python3
Functions in python3
 
Types by Adform Research
Types by Adform ResearchTypes by Adform Research
Types by Adform Research
 
Need help filling out the missing sections of this code- the sections.docx
Need help filling out the missing sections of this code- the sections.docxNeed help filling out the missing sections of this code- the sections.docx
Need help filling out the missing sections of this code- the sections.docx
 
Functions, Types, Programs and Effects
Functions, Types, Programs and EffectsFunctions, Types, Programs and Effects
Functions, Types, Programs and Effects
 
import os import matplotlib-pyplot as plt import pandas as pd import r.docx
import os import matplotlib-pyplot as plt import pandas as pd import r.docximport os import matplotlib-pyplot as plt import pandas as pd import r.docx
import os import matplotlib-pyplot as plt import pandas as pd import r.docx
 
Type hints Python 3
Type hints  Python 3Type hints  Python 3
Type hints Python 3
 
Working with tf.data (TF 2)
Working with tf.data (TF 2)Working with tf.data (TF 2)
Working with tf.data (TF 2)
 
solution-of-practicals-class-xii-comp.-sci.-083-2021-22 (1).pdf
solution-of-practicals-class-xii-comp.-sci.-083-2021-22 (1).pdfsolution-of-practicals-class-xii-comp.-sci.-083-2021-22 (1).pdf
solution-of-practicals-class-xii-comp.-sci.-083-2021-22 (1).pdf
 
Array
ArrayArray
Array
 

More from aroraenterprisesmbd

In the following list, which term is least related to the others tr.pdf
In the following list, which term is least related to the others  tr.pdfIn the following list, which term is least related to the others  tr.pdf
In the following list, which term is least related to the others tr.pdfaroraenterprisesmbd
 
If your organization is going to apply for a grant, when do you thin.pdf
If your organization is going to apply for a grant, when do you thin.pdfIf your organization is going to apply for a grant, when do you thin.pdf
If your organization is going to apply for a grant, when do you thin.pdfaroraenterprisesmbd
 
If the characteristic followed in the pedigree is x-linked recessive .pdf
If the characteristic followed in the pedigree is x-linked recessive .pdfIf the characteristic followed in the pedigree is x-linked recessive .pdf
If the characteristic followed in the pedigree is x-linked recessive .pdfaroraenterprisesmbd
 
I want to know the purpose of parting lineSolutionA parting li.pdf
I want to know the purpose of parting lineSolutionA parting li.pdfI want to know the purpose of parting lineSolutionA parting li.pdf
I want to know the purpose of parting lineSolutionA parting li.pdfaroraenterprisesmbd
 
HTML5 & JqueryJavascriptI am trying to code a image slider and I.pdf
HTML5 & JqueryJavascriptI am trying to code a image slider and I.pdfHTML5 & JqueryJavascriptI am trying to code a image slider and I.pdf
HTML5 & JqueryJavascriptI am trying to code a image slider and I.pdfaroraenterprisesmbd
 
How to access this window in ANSYS (Picture 1 contains analysis s.pdf
How to access this window in ANSYS (Picture 1 contains analysis s.pdfHow to access this window in ANSYS (Picture 1 contains analysis s.pdf
How to access this window in ANSYS (Picture 1 contains analysis s.pdfaroraenterprisesmbd
 
How and when do we learn ethicsHow and when do we learn ethics.pdf
How and when do we learn ethicsHow and when do we learn ethics.pdfHow and when do we learn ethicsHow and when do we learn ethics.pdf
How and when do we learn ethicsHow and when do we learn ethics.pdfaroraenterprisesmbd
 
How does a dominant culture differ from a subculture In your answer.pdf
How does a dominant culture differ from a subculture In your answer.pdfHow does a dominant culture differ from a subculture In your answer.pdf
How does a dominant culture differ from a subculture In your answer.pdfaroraenterprisesmbd
 
Encrypt the message HALT by translating the letters into numbe.pdf
Encrypt the message  HALT  by translating the letters into numbe.pdfEncrypt the message  HALT  by translating the letters into numbe.pdf
Encrypt the message HALT by translating the letters into numbe.pdfaroraenterprisesmbd
 
Each letter in the word Massachusetts is written on a card. The card.pdf
Each letter in the word Massachusetts is written on a card. The card.pdfEach letter in the word Massachusetts is written on a card. The card.pdf
Each letter in the word Massachusetts is written on a card. The card.pdfaroraenterprisesmbd
 
Below is the question I need help with. It need to be done in Java. .pdf
Below is the question I need help with. It need to be done in Java. .pdfBelow is the question I need help with. It need to be done in Java. .pdf
Below is the question I need help with. It need to be done in Java. .pdfaroraenterprisesmbd
 
Css code for a awoko newspaper html website which provides busines.pdf
Css code for a awoko newspaper html website which provides busines.pdfCss code for a awoko newspaper html website which provides busines.pdf
Css code for a awoko newspaper html website which provides busines.pdfaroraenterprisesmbd
 
Case study Job Satisfaction in the Banking Industry Or the logisti.pdf
Case study Job Satisfaction in the Banking Industry Or the logisti.pdfCase study Job Satisfaction in the Banking Industry Or the logisti.pdf
Case study Job Satisfaction in the Banking Industry Or the logisti.pdfaroraenterprisesmbd
 
You are constructing working models of the heart for extra credit You.pdf
You are constructing working models of the heart for extra credit You.pdfYou are constructing working models of the heart for extra credit You.pdf
You are constructing working models of the heart for extra credit You.pdfaroraenterprisesmbd
 
why does countercurrent flow yields greater oxygen uptake than concu.pdf
why does countercurrent flow yields greater oxygen uptake than concu.pdfwhy does countercurrent flow yields greater oxygen uptake than concu.pdf
why does countercurrent flow yields greater oxygen uptake than concu.pdfaroraenterprisesmbd
 
Wind Shear can be defined in the horizontal plane as well as the vert.pdf
Wind Shear can be defined in the horizontal plane as well as the vert.pdfWind Shear can be defined in the horizontal plane as well as the vert.pdf
Wind Shear can be defined in the horizontal plane as well as the vert.pdfaroraenterprisesmbd
 
While hiking on some small islands in Lake Superior, you stumble acr.pdf
While hiking on some small islands in Lake Superior, you stumble acr.pdfWhile hiking on some small islands in Lake Superior, you stumble acr.pdf
While hiking on some small islands in Lake Superior, you stumble acr.pdfaroraenterprisesmbd
 
Which phyla have megaphylls Bryophyta Monilophyta Coniferophyta .pdf
Which phyla have megaphylls  Bryophyta  Monilophyta  Coniferophyta  .pdfWhich phyla have megaphylls  Bryophyta  Monilophyta  Coniferophyta  .pdf
Which phyla have megaphylls Bryophyta Monilophyta Coniferophyta .pdfaroraenterprisesmbd
 
Where do endocyotic vesicles come fromA. Plasma membranceB. Nuc.pdf
Where do endocyotic vesicles come fromA. Plasma membranceB. Nuc.pdfWhere do endocyotic vesicles come fromA. Plasma membranceB. Nuc.pdf
Where do endocyotic vesicles come fromA. Plasma membranceB. Nuc.pdfaroraenterprisesmbd
 
When considering the AFN equation, we exclude notes payables from ou.pdf
When considering the AFN equation, we exclude notes payables from ou.pdfWhen considering the AFN equation, we exclude notes payables from ou.pdf
When considering the AFN equation, we exclude notes payables from ou.pdfaroraenterprisesmbd
 

More from aroraenterprisesmbd (20)

In the following list, which term is least related to the others tr.pdf
In the following list, which term is least related to the others  tr.pdfIn the following list, which term is least related to the others  tr.pdf
In the following list, which term is least related to the others tr.pdf
 
If your organization is going to apply for a grant, when do you thin.pdf
If your organization is going to apply for a grant, when do you thin.pdfIf your organization is going to apply for a grant, when do you thin.pdf
If your organization is going to apply for a grant, when do you thin.pdf
 
If the characteristic followed in the pedigree is x-linked recessive .pdf
If the characteristic followed in the pedigree is x-linked recessive .pdfIf the characteristic followed in the pedigree is x-linked recessive .pdf
If the characteristic followed in the pedigree is x-linked recessive .pdf
 
I want to know the purpose of parting lineSolutionA parting li.pdf
I want to know the purpose of parting lineSolutionA parting li.pdfI want to know the purpose of parting lineSolutionA parting li.pdf
I want to know the purpose of parting lineSolutionA parting li.pdf
 
HTML5 & JqueryJavascriptI am trying to code a image slider and I.pdf
HTML5 & JqueryJavascriptI am trying to code a image slider and I.pdfHTML5 & JqueryJavascriptI am trying to code a image slider and I.pdf
HTML5 & JqueryJavascriptI am trying to code a image slider and I.pdf
 
How to access this window in ANSYS (Picture 1 contains analysis s.pdf
How to access this window in ANSYS (Picture 1 contains analysis s.pdfHow to access this window in ANSYS (Picture 1 contains analysis s.pdf
How to access this window in ANSYS (Picture 1 contains analysis s.pdf
 
How and when do we learn ethicsHow and when do we learn ethics.pdf
How and when do we learn ethicsHow and when do we learn ethics.pdfHow and when do we learn ethicsHow and when do we learn ethics.pdf
How and when do we learn ethicsHow and when do we learn ethics.pdf
 
How does a dominant culture differ from a subculture In your answer.pdf
How does a dominant culture differ from a subculture In your answer.pdfHow does a dominant culture differ from a subculture In your answer.pdf
How does a dominant culture differ from a subculture In your answer.pdf
 
Encrypt the message HALT by translating the letters into numbe.pdf
Encrypt the message  HALT  by translating the letters into numbe.pdfEncrypt the message  HALT  by translating the letters into numbe.pdf
Encrypt the message HALT by translating the letters into numbe.pdf
 
Each letter in the word Massachusetts is written on a card. The card.pdf
Each letter in the word Massachusetts is written on a card. The card.pdfEach letter in the word Massachusetts is written on a card. The card.pdf
Each letter in the word Massachusetts is written on a card. The card.pdf
 
Below is the question I need help with. It need to be done in Java. .pdf
Below is the question I need help with. It need to be done in Java. .pdfBelow is the question I need help with. It need to be done in Java. .pdf
Below is the question I need help with. It need to be done in Java. .pdf
 
Css code for a awoko newspaper html website which provides busines.pdf
Css code for a awoko newspaper html website which provides busines.pdfCss code for a awoko newspaper html website which provides busines.pdf
Css code for a awoko newspaper html website which provides busines.pdf
 
Case study Job Satisfaction in the Banking Industry Or the logisti.pdf
Case study Job Satisfaction in the Banking Industry Or the logisti.pdfCase study Job Satisfaction in the Banking Industry Or the logisti.pdf
Case study Job Satisfaction in the Banking Industry Or the logisti.pdf
 
You are constructing working models of the heart for extra credit You.pdf
You are constructing working models of the heart for extra credit You.pdfYou are constructing working models of the heart for extra credit You.pdf
You are constructing working models of the heart for extra credit You.pdf
 
why does countercurrent flow yields greater oxygen uptake than concu.pdf
why does countercurrent flow yields greater oxygen uptake than concu.pdfwhy does countercurrent flow yields greater oxygen uptake than concu.pdf
why does countercurrent flow yields greater oxygen uptake than concu.pdf
 
Wind Shear can be defined in the horizontal plane as well as the vert.pdf
Wind Shear can be defined in the horizontal plane as well as the vert.pdfWind Shear can be defined in the horizontal plane as well as the vert.pdf
Wind Shear can be defined in the horizontal plane as well as the vert.pdf
 
While hiking on some small islands in Lake Superior, you stumble acr.pdf
While hiking on some small islands in Lake Superior, you stumble acr.pdfWhile hiking on some small islands in Lake Superior, you stumble acr.pdf
While hiking on some small islands in Lake Superior, you stumble acr.pdf
 
Which phyla have megaphylls Bryophyta Monilophyta Coniferophyta .pdf
Which phyla have megaphylls  Bryophyta  Monilophyta  Coniferophyta  .pdfWhich phyla have megaphylls  Bryophyta  Monilophyta  Coniferophyta  .pdf
Which phyla have megaphylls Bryophyta Monilophyta Coniferophyta .pdf
 
Where do endocyotic vesicles come fromA. Plasma membranceB. Nuc.pdf
Where do endocyotic vesicles come fromA. Plasma membranceB. Nuc.pdfWhere do endocyotic vesicles come fromA. Plasma membranceB. Nuc.pdf
Where do endocyotic vesicles come fromA. Plasma membranceB. Nuc.pdf
 
When considering the AFN equation, we exclude notes payables from ou.pdf
When considering the AFN equation, we exclude notes payables from ou.pdfWhen considering the AFN equation, we exclude notes payables from ou.pdf
When considering the AFN equation, we exclude notes payables from ou.pdf
 

Recently uploaded

Plant propagation: Sexual and Asexual propapagation.pptx
Plant propagation: Sexual and Asexual propapagation.pptxPlant propagation: Sexual and Asexual propapagation.pptx
Plant propagation: Sexual and Asexual propapagation.pptxUmeshTimilsina1
 
NO1 Top Black Magic Specialist In Lahore Black magic In Pakistan Kala Ilam Ex...
NO1 Top Black Magic Specialist In Lahore Black magic In Pakistan Kala Ilam Ex...NO1 Top Black Magic Specialist In Lahore Black magic In Pakistan Kala Ilam Ex...
NO1 Top Black Magic Specialist In Lahore Black magic In Pakistan Kala Ilam Ex...Amil baba
 
How to setup Pycharm environment for Odoo 17.pptx
How to setup Pycharm environment for Odoo 17.pptxHow to setup Pycharm environment for Odoo 17.pptx
How to setup Pycharm environment for Odoo 17.pptxCeline George
 
This PowerPoint helps students to consider the concept of infinity.
This PowerPoint helps students to consider the concept of infinity.This PowerPoint helps students to consider the concept of infinity.
This PowerPoint helps students to consider the concept of infinity.christianmathematics
 
80 ĐỀ THI THỬ TUYỂN SINH TIẾNG ANH VÀO 10 SỞ GD – ĐT THÀNH PHỐ HỒ CHÍ MINH NĂ...
80 ĐỀ THI THỬ TUYỂN SINH TIẾNG ANH VÀO 10 SỞ GD – ĐT THÀNH PHỐ HỒ CHÍ MINH NĂ...80 ĐỀ THI THỬ TUYỂN SINH TIẾNG ANH VÀO 10 SỞ GD – ĐT THÀNH PHỐ HỒ CHÍ MINH NĂ...
80 ĐỀ THI THỬ TUYỂN SINH TIẾNG ANH VÀO 10 SỞ GD – ĐT THÀNH PHỐ HỒ CHÍ MINH NĂ...Nguyen Thanh Tu Collection
 
HMCS Vancouver Pre-Deployment Brief - May 2024 (Web Version).pptx
HMCS Vancouver Pre-Deployment Brief - May 2024 (Web Version).pptxHMCS Vancouver Pre-Deployment Brief - May 2024 (Web Version).pptx
HMCS Vancouver Pre-Deployment Brief - May 2024 (Web Version).pptxmarlenawright1
 
Fostering Friendships - Enhancing Social Bonds in the Classroom
Fostering Friendships - Enhancing Social Bonds  in the ClassroomFostering Friendships - Enhancing Social Bonds  in the Classroom
Fostering Friendships - Enhancing Social Bonds in the ClassroomPooky Knightsmith
 
Basic Civil Engineering first year Notes- Chapter 4 Building.pptx
Basic Civil Engineering first year Notes- Chapter 4 Building.pptxBasic Civil Engineering first year Notes- Chapter 4 Building.pptx
Basic Civil Engineering first year Notes- Chapter 4 Building.pptxDenish Jangid
 
Unit 3 Emotional Intelligence and Spiritual Intelligence.pdf
Unit 3 Emotional Intelligence and Spiritual Intelligence.pdfUnit 3 Emotional Intelligence and Spiritual Intelligence.pdf
Unit 3 Emotional Intelligence and Spiritual Intelligence.pdfDr Vijay Vishwakarma
 
Jamworks pilot and AI at Jisc (20/03/2024)
Jamworks pilot and AI at Jisc (20/03/2024)Jamworks pilot and AI at Jisc (20/03/2024)
Jamworks pilot and AI at Jisc (20/03/2024)Jisc
 
Holdier Curriculum Vitae (April 2024).pdf
Holdier Curriculum Vitae (April 2024).pdfHoldier Curriculum Vitae (April 2024).pdf
Holdier Curriculum Vitae (April 2024).pdfagholdier
 
On_Translating_a_Tamil_Poem_by_A_K_Ramanujan.pptx
On_Translating_a_Tamil_Poem_by_A_K_Ramanujan.pptxOn_Translating_a_Tamil_Poem_by_A_K_Ramanujan.pptx
On_Translating_a_Tamil_Poem_by_A_K_Ramanujan.pptxPooja Bhuva
 
Application orientated numerical on hev.ppt
Application orientated numerical on hev.pptApplication orientated numerical on hev.ppt
Application orientated numerical on hev.pptRamjanShidvankar
 
Food safety_Challenges food safety laboratories_.pdf
Food safety_Challenges food safety laboratories_.pdfFood safety_Challenges food safety laboratories_.pdf
Food safety_Challenges food safety laboratories_.pdfSherif Taha
 
Accessible Digital Futures project (20/03/2024)
Accessible Digital Futures project (20/03/2024)Accessible Digital Futures project (20/03/2024)
Accessible Digital Futures project (20/03/2024)Jisc
 
Salient Features of India constitution especially power and functions
Salient Features of India constitution especially power and functionsSalient Features of India constitution especially power and functions
Salient Features of India constitution especially power and functionsKarakKing
 
Google Gemini An AI Revolution in Education.pptx
Google Gemini An AI Revolution in Education.pptxGoogle Gemini An AI Revolution in Education.pptx
Google Gemini An AI Revolution in Education.pptxDr. Sarita Anand
 
The basics of sentences session 3pptx.pptx
The basics of sentences session 3pptx.pptxThe basics of sentences session 3pptx.pptx
The basics of sentences session 3pptx.pptxheathfieldcps1
 
Single or Multiple melodic lines structure
Single or Multiple melodic lines structureSingle or Multiple melodic lines structure
Single or Multiple melodic lines structuredhanjurrannsibayan2
 
Beyond_Borders_Understanding_Anime_and_Manga_Fandom_A_Comprehensive_Audience_...
Beyond_Borders_Understanding_Anime_and_Manga_Fandom_A_Comprehensive_Audience_...Beyond_Borders_Understanding_Anime_and_Manga_Fandom_A_Comprehensive_Audience_...
Beyond_Borders_Understanding_Anime_and_Manga_Fandom_A_Comprehensive_Audience_...Pooja Bhuva
 

Recently uploaded (20)

Plant propagation: Sexual and Asexual propapagation.pptx
Plant propagation: Sexual and Asexual propapagation.pptxPlant propagation: Sexual and Asexual propapagation.pptx
Plant propagation: Sexual and Asexual propapagation.pptx
 
NO1 Top Black Magic Specialist In Lahore Black magic In Pakistan Kala Ilam Ex...
NO1 Top Black Magic Specialist In Lahore Black magic In Pakistan Kala Ilam Ex...NO1 Top Black Magic Specialist In Lahore Black magic In Pakistan Kala Ilam Ex...
NO1 Top Black Magic Specialist In Lahore Black magic In Pakistan Kala Ilam Ex...
 
How to setup Pycharm environment for Odoo 17.pptx
How to setup Pycharm environment for Odoo 17.pptxHow to setup Pycharm environment for Odoo 17.pptx
How to setup Pycharm environment for Odoo 17.pptx
 
This PowerPoint helps students to consider the concept of infinity.
This PowerPoint helps students to consider the concept of infinity.This PowerPoint helps students to consider the concept of infinity.
This PowerPoint helps students to consider the concept of infinity.
 
80 ĐỀ THI THỬ TUYỂN SINH TIẾNG ANH VÀO 10 SỞ GD – ĐT THÀNH PHỐ HỒ CHÍ MINH NĂ...
80 ĐỀ THI THỬ TUYỂN SINH TIẾNG ANH VÀO 10 SỞ GD – ĐT THÀNH PHỐ HỒ CHÍ MINH NĂ...80 ĐỀ THI THỬ TUYỂN SINH TIẾNG ANH VÀO 10 SỞ GD – ĐT THÀNH PHỐ HỒ CHÍ MINH NĂ...
80 ĐỀ THI THỬ TUYỂN SINH TIẾNG ANH VÀO 10 SỞ GD – ĐT THÀNH PHỐ HỒ CHÍ MINH NĂ...
 
HMCS Vancouver Pre-Deployment Brief - May 2024 (Web Version).pptx
HMCS Vancouver Pre-Deployment Brief - May 2024 (Web Version).pptxHMCS Vancouver Pre-Deployment Brief - May 2024 (Web Version).pptx
HMCS Vancouver Pre-Deployment Brief - May 2024 (Web Version).pptx
 
Fostering Friendships - Enhancing Social Bonds in the Classroom
Fostering Friendships - Enhancing Social Bonds  in the ClassroomFostering Friendships - Enhancing Social Bonds  in the Classroom
Fostering Friendships - Enhancing Social Bonds in the Classroom
 
Basic Civil Engineering first year Notes- Chapter 4 Building.pptx
Basic Civil Engineering first year Notes- Chapter 4 Building.pptxBasic Civil Engineering first year Notes- Chapter 4 Building.pptx
Basic Civil Engineering first year Notes- Chapter 4 Building.pptx
 
Unit 3 Emotional Intelligence and Spiritual Intelligence.pdf
Unit 3 Emotional Intelligence and Spiritual Intelligence.pdfUnit 3 Emotional Intelligence and Spiritual Intelligence.pdf
Unit 3 Emotional Intelligence and Spiritual Intelligence.pdf
 
Jamworks pilot and AI at Jisc (20/03/2024)
Jamworks pilot and AI at Jisc (20/03/2024)Jamworks pilot and AI at Jisc (20/03/2024)
Jamworks pilot and AI at Jisc (20/03/2024)
 
Holdier Curriculum Vitae (April 2024).pdf
Holdier Curriculum Vitae (April 2024).pdfHoldier Curriculum Vitae (April 2024).pdf
Holdier Curriculum Vitae (April 2024).pdf
 
On_Translating_a_Tamil_Poem_by_A_K_Ramanujan.pptx
On_Translating_a_Tamil_Poem_by_A_K_Ramanujan.pptxOn_Translating_a_Tamil_Poem_by_A_K_Ramanujan.pptx
On_Translating_a_Tamil_Poem_by_A_K_Ramanujan.pptx
 
Application orientated numerical on hev.ppt
Application orientated numerical on hev.pptApplication orientated numerical on hev.ppt
Application orientated numerical on hev.ppt
 
Food safety_Challenges food safety laboratories_.pdf
Food safety_Challenges food safety laboratories_.pdfFood safety_Challenges food safety laboratories_.pdf
Food safety_Challenges food safety laboratories_.pdf
 
Accessible Digital Futures project (20/03/2024)
Accessible Digital Futures project (20/03/2024)Accessible Digital Futures project (20/03/2024)
Accessible Digital Futures project (20/03/2024)
 
Salient Features of India constitution especially power and functions
Salient Features of India constitution especially power and functionsSalient Features of India constitution especially power and functions
Salient Features of India constitution especially power and functions
 
Google Gemini An AI Revolution in Education.pptx
Google Gemini An AI Revolution in Education.pptxGoogle Gemini An AI Revolution in Education.pptx
Google Gemini An AI Revolution in Education.pptx
 
The basics of sentences session 3pptx.pptx
The basics of sentences session 3pptx.pptxThe basics of sentences session 3pptx.pptx
The basics of sentences session 3pptx.pptx
 
Single or Multiple melodic lines structure
Single or Multiple melodic lines structureSingle or Multiple melodic lines structure
Single or Multiple melodic lines structure
 
Beyond_Borders_Understanding_Anime_and_Manga_Fandom_A_Comprehensive_Audience_...
Beyond_Borders_Understanding_Anime_and_Manga_Fandom_A_Comprehensive_Audience_...Beyond_Borders_Understanding_Anime_and_Manga_Fandom_A_Comprehensive_Audience_...
Beyond_Borders_Understanding_Anime_and_Manga_Fandom_A_Comprehensive_Audience_...
 

Help with implementing the four function the first is an exampleth.pdf

  • 1. Help with implementing the four function the first is an example thanks def inorder(T,f): if not is_bst(T): return if not T: return inorder(T[1],f) f(T[0]) inorder(T[2],f) # programming project: provide implementations for the functions below # and add tests for these functions to the code in the block # that starts "if __name__ == '__main__'" def preorder(T,f): pass def postorder(T,f): pass def tree_height(T): pass def balance(T): # returns the height of the left subtree of T # minus the height of the right subtree of T pass Solution class Node: def _init_(self,val): self.value=val self.leftChild=None self.rightChild=None def preorder(self): if self: print(str(self.value))
  • 2. if self.leftChild: self.leftChild. preorder() if self.rightChild: self. rightChild. preorder() def postorder(self): if self: if self.leftChild: self.leftChild. postorder () if self.rightChild: self. rightChild. postorder () print(str(self.value)) def inorder(self): if self: if self.leftChild: self.leftChild. inorder () print(str(self.value)) if self.rightChild: self. rightChild. inorder () def height(self,root): if root is None: reture 0 else: return max(self.height(root.left),self.height(root.right))+1 det balance(self,root): if root is None: return 0 else: leftHeight= height(root.left) rightHeight= height(root.right) if leftHeight- rightHeight<=1 : return 1 else: return 0 class Tree: def _init_(self): self.root=None
  • 3. def preorder(self): print(“Preorder)” self.root.preorder() def postorder(self): print(“Postorder)” self.root. postorder () def inorder(self): print(“Inorder)” self.root. inorder () bst=Tree() bst.preorder() bst.postorder() bst.inorder() print("Height of tree is " (height (bst))) if (balance(bst): print (“Tree is balance”) else print (“Tree is not balance”)