SlideShare a Scribd company logo
1 of 1
Download to read offline
Solution
:
Traversing Binary Trees
The preorder standard procedures to traverse a binary tree are defined recursively as follows:
preorder(T):if T then visit root(T); preorder(left(T)); preorder(right(T))
preorder( ) =
preorder(tree(root, Left, Right)) = cat(root,preorder(Left), cat(preorder(Right)))
where cat concatenates two lists and can be defined by,
cat(,L) =L
cat(h ::t, L) = h :: cat(t, L).

More Related Content

More from sudhirchourasia86

  package Chapter_20;import ToolKit.PostfixNotation;import javaf.pdf
  package Chapter_20;import ToolKit.PostfixNotation;import javaf.pdf  package Chapter_20;import ToolKit.PostfixNotation;import javaf.pdf
  package Chapter_20;import ToolKit.PostfixNotation;import javaf.pdf
sudhirchourasia86
 
There are ten guidelines with a broad coverage, ranging from develop.pdf
There are ten guidelines with a broad coverage, ranging from develop.pdfThere are ten guidelines with a broad coverage, ranging from develop.pdf
There are ten guidelines with a broad coverage, ranging from develop.pdf
sudhirchourasia86
 
The way Ive been told to look at the classifications is to look at.pdf
The way Ive been told to look at the classifications is to look at.pdfThe way Ive been told to look at the classifications is to look at.pdf
The way Ive been told to look at the classifications is to look at.pdf
sudhirchourasia86
 
Ques-1Chlamydia trichomatis has small G shaped intracellular bact.pdf
Ques-1Chlamydia trichomatis has small G shaped intracellular bact.pdfQues-1Chlamydia trichomatis has small G shaped intracellular bact.pdf
Ques-1Chlamydia trichomatis has small G shaped intracellular bact.pdf
sudhirchourasia86
 
package net.codejava.swing.mail;import java.awt.Font;import java.pdf
package net.codejava.swing.mail;import java.awt.Font;import java.pdfpackage net.codejava.swing.mail;import java.awt.Font;import java.pdf
package net.codejava.swing.mail;import java.awt.Font;import java.pdf
sudhirchourasia86
 
Maryland’s State Finance & Procurement Article §14-410 defines envir.pdf
Maryland’s State Finance & Procurement Article §14-410 defines envir.pdfMaryland’s State Finance & Procurement Article §14-410 defines envir.pdf
Maryland’s State Finance & Procurement Article §14-410 defines envir.pdf
sudhirchourasia86
 
Habitat,Feeding,Mobilityfresh water habitatNitrogen fixation.pdf
Habitat,Feeding,Mobilityfresh water habitatNitrogen fixation.pdfHabitat,Feeding,Mobilityfresh water habitatNitrogen fixation.pdf
Habitat,Feeding,Mobilityfresh water habitatNitrogen fixation.pdf
sudhirchourasia86
 

More from sudhirchourasia86 (20)

Ionic Equation is MgO(s) + 2 H+(aq) + 2NO3- (aq.pdf
                     Ionic Equation is   MgO(s) + 2 H+(aq) + 2NO3- (aq.pdf                     Ionic Equation is   MgO(s) + 2 H+(aq) + 2NO3- (aq.pdf
Ionic Equation is MgO(s) + 2 H+(aq) + 2NO3- (aq.pdf
 
FeBrs is a typo Lets suppose it is FeBr2. 2Na .pdf
                     FeBrs is a typo Lets suppose it is FeBr2. 2Na .pdf                     FeBrs is a typo Lets suppose it is FeBr2. 2Na .pdf
FeBrs is a typo Lets suppose it is FeBr2. 2Na .pdf
 
Density increases .pdf
                     Density increases                                .pdf                     Density increases                                .pdf
Density increases .pdf
 
d) in real gases there are attraction between m.pdf
                     d)   in real gases there are attraction between m.pdf                     d)   in real gases there are attraction between m.pdf
d) in real gases there are attraction between m.pdf
 
Shareholder’s equity= Current assets+Net fixed assets-Current lia.pdf
Shareholder’s equity= Current assets+Net fixed assets-Current lia.pdfShareholder’s equity= Current assets+Net fixed assets-Current lia.pdf
Shareholder’s equity= Current assets+Net fixed assets-Current lia.pdf
 
