SlideShare a Scribd company logo
1 of 9
Download to read offline
C++ BinaryTree Help : Creating main function for Trees...
Here are the header files :
PrintExpressionTour.H:
#ifndef _PRINTEXPRESSIONTOUR_H_
#define _PRINTEXPRESSIONTOUR_H_
#include "EulerTour.h"
#include
template
class PrintExpressionTour : public EulerTour {
protected: // ...same type name shortcuts as in EvaluateExpressionTour
public:
inline void execute( const BinaryTree& T ) { // execute the tour
initialize( T );
std::cout << "Expression: "; eulerTour( T.root() ); std::cout << std::endl;
}
protected: // leaf: print value
virtual void visitExternal( const Position& p, Result& r ) const {
std::cout << *p;
}
// left: open new expression
virtual void visitLeft( const Position& p, Result& r ) const {
std::cout << "(";
}
// below: print operator
virtual void visitBelow( const Position& p, Result& r ) const {
std::cout << *p;
}
// right: close expression
virtual void visitRight( const BinaryTree::Position& p, Result& r ) const {
std::cout << ")";
}
};
#endif // _PRINTEXPRESSIONTOUR_H_
BinaryTree.h:
#ifndef _BINARYTREE_H_
#define _BINARYTREE_H_
#include
#include
typedef std::string Elem; // base element type
class BinaryTree {
protected:
struct Node { // a node of the tree
Elem elt; // element value
Node* par; // parent
Node* left; // left child
Node* right; // right child
Node() : elt(), par( NULL ), left( NULL ), right( NULL ) {} // constructor
};
public:
class Position { // position in the tree
private:
Node* v; // pointer to the node
public:
Position( Node* _v = NULL ) : v( _v ) {} // constructor
Elem& operator*() const // get element
{
return v->elt;
}
Position left() const // get left child
{
return Position( v->left );
}
Position right() const // get right child
{
return Position( v->right );
}
Position parent() const // get parent
{
return Position( v->par );
}
bool isRoot() const // root of the tree?
{
return v->par == NULL;
}
bool isExternal() const // an external node?
{
return v->left == NULL && v->right == NULL;
}
friend class BinaryTree; // give tree access
};
typedef std::list PositionList; // list of positions
public:
BinaryTree(); // constructor
int size() const; // number of nodes
bool empty() const; // is tree empty?
Position root() const; // get the root
PositionList positions() const; // list of nodes
void addRoot(); // add root to empty tree
void expandExternal( const Position& p ); // expand external node
Position removeAboveExternal( const Position& p ); // remove p and parent
// housekeeping functions omitted...
protected: // local utilities
void preorder( Node* v, PositionList& pl ) const; // preorder utility
private:
Node* _root; // pointer to the root
int n; // number of nodes
};
#endif // _BINARYTREE_H_
EulerTour.h:
#ifndef _EULERTOUR_H_
#define _EULERTOUR_H_
#include "BinaryTree.h"
template // element and result types
class EulerTour { // a template for Euler tour
protected:
struct Result { // stores tour results
R leftResult; // result from left subtree
R rightResult; // result from right subtree
R finalResult; // combined result
};
//typedef BinaryTree BinaryTree; // the tree
typedef typename BinaryTree::Position Position; // a position in the tree
protected: // data member
const BinaryTree* tree; // pointer to the tree
public:
void initialize( const BinaryTree& T ) // initialize
{
tree = &T;
}
protected: // local utilities
R eulerTour( const Position& p ) const {
Result r = initResult();
if ( p.isExternal() ) { // external node
visitExternal( p, r );
} else { // internal node
visitLeft( p, r );
r.leftResult = eulerTour( p.left() ); // recurse on left
visitBelow( p, r );
r.rightResult = eulerTour( p.right() ); // recurse on right
visitRight( p, r );
}
return result( r );
} // perform the Euler tour who will implement this?
// functions given by subclasses
virtual void visitExternal( const Position& p, Result& r ) const {}
virtual void visitLeft( const Position& p, Result& r ) const {}
virtual void visitBelow( const Position& p, Result& r ) const {}
virtual void visitRight( const Position& p, Result& r ) const {}
Result initResult() const {
return Result();
}
R result( const Result& r ) const {
return r.finalResult;
}
};
#endif
BinaryTree.cpp:
#include "BinaryTree.h"
void BinaryTree::expandExternal( const Position& p ) {
Node* v = p.v; // p's node
v->left = new Node; // add a new left child
v->left->par = v; // v is its parent
v->right = new Node; // and a new right child
v->right->par = v; // v is its parent
n += 2; // two more nodes
}
BinaryTree::PositionList BinaryTree::positions() const {
PositionList pl;
preorder( _root, pl ); // preorder traversal
return PositionList( pl ); // return resulting list
}
// preorder traversal
void BinaryTree::preorder( Node* v, PositionList& pl ) const {
pl.push_back( Position( v ) ); // add this node
if ( v->left != NULL ) // traverse left subtree
preorder( v->left, pl );
if ( v->right != NULL ) // traverse right subtree
preorder( v->right, pl );
}
BinaryTree::BinaryTree() // constructor
: _root( NULL ), n( 0 ) {}
int BinaryTree::size() const // number of nodes
{
return n;
}
bool BinaryTree::empty() const // is tree empty?
{
return size() == 0;
}
BinaryTree::Position BinaryTree::root() const // get the root
{
return Position( _root );
}
void BinaryTree::addRoot() // add root to empty tree
{
_root = new Node; n = 1;
}
I need to make another "main.cpp" for this BinaryTree:
I have started with the following:
#include
#include
#include "BinaryTree.h"
#include "PrintExpressionTour.h"
int main()
{
// What goes inside here by looking at the Tree Picture?
system( "pause" );
return EXIT_SUCCESS;
}
Help Anyone Please? Thank you // 4 7 3 2 5 9 3 3
Solution
Sequence Alignment or sequence comparison lies in spite of appearance of the bioinformatics,
that describes the approach of arrangement of DNA/RNA or macromolecule sequences, so as to
spot the regions of similarity among them. it's wont to infer structural, useful and biological
process relationship between the sequences. Alignment finds similarity level between question
sequence and completely different info sequences. The algorithmic program works by dynamic
programming approach that divides the matter into smaller freelance sub issues. It finds the
alignment a lot of quantitatively by assignment scores.
When a replacement sequence is found, the structure and performance will be simply expected
by doing sequence alignment. Since it's believed that, a sequence sharing common ascendent
would exhibit similar structure or perform. bigger the sequence similarity, bigger is that the
likelihood that they share similar structure or perform.
Methods of Sequence Alignment:
There square measure primarily 2 strategies of Sequence Alignment:
Global Alignment : Closely connected sequences that square measure of same length square
measure much applicable for international alignment. Here, the alignment is dole out from
starting until finish of the sequence to search out out the simplest potential alignment.
The Needleman-Wunsch algorithmic program (A formula or set of steps to unravel a problem)
was developed by Saul B. Needleman and Christian D. Wunsch in 1970, that could be a dynamic
programming algorithmic program for sequence alignment. The dynamic programming solves
the initial drawback by dividing the matter into smaller freelance sub issues. These techniques
square measure utilized in many various aspects of engineering science. The algorithmic
program explains international sequence alignment for positioning ester or macromolecule
sequences.
Local Alignment : Sequences that square measure suspected to possess similarity or perhaps
dissimilar sequences will be compared with native alignment technique. It finds native regions
with high level of similarity.
These 2 strategies of alignments square measure outlined by completely different algorithms,
that use grading matrices to align the 2 completely different series of characters or patterns
(sequences). {the 2|the 2} {different|totally completely different|completely different} alignment
strategies square measure largely outlined by Dynamic programming approach for positioning
two different sequences.
Dynamic Programming:
Dynamic programming is employed for optimum alignment of 2 sequences. It finds the
alignment in an exceedingly a lot of quantitative approach by giving some scores for matches
and mismatches (Scoring matrices), instead of solely applying dots. By looking out the best
scores within the matrix, alignment will be accurately obtained. The Dynamic Programming
solves the initial drawback by dividing the matter into smaller freelance sub issues. These
techniques square measure utilized in many various aspects of engineering science. Needleman-
Wunsch and Smith-Waterman algorithms for sequence alignment square measure outlined by
dynamic programming approach.
Scoring matrices:
In optimum alignment procedures, largely Needleman-Wunsch and Smith-Waterman algorithms
use classification system. For ester sequence alignment, the grading matrices used square
measure comparatively less complicated since the frequency of mutation for all the bases square
measure equal. Positive or higher price is appointed for a match and a negative or a lower price
is appointed for pair. These assumption based mostly scores will be used for grading the
matrices. There square measure different grading matrices that square measure predefined
largely, utilized in the case of organic compound substitutions.
Mainly used predefined matrices square measure PAM and BLOSUM.
PAM Matrices: Margaret Dayhoff was the primary one to develop the PAM matrix, PAM stands
for purpose Accepted Mutations. PAM matrices square measure calculated by perceptive the
variations in closely connected proteins. One PAM unit (PAM1) specifies one accepted gene
mutation per a hundred organic compound residues, i.e. one hundred and twenty fifth
amendment and ninety nine remains in and of itself.
BLOSUM: BLOcks SUbstitution Matrix, developed by Henikoff and Henikoff in 1992, used
preserved regions. These matrices square measure actual proportion identity values. merely to
mention, they depend upon similarity. Blosum sixty two suggests that there's sixty two Gestalt
law of organization.
Gap score or gap penalty: Dynamic programming algorithms use gap penalties to maximise the
biological that means. Gap penalty is subtracted for every gap that has been introduced. There
square measure completely different gap penalties like gap open and gap extension. The gap
score defines a penalty given to alignment after we have insertion or deletion. throughout the
evolution, there is also a case wherever we are able to see continuous gaps right along the
sequence, that the linear gap penalty wouldn't be applicable for the alignment. therefore gap
open and gap extension has been introduced once there square measure continuous gaps (five or
more). The open penalty is often applied at the beginning of the gap, so the opposite gaps
following it's given with a niche extension penalty which is able to be less compared to the open
penalty. Typical values square measure –12 for gap gap, and –4 for gap extension.
Working of Needleman -Wunsch algorithmic program
To study the algorithmic program, take into account the 2 given sequences.
CGTGAATTCAT (sequence #1) , GACTTAC (sequence #2)
The length (count of the nucleotides or amino acids) of the sequence one and sequence a pair of
square measure eleven and seven severally. The initial matrix is made with A+1 column’s and
B+1 row’s (where A and B corresponds to length of the sequences). additional row and column
is given, therefore on align with gap, at the beginning of the matrix as shown in Figure one.
Figure 1: Initial matrix
After making the initial matrix, grading schema should be introduced which might be user
outlined with specific scores. the straightforward basic grading schema will be assumed as, if 2
residues (nucleotide or amino acid) at ith and jth position square measure same, matching score
is one (S(i,j)= 1) or if the 2 residues at ith and jth position don't seem to be same, pair score is
assumed as -1 (S(i,j)= -1 ). The gap score(w) or gap penalty is assumed as -1 .
*Note: The a lot of match, pair and gap will be user outlined, provided the gap penalty ought to
be negative or zero.
Gap score is outlined as penalty given to alignment, after we have insertion or deletion.
The dynamic programming matrix is outlined with 3 completely different steps.
1.Initialization of the matrix with the scores potential.
2.Matrix filling with most scores.
3.Trace back the residues for applicable alignment.

More Related Content

Similar to C++ BinaryTree Help Creating main function for Trees...Here are .pdf

Need Help with this Java Assignment. Program should be done in JAVA .pdf
Need Help with this Java Assignment. Program should be done in JAVA .pdfNeed Help with this Java Assignment. Program should be done in JAVA .pdf
Need Help with this Java Assignment. Program should be done in JAVA .pdf
archiesgallery
 
Please i need help on following program using C++ Language.Add the.pdf
Please i need help on following program using C++ Language.Add the.pdfPlease i need help on following program using C++ Language.Add the.pdf
Please i need help on following program using C++ Language.Add the.pdf
ezzi552
 
Using an Array include ltstdiohgt include ltmpih.pdf
Using an Array include ltstdiohgt include ltmpih.pdfUsing an Array include ltstdiohgt include ltmpih.pdf
Using an Array include ltstdiohgt include ltmpih.pdf
giriraj65
 
in this assignment you are asked to write a simple driver program an.pdf
in this assignment you are asked to write a simple driver program an.pdfin this assignment you are asked to write a simple driver program an.pdf
in this assignment you are asked to write a simple driver program an.pdf
michardsonkhaicarr37
 
Functions And Header Files In C++ | Bjarne stroustrup
Functions And Header Files In C++ | Bjarne stroustrupFunctions And Header Files In C++ | Bjarne stroustrup
Functions And Header Files In C++ | Bjarne stroustrup
SyedHaroonShah4
 
Creat Shape classes from scratch DETAILS You will create 3 shape cla.pdf
Creat Shape classes from scratch DETAILS You will create 3 shape cla.pdfCreat Shape classes from scratch DETAILS You will create 3 shape cla.pdf
Creat Shape classes from scratch DETAILS You will create 3 shape cla.pdf
aromanets
 
C programming. Answer question only in C code Ninth Deletion with B.pdf
C programming. Answer question only in C code Ninth Deletion with B.pdfC programming. Answer question only in C code Ninth Deletion with B.pdf
C programming. Answer question only in C code Ninth Deletion with B.pdf
info309708
 
Templated Binary Tree implementing function help I need to im.pdf
Templated Binary Tree implementing function help I need to im.pdfTemplated Binary Tree implementing function help I need to im.pdf
Templated Binary Tree implementing function help I need to im.pdf
manjan6
 
a) Complete both insert and delete methods. If it works correctly 10.pdf
a) Complete both insert and delete methods. If it works correctly 10.pdfa) Complete both insert and delete methods. If it works correctly 10.pdf
a) Complete both insert and delete methods. If it works correctly 10.pdf
MAYANKBANSAL1981
 
