In pseudocode, you are to write a divide-and-conquer algorithm that checks if two input binary trees are isomorphic. Two trees are isomorphic if they have the same shape and same labels at each corresponding node. (a) An incomplete sketch of the algorithm is given below. Fill-in the missing parts and return the full algorithm. The notation is as follows. If T is a root reference, its left and right children are respectively denoted with T->left and T->right. The label of T is T->label. isIsomorphic ( P, ____) { if( P = null & _______) { return true } if( } 11 Q = null) { return false

icon
Related questions
Question
4
Isomorphic binary trees
In pseudocode, you are to write a divide-and-conquer algorithm that checks if two input binary
trees are isomorphic. Two trees are isomorphic if they have the same shape and same labels at
each corresponding node.
(a)
(b)
An incomplete sketch of the algorithm is given below. Fill-in the missing parts
and return the full algorithm.
The notation is as follows. If T is a root reference, its left and right children are respectively
denoted with T->left and T->right. The label of T is T->label.
is Isomorphic ( P, ____) {
}
if( P = null &) {
return true
}
if(
|| Q = null) {
return false
}
if( P->label Q->label) {
return false
}
return (isIsomorphic (_.
& isIsomoprhic (_.
|| (isIsomorphic(_
& isIsomoprhic (_.
)) //left of P and left of Q
._)
)))
//left of P and right of Q
Write down the recurrence expressing the complexity of the algorithm.
Transcribed Image Text:4 Isomorphic binary trees In pseudocode, you are to write a divide-and-conquer algorithm that checks if two input binary trees are isomorphic. Two trees are isomorphic if they have the same shape and same labels at each corresponding node. (a) (b) An incomplete sketch of the algorithm is given below. Fill-in the missing parts and return the full algorithm. The notation is as follows. If T is a root reference, its left and right children are respectively denoted with T->left and T->right. The label of T is T->label. is Isomorphic ( P, ____) { } if( P = null &) { return true } if( || Q = null) { return false } if( P->label Q->label) { return false } return (isIsomorphic (_. & isIsomoprhic (_. || (isIsomorphic(_ & isIsomoprhic (_. )) //left of P and left of Q ._) ))) //left of P and right of Q Write down the recurrence expressing the complexity of the algorithm.
Expert Solution
steps

Step by step

Solved in 3 steps

Blurred answer