in Reproductive cloning of mammals the Nucelus ( Genetic material) f.pdf
in Reproductive cloning of mammals the Nucelus ( Genetic material) f.pdfin Reproductive cloning of mammals the Nucelus ( Genetic material) f.pdf
in Reproductive cloning of mammals the Nucelus ( Genetic material) f.pdf
 
   a) OH- (aq) is a Lewis base because it can give electrions to Oth.pdf
   a) OH- (aq) is a Lewis base because it can give electrions to Oth.pdf   a) OH- (aq) is a Lewis base because it can give electrions to Oth.pdf
   a) OH- (aq) is a Lewis base because it can give electrions to Oth.pdf
 
  package Chapter_20;import ToolKit.PostfixNotation;import javaf.pdf
  package Chapter_20;import ToolKit.PostfixNotation;import javaf.pdf  package Chapter_20;import ToolKit.PostfixNotation;import javaf.pdf
  package Chapter_20;import ToolKit.PostfixNotation;import javaf.pdf
 
Initial concentration of NH3 = molesvolume = 0.2501.00 = 0.250 M.pdf
Initial concentration of NH3 = molesvolume = 0.2501.00 = 0.250 M.pdfInitial concentration of NH3 = molesvolume = 0.2501.00 = 0.250 M.pdf
Initial concentration of NH3 = molesvolume = 0.2501.00 = 0.250 M.pdf
 
There are ten guidelines with a broad coverage, ranging from develop.pdf
There are ten guidelines with a broad coverage, ranging from develop.pdfThere are ten guidelines with a broad coverage, ranging from develop.pdf
There are ten guidelines with a broad coverage, ranging from develop.pdf
 
The way Ive been told to look at the classifications is to look at.pdf
The way Ive been told to look at the classifications is to look at.pdfThe way Ive been told to look at the classifications is to look at.pdf
The way Ive been told to look at the classifications is to look at.pdf
 
The enthalpy change of reaction = E(bonds broken) - E(bonds formed).pdf
The enthalpy change of reaction = E(bonds broken) - E(bonds formed).pdfThe enthalpy change of reaction = E(bonds broken) - E(bonds formed).pdf
The enthalpy change of reaction = E(bonds broken) - E(bonds formed).pdf
 
tanx =1x = tan^-1(1) = pi4 for 0x 90sinx = 1sqrt2 ; cosx = 1.pdf
tanx =1x = tan^-1(1) = pi4 for 0x 90sinx = 1sqrt2 ; cosx = 1.pdftanx =1x = tan^-1(1) = pi4 for 0x 90sinx = 1sqrt2 ; cosx = 1.pdf
tanx =1x = tan^-1(1) = pi4 for 0x 90sinx = 1sqrt2 ; cosx = 1.pdf
 
The answer is b. decreasesSolids have lower entropy than gases.pdf
The answer is b. decreasesSolids have lower entropy than gases.pdfThe answer is b. decreasesSolids have lower entropy than gases.pdf
The answer is b. decreasesSolids have lower entropy than gases.pdf
 
Ques-1Chlamydia trichomatis has small G shaped intracellular bact.pdf
Ques-1Chlamydia trichomatis has small G shaped intracellular bact.pdfQues-1Chlamydia trichomatis has small G shaped intracellular bact.pdf
Ques-1Chlamydia trichomatis has small G shaped intracellular bact.pdf
 
package net.codejava.swing.mail;import java.awt.Font;import java.pdf
package net.codejava.swing.mail;import java.awt.Font;import java.pdfpackage net.codejava.swing.mail;import java.awt.Font;import java.pdf
package net.codejava.swing.mail;import java.awt.Font;import java.pdf
 
No. The Oxygens on both sides of the Iodine cancel out, so the mol.pdf
No. The Oxygens on both sides of the Iodine cancel out, so the mol.pdfNo. The Oxygens on both sides of the Iodine cancel out, so the mol.pdf
No. The Oxygens on both sides of the Iodine cancel out, so the mol.pdf
 