Modify your solution for PLP04 to allow the user to choose the shape.pdf
Modify your solution for PLP04 to allow the user to choose the shape.pdfModify your solution for PLP04 to allow the user to choose the shape.pdf
Modify your solution for PLP04 to allow the user to choose the shape.pdf
hullibergerr25980
 
Modify HuffmanTree.java and HuffmanNode.java to allow the user to se.pdf
Modify HuffmanTree.java and HuffmanNode.java to allow the user to se.pdfModify HuffmanTree.java and HuffmanNode.java to allow the user to se.pdf
Modify HuffmanTree.java and HuffmanNode.java to allow the user to se.pdf
arjuncorner565
 
maincpp Build and procees a sorted linked list of Patie.pdf
maincpp   Build and procees a sorted linked list of Patie.pdfmaincpp   Build and procees a sorted linked list of Patie.pdf
maincpp Build and procees a sorted linked list of Patie.pdf
adityastores21
 
C++: Constructor, Copy Constructor and Assignment operator
C++: Constructor, Copy Constructor and Assignment operatorC++: Constructor, Copy Constructor and Assignment operator
C++: Constructor, Copy Constructor and Assignment operator
Jussi Pohjolainen
 

Similar to C++ BinaryTree Help Creating main function for Trees...Here are .pdf (20)

