Question
8. in method 3 in DSS we used array of heights and merging of the trees is accomplished by this array ( we merged the
8. in method 3 in DSS we used array of heights and merging of the trees is accomplished by this array ( we merged the lowest tree to the highest tree ).
Assuming that instead array of heights we will use array of size, that will save the number of nodes for each tree and the new merge will be accomplished by this array of size in the same way from the smallest tree to the biggest tree.
a. write merge3 function that will implement this method.
b. Can you block the height of the tree according to this approach?
c. what is the complexity of merge3 in this approach ?
Defined functions:
Merge3(a,b) {
If(height[a] = height[b]){
T[b] = a;
Height[a]++;
}
Else if ( height[a] > height[b]){
T[b] = a;
}
Else{
t[a] = b;
}
}
Find3(x) {
K = x;
While ( k != t[k] ) {
K = t[k];
}
Return k;
}
Merge4 ( a,b) {
If ( a > b ) {
T[a] = b;
}
Else{
T[b] = a;
}
}
Find4(x) {
K = x;
While(t[k] !=k ){
K = t[k];
}
While( I != k ){
J = t[I];
I = j;
}
Return k;
}
Step by Step Solution
There are 3 Steps involved in it
Step: 1
Get Instant Access to Expert-Tailored Solutions
See step-by-step solutions with expert insights and AI powered tools for academic success
Step: 2
Step: 3
Ace Your Homework with AI
Get the answers you need in no time with our AI-driven, step-by-step assistance
Get Started