NameTest.java import java.util.Scanner;public class NameTest {.pdf
NameTest.java import java.util.Scanner;public class NameTest {.pdfNameTest.java import java.util.Scanner;public class NameTest {.pdf
NameTest.java import java.util.Scanner;public class NameTest {.pdf
 
Maryland’s State Finance & Procurement Article §14-410 defines envir.pdf
Maryland’s State Finance & Procurement Article §14-410 defines envir.pdfMaryland’s State Finance & Procurement Article §14-410 defines envir.pdf
Maryland’s State Finance & Procurement Article §14-410 defines envir.pdf
 
Habitat,Feeding,Mobilityfresh water habitatNitrogen fixation.pdf
Habitat,Feeding,Mobilityfresh water habitatNitrogen fixation.pdfHabitat,Feeding,Mobilityfresh water habitatNitrogen fixation.pdf
Habitat,Feeding,Mobilityfresh water habitatNitrogen fixation.pdf
 

Recently uploaded

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
heathfieldcps1
 
Call Girls in Uttam Nagar (delhi) call me [🔝9953056974🔝] escort service 24X7
Call Girls in  Uttam Nagar (delhi) call me [🔝9953056974🔝] escort service 24X7Call Girls in  Uttam Nagar (delhi) call me [🔝9953056974🔝] escort service 24X7
Call Girls in Uttam Nagar (delhi) call me [🔝9953056974🔝] escort service 24X7
9953056974 Low Rate Call Girls In Saket, Delhi NCR
 

Recently uploaded (20)

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Ă...
 
REMIFENTANIL: An Ultra short acting opioid.pptx
REMIFENTANIL: An Ultra short acting opioid.pptxREMIFENTANIL: An Ultra short acting opioid.pptx
REMIFENTANIL: An Ultra short acting opioid.pptx
 
Understanding Accommodations and Modifications
Understanding  Accommodations and ModificationsUnderstanding  Accommodations and Modifications
Understanding Accommodations and Modifications
 
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
 
OSCM Unit 2_Operations Processes & Systems
OSCM Unit 2_Operations Processes & SystemsOSCM Unit 2_Operations Processes & Systems
OSCM Unit 2_Operations Processes & Systems
 
How to Add a Tool Tip to a Field in Odoo 17
How to Add a Tool Tip to a Field in Odoo 17How to Add a Tool Tip to a Field in Odoo 17
How to Add a Tool Tip to a Field in Odoo 17
 
FSB Advising Checklist - Orientation 2024
FSB Advising Checklist - Orientation 2024FSB Advising Checklist - Orientation 2024
FSB Advising Checklist - Orientation 2024
 
Details on CBSE Compartment Exam.pptx1111
Details on CBSE Compartment Exam.pptx1111Details on CBSE Compartment Exam.pptx1111
Details on CBSE Compartment Exam.pptx1111
 
Exploring_the_Narrative_Style_of_Amitav_Ghoshs_Gun_Island.pptx
Exploring_the_Narrative_Style_of_Amitav_Ghoshs_Gun_Island.pptxExploring_the_Narrative_Style_of_Amitav_Ghoshs_Gun_Island.pptx
Exploring_the_Narrative_Style_of_Amitav_Ghoshs_Gun_Island.pptx
 
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
 
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...
 
Call Girls in Uttam Nagar (delhi) call me [🔝9953056974🔝] escort service 24X7
Call Girls in  Uttam Nagar (delhi) call me [🔝9953056974🔝] escort service 24X7Call Girls in  Uttam Nagar (delhi) call me [🔝9953056974🔝] escort service 24X7
Call Girls in Uttam Nagar (delhi) call me [🔝9953056974🔝] escort service 24X7
 
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
 
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)
 
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
 
How to Add New Custom Addons Path in Odoo 17
How to Add New Custom Addons Path in Odoo 17How to Add New Custom Addons Path in Odoo 17
How to Add New Custom Addons Path in Odoo 17
 
Python Notes for mca i year students osmania university.docx
Python Notes for mca i year students osmania university.docxPython Notes for mca i year students osmania university.docx
Python Notes for mca i year students osmania university.docx
 
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)
 
latest AZ-104 Exam Questions and Answers
latest AZ-104 Exam Questions and Answerslatest AZ-104 Exam Questions and Answers
latest AZ-104 Exam Questions and Answers
 
General Principles of Intellectual Property: Concepts of Intellectual Proper...
General Principles of Intellectual Property: Concepts of Intellectual  Proper...General Principles of Intellectual Property: Concepts of Intellectual  Proper...
General Principles of Intellectual Property: Concepts of Intellectual Proper...
 

SolutionTraversing Binary Trees The preorder standard procedure.pdf

  • 1. Solution : Traversing Binary Trees The preorder standard procedures to traverse a binary tree are defined recursively as follows: preorder(T):if T then visit root(T); preorder(left(T)); preorder(right(T)) preorder( ) = preorder(tree(root, Left, Right)) = cat(root,preorder(Left), cat(preorder(Right))) where cat concatenates two lists and can be defined by, cat(,L) =L cat(h ::t, L) = h :: cat(t, L).