Need Help with this Java Assignment. Program should be done in JAVA .pdf
Need Help with this Java Assignment. Program should be done in JAVA .pdfNeed Help with this Java Assignment. Program should be done in JAVA .pdf
Need Help with this Java Assignment. Program should be done in JAVA .pdf
 
Please i need help on following program using C++ Language.Add the.pdf
Please i need help on following program using C++ Language.Add the.pdfPlease i need help on following program using C++ Language.Add the.pdf
Please i need help on following program using C++ Language.Add the.pdf
 
Using an Array include ltstdiohgt include ltmpih.pdf
Using an Array include ltstdiohgt include ltmpih.pdfUsing an Array include ltstdiohgt include ltmpih.pdf
Using an Array include ltstdiohgt include ltmpih.pdf
 
in this assignment you are asked to write a simple driver program an.pdf
in this assignment you are asked to write a simple driver program an.pdfin this assignment you are asked to write a simple driver program an.pdf
in this assignment you are asked to write a simple driver program an.pdf
 
Functions And Header Files In C++ | Bjarne stroustrup
Functions And Header Files In C++ | Bjarne stroustrupFunctions And Header Files In C++ | Bjarne stroustrup
Functions And Header Files In C++ | Bjarne stroustrup
 
Creat Shape classes from scratch DETAILS You will create 3 shape cla.pdf
Creat Shape classes from scratch DETAILS You will create 3 shape cla.pdfCreat Shape classes from scratch DETAILS You will create 3 shape cla.pdf
Creat Shape classes from scratch DETAILS You will create 3 shape cla.pdf
 
C programming. Answer question only in C code Ninth Deletion with B.pdf
C programming. Answer question only in C code Ninth Deletion with B.pdfC programming. Answer question only in C code Ninth Deletion with B.pdf
C programming. Answer question only in C code Ninth Deletion with B.pdf
 
Templated Binary Tree implementing function help I need to im.pdf
Templated Binary Tree implementing function help I need to im.pdfTemplated Binary Tree implementing function help I need to im.pdf
Templated Binary Tree implementing function help I need to im.pdf
 
a) Complete both insert and delete methods. If it works correctly 10.pdf
a) Complete both insert and delete methods. If it works correctly 10.pdfa) Complete both insert and delete methods. If it works correctly 10.pdf
a) Complete both insert and delete methods. If it works correctly 10.pdf
 
Java Class Design
Java Class DesignJava Class Design
Java Class Design
 
Gabriele Petronella - FP for front-end development: should you care? - Codemo...
Gabriele Petronella - FP for front-end development: should you care? - Codemo...Gabriele Petronella - FP for front-end development: should you care? - Codemo...
Gabriele Petronella - FP for front-end development: should you care? - Codemo...
 
9. DBMS Experiment Laboratory PresentationPPT
9. DBMS Experiment Laboratory PresentationPPT9. DBMS Experiment Laboratory PresentationPPT
9. DBMS Experiment Laboratory PresentationPPT
 
Modify your solution for PLP04 to allow the user to choose the shape.pdf
Modify your solution for PLP04 to allow the user to choose the shape.pdfModify your solution for PLP04 to allow the user to choose the shape.pdf
Modify your solution for PLP04 to allow the user to choose the shape.pdf
 
Go Programming Language (Golang)
Go Programming Language (Golang)Go Programming Language (Golang)
Go Programming Language (Golang)
 
Mixing functional and object oriented approaches to programming in C#
Mixing functional and object oriented approaches to programming in C#Mixing functional and object oriented approaches to programming in C#
Mixing functional and object oriented approaches to programming in C#
 
Modify HuffmanTree.java and HuffmanNode.java to allow the user to se.pdf
Modify HuffmanTree.java and HuffmanNode.java to allow the user to se.pdfModify HuffmanTree.java and HuffmanNode.java to allow the user to se.pdf
Modify HuffmanTree.java and HuffmanNode.java to allow the user to se.pdf
 
7 functions
7  functions7  functions
7 functions
 
Functional Programming You Already Know
Functional Programming You Already KnowFunctional Programming You Already Know
Functional Programming You Already Know
 
maincpp Build and procees a sorted linked list of Patie.pdf
maincpp   Build and procees a sorted linked list of Patie.pdfmaincpp   Build and procees a sorted linked list of Patie.pdf
maincpp Build and procees a sorted linked list of Patie.pdf
 
C++: Constructor, Copy Constructor and Assignment operator
C++: Constructor, Copy Constructor and Assignment operatorC++: Constructor, Copy Constructor and Assignment operator
C++: Constructor, Copy Constructor and Assignment operator
 

More from forecastfashions

Did BP respond to the oil spill in a manner that was appropriate to .pdf
Did BP respond to the oil spill in a manner that was appropriate to .pdfDid BP respond to the oil spill in a manner that was appropriate to .pdf
Did BP respond to the oil spill in a manner that was appropriate to .pdf
forecastfashions
 
Assignment Description When dealing with a performance improvement .pdf
Assignment Description When dealing with a performance improvement .pdfAssignment Description When dealing with a performance improvement .pdf
Assignment Description When dealing with a performance improvement .pdf
forecastfashions
 
What are rubisco and RuBP And what do they do Briefly list 4 simil.pdf
What are rubisco and RuBP And what do they do  Briefly list 4 simil.pdfWhat are rubisco and RuBP And what do they do  Briefly list 4 simil.pdf
What are rubisco and RuBP And what do they do Briefly list 4 simil.pdf
forecastfashions
 
Virtual Machines Discuss what are the new innovation today in this .pdf
Virtual Machines Discuss what are the new innovation today in this .pdfVirtual Machines Discuss what are the new innovation today in this .pdf
Virtual Machines Discuss what are the new innovation today in this .pdf
forecastfashions
 
Using Java, please write the program for the following prompt in the.pdf
Using Java, please write the program for the following prompt in the.pdfUsing Java, please write the program for the following prompt in the.pdf
Using Java, please write the program for the following prompt in the.pdf
forecastfashions
 

More from forecastfashions (20)

Identify the organ labelled 3.liverstomacht h e mesenteryjej.pdf
Identify the organ labelled 3.liverstomacht h e mesenteryjej.pdfIdentify the organ labelled 3.liverstomacht h e mesenteryjej.pdf
Identify the organ labelled 3.liverstomacht h e mesenteryjej.pdf
 
Fahrenheit ToCelsiusValue.java Done Program name Fahrenheit To Celsiu.pdf
Fahrenheit ToCelsiusValue.java Done Program name Fahrenheit To Celsiu.pdfFahrenheit ToCelsiusValue.java Done Program name Fahrenheit To Celsiu.pdf
Fahrenheit ToCelsiusValue.java Done Program name Fahrenheit To Celsiu.pdf
 
Explain the relationship between three aspects of science hypothesi.pdf
Explain the relationship between three aspects of science hypothesi.pdfExplain the relationship between three aspects of science hypothesi.pdf
Explain the relationship between three aspects of science hypothesi.pdf
 
Did BP respond to the oil spill in a manner that was appropriate to .pdf
Did BP respond to the oil spill in a manner that was appropriate to .pdfDid BP respond to the oil spill in a manner that was appropriate to .pdf
Did BP respond to the oil spill in a manner that was appropriate to .pdf
 
Consider the subset S = {0, 2, 4, 6, 8, 10, 12} of Z14Z. (a) Show t.pdf
Consider the subset S = {0, 2, 4, 6, 8, 10, 12} of Z14Z.  (a) Show t.pdfConsider the subset S = {0, 2, 4, 6, 8, 10, 12} of Z14Z.  (a) Show t.pdf
Consider the subset S = {0, 2, 4, 6, 8, 10, 12} of Z14Z. (a) Show t.pdf
 
Assignment Description When dealing with a performance improvement .pdf
Assignment Description When dealing with a performance improvement .pdfAssignment Description When dealing with a performance improvement .pdf
Assignment Description When dealing with a performance improvement .pdf
 
Answer ALL 2 QUESTIONS please.... You configured several time settin.pdf
Answer ALL 2 QUESTIONS please.... You configured several time settin.pdfAnswer ALL 2 QUESTIONS please.... You configured several time settin.pdf
Answer ALL 2 QUESTIONS please.... You configured several time settin.pdf
 
A heritability of body weight of 0.4 means that body weight is deter.pdf
A heritability of body weight of 0.4 means that body weight is deter.pdfA heritability of body weight of 0.4 means that body weight is deter.pdf
A heritability of body weight of 0.4 means that body weight is deter.pdf
 
After reading the Cultural Competency Module, reflect on your own co.pdf
After reading the Cultural Competency Module, reflect on your own co.pdfAfter reading the Cultural Competency Module, reflect on your own co.pdf
After reading the Cultural Competency Module, reflect on your own co.pdf
 
A variable that consists of indivisible categories with no other sco.pdf
A variable that consists of indivisible categories with no other sco.pdfA variable that consists of indivisible categories with no other sco.pdf
A variable that consists of indivisible categories with no other sco.pdf
 
Write a short essay explaining the four primary groups of production.pdf
Write a short essay explaining the four primary groups of production.pdfWrite a short essay explaining the four primary groups of production.pdf
Write a short essay explaining the four primary groups of production.pdf
 
Why didnt the government just arrange to have excess food commodit.pdf
Why didnt the government just arrange to have excess food commodit.pdfWhy didnt the government just arrange to have excess food commodit.pdf
Why didnt the government just arrange to have excess food commodit.pdf
 
Where is Virtual Reality going, and where would it be 20 yearsS.pdf
Where is Virtual Reality going, and where would it be 20 yearsS.pdfWhere is Virtual Reality going, and where would it be 20 yearsS.pdf
Where is Virtual Reality going, and where would it be 20 yearsS.pdf
 
What is the negative side to overusing technical communication tools.pdf
What is the negative side to overusing technical communication tools.pdfWhat is the negative side to overusing technical communication tools.pdf
What is the negative side to overusing technical communication tools.pdf
 
What is the method of action of aldehydes They damage proteins .pdf
What is the method of action of aldehydes  They damage proteins .pdfWhat is the method of action of aldehydes  They damage proteins .pdf
What is the method of action of aldehydes They damage proteins .pdf
 
What are rubisco and RuBP And what do they do Briefly list 4 simil.pdf
What are rubisco and RuBP And what do they do  Briefly list 4 simil.pdfWhat are rubisco and RuBP And what do they do  Briefly list 4 simil.pdf
What are rubisco and RuBP And what do they do Briefly list 4 simil.pdf
 
Virtual Machines Discuss what are the new innovation today in this .pdf
Virtual Machines Discuss what are the new innovation today in this .pdfVirtual Machines Discuss what are the new innovation today in this .pdf
Virtual Machines Discuss what are the new innovation today in this .pdf
 
Using Java, please write the program for the following prompt in the.pdf
Using Java, please write the program for the following prompt in the.pdfUsing Java, please write the program for the following prompt in the.pdf
Using Java, please write the program for the following prompt in the.pdf
 
True or FalseBecause IPsec is located in the IP layer, when it is.pdf
True or FalseBecause IPsec is located in the IP layer, when it is.pdfTrue or FalseBecause IPsec is located in the IP layer, when it is.pdf
True or FalseBecause IPsec is located in the IP layer, when it is.pdf
 
TIA-569 lists six different areas or spaces where cabling is run. Li.pdf
TIA-569 lists six different areas or spaces where cabling is run. Li.pdfTIA-569 lists six different areas or spaces where cabling is run. Li.pdf
TIA-569 lists six different areas or spaces where cabling is run. Li.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
 

Recently uploaded (20)

Wellbeing inclusion and digital dystopias.pptx
Wellbeing inclusion and digital dystopias.pptxWellbeing inclusion and digital dystopias.pptx
Wellbeing inclusion and digital dystopias.pptx
 
COMMUNICATING NEGATIVE NEWS - APPROACHES .pptx
COMMUNICATING NEGATIVE NEWS - APPROACHES .pptxCOMMUNICATING NEGATIVE NEWS - APPROACHES .pptx
COMMUNICATING NEGATIVE NEWS - APPROACHES .pptx
 
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
 
Simple, Complex, and Compound Sentences Exercises.pdf
Simple, Complex, and Compound Sentences Exercises.pdfSimple, Complex, and Compound Sentences Exercises.pdf
Simple, Complex, and Compound Sentences Exercises.pdf
 
Interdisciplinary_Insights_Data_Collection_Methods.pptx
Interdisciplinary_Insights_Data_Collection_Methods.pptxInterdisciplinary_Insights_Data_Collection_Methods.pptx
Interdisciplinary_Insights_Data_Collection_Methods.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 Manage Global Discount in Odoo 17 POS
How to Manage Global Discount in Odoo 17 POSHow to Manage Global Discount in Odoo 17 POS
How to Manage Global Discount in Odoo 17 POS
 
Basic Intentional Injuries Health Education
Basic Intentional Injuries Health EducationBasic Intentional Injuries Health Education
Basic Intentional Injuries Health Education
 
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
 
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.
 
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
 
SOC 101 Demonstration of Learning Presentation
SOC 101 Demonstration of Learning PresentationSOC 101 Demonstration of Learning Presentation
SOC 101 Demonstration of Learning Presentation
 
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)
 
How to Create and Manage Wizard in Odoo 17
How to Create and Manage Wizard in Odoo 17How to Create and Manage Wizard in Odoo 17
How to Create and Manage Wizard in Odoo 17
 
FICTIONAL SALESMAN/SALESMAN SNSW 2024.pdf
FICTIONAL SALESMAN/SALESMAN SNSW 2024.pdfFICTIONAL SALESMAN/SALESMAN SNSW 2024.pdf
FICTIONAL SALESMAN/SALESMAN SNSW 2024.pdf
 
Philosophy of china and it's charactistics
Philosophy of china and it's charactisticsPhilosophy of china and it's charactistics
Philosophy of china and it's charactistics
 
Towards a code of practice for AI in AT.pptx
Towards a code of practice for AI in AT.pptxTowards a code of practice for AI in AT.pptx
Towards a code of practice for AI in AT.pptx
 
Tatlong Kwento ni Lola basyang-1.pdf arts
Tatlong Kwento ni Lola basyang-1.pdf artsTatlong Kwento ni Lola basyang-1.pdf arts
Tatlong Kwento ni Lola basyang-1.pdf arts
 
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
 
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
 

C++ BinaryTree Help Creating main function for Trees...Here are .pdf

  • 1. C++ BinaryTree Help : Creating main function for Trees... Here are the header files : PrintExpressionTour.H: #ifndef _PRINTEXPRESSIONTOUR_H_ #define _PRINTEXPRESSIONTOUR_H_ #include "EulerTour.h" #include template class PrintExpressionTour : public EulerTour { protected: // ...same type name shortcuts as in EvaluateExpressionTour public: inline void execute( const BinaryTree& T ) { // execute the tour initialize( T ); std::cout << "Expression: "; eulerTour( T.root() ); std::cout << std::endl; } protected: // leaf: print value virtual void visitExternal( const Position& p, Result& r ) const { std::cout << *p; } // left: open new expression virtual void visitLeft( const Position& p, Result& r ) const { std::cout << "("; } // below: print operator virtual void visitBelow( const Position& p, Result& r ) const { std::cout << *p; } // right: close expression virtual void visitRight( const BinaryTree::Position& p, Result& r ) const { std::cout << ")"; } }; #endif // _PRINTEXPRESSIONTOUR_H_ BinaryTree.h: #ifndef _BINARYTREE_H_
  • 2. #define _BINARYTREE_H_ #include #include typedef std::string Elem; // base element type class BinaryTree { protected: struct Node { // a node of the tree Elem elt; // element value Node* par; // parent Node* left; // left child Node* right; // right child Node() : elt(), par( NULL ), left( NULL ), right( NULL ) {} // constructor }; public: class Position { // position in the tree private: Node* v; // pointer to the node public: Position( Node* _v = NULL ) : v( _v ) {} // constructor Elem& operator*() const // get element { return v->elt; } Position left() const // get left child { return Position( v->left ); } Position right() const // get right child { return Position( v->right ); } Position parent() const // get parent { return Position( v->par ); } bool isRoot() const // root of the tree?
  • 3. { return v->par == NULL; } bool isExternal() const // an external node? { return v->left == NULL && v->right == NULL; } friend class BinaryTree; // give tree access }; typedef std::list PositionList; // list of positions public: BinaryTree(); // constructor int size() const; // number of nodes bool empty() const; // is tree empty? Position root() const; // get the root PositionList positions() const; // list of nodes void addRoot(); // add root to empty tree void expandExternal( const Position& p ); // expand external node Position removeAboveExternal( const Position& p ); // remove p and parent // housekeeping functions omitted... protected: // local utilities void preorder( Node* v, PositionList& pl ) const; // preorder utility private: Node* _root; // pointer to the root int n; // number of nodes }; #endif // _BINARYTREE_H_ EulerTour.h: #ifndef _EULERTOUR_H_ #define _EULERTOUR_H_ #include "BinaryTree.h" template // element and result types class EulerTour { // a template for Euler tour protected: struct Result { // stores tour results R leftResult; // result from left subtree
  • 4. R rightResult; // result from right subtree R finalResult; // combined result }; //typedef BinaryTree BinaryTree; // the tree typedef typename BinaryTree::Position Position; // a position in the tree protected: // data member const BinaryTree* tree; // pointer to the tree public: void initialize( const BinaryTree& T ) // initialize { tree = &T; } protected: // local utilities R eulerTour( const Position& p ) const { Result r = initResult(); if ( p.isExternal() ) { // external node visitExternal( p, r ); } else { // internal node visitLeft( p, r ); r.leftResult = eulerTour( p.left() ); // recurse on left visitBelow( p, r ); r.rightResult = eulerTour( p.right() ); // recurse on right visitRight( p, r ); } return result( r ); } // perform the Euler tour who will implement this? // functions given by subclasses virtual void visitExternal( const Position& p, Result& r ) const {} virtual void visitLeft( const Position& p, Result& r ) const {} virtual void visitBelow( const Position& p, Result& r ) const {} virtual void visitRight( const Position& p, Result& r ) const {} Result initResult() const { return Result(); } R result( const Result& r ) const { return r.finalResult;
  • 5. } }; #endif BinaryTree.cpp: #include "BinaryTree.h" void BinaryTree::expandExternal( const Position& p ) { Node* v = p.v; // p's node v->left = new Node; // add a new left child v->left->par = v; // v is its parent v->right = new Node; // and a new right child v->right->par = v; // v is its parent n += 2; // two more nodes } BinaryTree::PositionList BinaryTree::positions() const { PositionList pl; preorder( _root, pl ); // preorder traversal return PositionList( pl ); // return resulting list } // preorder traversal void BinaryTree::preorder( Node* v, PositionList& pl ) const { pl.push_back( Position( v ) ); // add this node if ( v->left != NULL ) // traverse left subtree preorder( v->left, pl ); if ( v->right != NULL ) // traverse right subtree preorder( v->right, pl ); } BinaryTree::BinaryTree() // constructor : _root( NULL ), n( 0 ) {} int BinaryTree::size() const // number of nodes { return n; } bool BinaryTree::empty() const // is tree empty? { return size() == 0; }
  • 6. BinaryTree::Position BinaryTree::root() const // get the root { return Position( _root ); } void BinaryTree::addRoot() // add root to empty tree { _root = new Node; n = 1; } I need to make another "main.cpp" for this BinaryTree: I have started with the following: #include #include #include "BinaryTree.h" #include "PrintExpressionTour.h" int main() { // What goes inside here by looking at the Tree Picture? system( "pause" ); return EXIT_SUCCESS; } Help Anyone Please? Thank you // 4 7 3 2 5 9 3 3 Solution Sequence Alignment or sequence comparison lies in spite of appearance of the bioinformatics, that describes the approach of arrangement of DNA/RNA or macromolecule sequences, so as to spot the regions of similarity among them. it's wont to infer structural, useful and biological process relationship between the sequences. Alignment finds similarity level between question sequence and completely different info sequences. The algorithmic program works by dynamic programming approach that divides the matter into smaller freelance sub issues. It finds the alignment a lot of quantitatively by assignment scores. When a replacement sequence is found, the structure and performance will be simply expected by doing sequence alignment. Since it's believed that, a sequence sharing common ascendent would exhibit similar structure or perform. bigger the sequence similarity, bigger is that the likelihood that they share similar structure or perform.
  • 7. Methods of Sequence Alignment: There square measure primarily 2 strategies of Sequence Alignment: Global Alignment : Closely connected sequences that square measure of same length square measure much applicable for international alignment. Here, the alignment is dole out from starting until finish of the sequence to search out out the simplest potential alignment. The Needleman-Wunsch algorithmic program (A formula or set of steps to unravel a problem) was developed by Saul B. Needleman and Christian D. Wunsch in 1970, that could be a dynamic programming algorithmic program for sequence alignment. The dynamic programming solves the initial drawback by dividing the matter into smaller freelance sub issues. These techniques square measure utilized in many various aspects of engineering science. The algorithmic program explains international sequence alignment for positioning ester or macromolecule sequences. Local Alignment : Sequences that square measure suspected to possess similarity or perhaps dissimilar sequences will be compared with native alignment technique. It finds native regions with high level of similarity. These 2 strategies of alignments square measure outlined by completely different algorithms, that use grading matrices to align the 2 completely different series of characters or patterns (sequences). {the 2|the 2} {different|totally completely different|completely different} alignment strategies square measure largely outlined by Dynamic programming approach for positioning two different sequences. Dynamic Programming: Dynamic programming is employed for optimum alignment of 2 sequences. It finds the alignment in an exceedingly a lot of quantitative approach by giving some scores for matches and mismatches (Scoring matrices), instead of solely applying dots. By looking out the best scores within the matrix, alignment will be accurately obtained. The Dynamic Programming solves the initial drawback by dividing the matter into smaller freelance sub issues. These techniques square measure utilized in many various aspects of engineering science. Needleman-
  • 8. Wunsch and Smith-Waterman algorithms for sequence alignment square measure outlined by dynamic programming approach. Scoring matrices: In optimum alignment procedures, largely Needleman-Wunsch and Smith-Waterman algorithms use classification system. For ester sequence alignment, the grading matrices used square measure comparatively less complicated since the frequency of mutation for all the bases square measure equal. Positive or higher price is appointed for a match and a negative or a lower price is appointed for pair. These assumption based mostly scores will be used for grading the matrices. There square measure different grading matrices that square measure predefined largely, utilized in the case of organic compound substitutions. Mainly used predefined matrices square measure PAM and BLOSUM. PAM Matrices: Margaret Dayhoff was the primary one to develop the PAM matrix, PAM stands for purpose Accepted Mutations. PAM matrices square measure calculated by perceptive the variations in closely connected proteins. One PAM unit (PAM1) specifies one accepted gene mutation per a hundred organic compound residues, i.e. one hundred and twenty fifth amendment and ninety nine remains in and of itself. BLOSUM: BLOcks SUbstitution Matrix, developed by Henikoff and Henikoff in 1992, used preserved regions. These matrices square measure actual proportion identity values. merely to mention, they depend upon similarity. Blosum sixty two suggests that there's sixty two Gestalt law of organization. Gap score or gap penalty: Dynamic programming algorithms use gap penalties to maximise the biological that means. Gap penalty is subtracted for every gap that has been introduced. There square measure completely different gap penalties like gap open and gap extension. The gap score defines a penalty given to alignment after we have insertion or deletion. throughout the evolution, there is also a case wherever we are able to see continuous gaps right along the sequence, that the linear gap penalty wouldn't be applicable for the alignment. therefore gap open and gap extension has been introduced once there square measure continuous gaps (five or more). The open penalty is often applied at the beginning of the gap, so the opposite gaps following it's given with a niche extension penalty which is able to be less compared to the open penalty. Typical values square measure –12 for gap gap, and –4 for gap extension.
  • 9. Working of Needleman -Wunsch algorithmic program To study the algorithmic program, take into account the 2 given sequences. CGTGAATTCAT (sequence #1) , GACTTAC (sequence #2) The length (count of the nucleotides or amino acids) of the sequence one and sequence a pair of square measure eleven and seven severally. The initial matrix is made with A+1 column’s and B+1 row’s (where A and B corresponds to length of the sequences). additional row and column is given, therefore on align with gap, at the beginning of the matrix as shown in Figure one. Figure 1: Initial matrix After making the initial matrix, grading schema should be introduced which might be user outlined with specific scores. the straightforward basic grading schema will be assumed as, if 2 residues (nucleotide or amino acid) at ith and jth position square measure same, matching score is one (S(i,j)= 1) or if the 2 residues at ith and jth position don't seem to be same, pair score is assumed as -1 (S(i,j)= -1 ). The gap score(w) or gap penalty is assumed as -1 . *Note: The a lot of match, pair and gap will be user outlined, provided the gap penalty ought to be negative or zero. Gap score is outlined as penalty given to alignment, after we have insertion or deletion. The dynamic programming matrix is outlined with 3 completely different steps. 1.Initialization of the matrix with the scores potential. 2.Matrix filling with most scores. 3.Trace back the residues for applicable alignment.