Question

Algorithm Question: Please do not write a real program. The answer should be an explaination of...

Algorithm Question:

Please do not write a real program.

The answer should be an explaination of your algorithm or pseudocode. Try to answer clearly and concisely. Thank you very much.

Question:

We are given a binary tree with height larger than h. Give an algorithm
that finds a subtree of height h and among such tree, it returns the one with least
number of elements.

0 0
Add a comment Improve this question Transcribed image text
Answer #1

The pseudocode for the above description is as follows:

Pseudocode:

1. Height of binary tree h.

2. Count the number of nodes in the binary tree as count.

3. Initialize the array of nodes in arr[];

4. for(i=0 ; i<arr.length ; i++)

subtree = arr[i];

if(subtree has adjacent node)

then add it in the array

temp[] = arr[i];

else

move forward;

  

5. Output the shortest temp[] which will be the subtree.

Rate an upvote.....Thankyou

Hope this helps.....

Add a comment
Know the answer?
Add Answer to:
Algorithm Question: Please do not write a real program. The answer should be an explaination of...
Your Answer:

Post as a guest

Your Name:

What's your source?

Earn Coins

Coins can be redeemed for fabulous gifts.

Not the answer you're looking for? Ask your own homework help question. Our experts will answer your question WITHIN MINUTES for Free.
Similar Homework Help Questions
  • Please answer this in python pseudocode. It's an algorithm question. 1. [10 marks] Consider the function...

    Please answer this in python pseudocode. It's an algorithm question. 1. [10 marks] Consider the function SumKSmallest(A[0..n – 1), k) that returns the sum of the k smallest elements in an unsorted integer array A of size n. For example, given the array A=[6,-6,3,2,1,2,0,4,3,5] and k=3, the function should return -5. a. [3 marks) Write an algorithm in pseudocode for SumKSmallest using the brute force paradigm. Indicate and justify (within a few sentences) the time complexity of your algorithm. b....

  • Would appreciate the answer in the Java coding language please and thank you! 10d 10h left...

    Would appreciate the answer in the Java coding language please and thank you! 10d 10h left Java 7 1. Check the Structure Autocomplete Ready 1 > import java.io.*;... 10 ALL A binary tree uses a multi-node data structure where each node may have 0 to 2 child nodes, and has one stored value, its node number in this case. A tree may either be: 11 class Result { * Complete the 'isValid' function below. • An empty tree, the root...

  • can u please help me answer this question and also please write clearly so I can...

    can u please help me answer this question and also please write clearly so I can understand thank you so much also please show all steps thank you so much Q1 The following formula estimates an average person's lung capacity V (in liters, where 11-103 cm): V = 4.1 H-0.018 A-2.7 where H and A are the person's height (in meters) and age (in years), respectively. In this formula, what are the UNITS of the numbers 4.1, 0.018, and 2.7?...

  • NEED HELP IN C!! Answer in C programming language. Question: Functions and .h file: Test function:...

    NEED HELP IN C!! Answer in C programming language. Question: Functions and .h file: Test function: part 1: part 2: For the assignment use the following structs for Binary Trees and Binary Search Trees. struct Binode { int value; struct Binode* left; struct BTnode* right; struct BTnode* parent; }; typedef struct Binode BTnode_t; typedef struct BST { BTnode_t* root; BST_t; Question 2 [10 points] Write a function that gets a binary tree and returns the sum of its elements. //...

  • For this computer assignment, you are to write a C++ program to implement a class for...

    For this computer assignment, you are to write a C++ program to implement a class for binary trees. To deal with variety of data types, implement this class as a template. The definition of the class for a binary tree (as a template) is given as follows: template < class T > class binTree { public: binTree ( ); // default constructor unsigned height ( ) const; // returns height of tree virtual void insert ( const T& ); //...

  • Java Programming Write a program to find the number of comparison using binarySearch and the sequentialSearch...

    Java Programming Write a program to find the number of comparison using binarySearch and the sequentialSearch algorithms as follows: Suppose list is an array of 2500 elements. 1. Use a random number generator to fill list; 2. Use a sorting algorithm to sort list; 3. Search list for some items as follows: a) Use the binary search algorithm to search list (please work on SearchSortAlgorithms.java and modify the algorithm to count the number of comparisons) b) Use the sequential search...

  • all in pseudocode Question 1) Warmup question: Write a function named True False() (only the function,...

    all in pseudocode Question 1) Warmup question: Write a function named True False() (only the function, no main is needed) that takes in a number and determines if it is evenly divisible by 5 (le, returns true or false). (15 points) Answer is in: Pseudocode CHO Java0 C+0 Page 17 Question 3) 2D Arrays The IRS has contracted you to process a 10x10 array of floating point numbers called Taxes and sum up all negative numbers in the array so...

  • JAVA 3 PLEASE ANSWER AS MANY QUESTIONS AS POSSIBLE! ONLY 2 QUESTIONS LEFT THIS MONTH!!! Question...

    JAVA 3 PLEASE ANSWER AS MANY QUESTIONS AS POSSIBLE! ONLY 2 QUESTIONS LEFT THIS MONTH!!! Question 12 pts Which is a valid constructor for Thread? Thread ( Runnable r, int priority ); Thread ( Runnable r, String name ); Thread ( int priority ); Thread ( Runnable r, ThreadGroup g ); Flag this Question Question 22 pts What method in the Thread class is responsible for pausing a thread for a specific amount of milliseconds? pause(). sleep(). hang(). kill(). Flag...

  • Please answer this question clearly and correctly! the code should be handwritten if all possible!! ALSO...

    Please answer this question clearly and correctly! the code should be handwritten if all possible!! ALSO MAKE SURE IT IS WRITTEN IN C++! thank you so much in advance and I will upvote when done right! (8 points) Create a class called resizeableArray. Include an int pointer arrayPtr variable that points to a dynamic array, a capacity variable that holds the dynamic array maximum size and a currentSize variable that has the current number of elements assigned in the dynamic...

  • Answer the following question on topic shadows and waves A. We are working on the wave...

    Answer the following question on topic shadows and waves A. We are working on the wave model of light. The idea that waves can move around on the surface of a swimming pool or a pond is obvious, partly because you can see the surface of water and the waves have large enough wavelength so you can easily see it. We can see light, but the wavelength is very very short, much shorter than our unaided eyes can see. For...

ADVERTISEMENT
Free Homework Help App
Download From Google Play
Scan Your Homework
to Get Instant Free Answers
Need Online Homework Help?
Ask a Question
Get Answers For Free
Most questions answered within 3 hours.
ADVERTISEMENT
ADVERTISEMENT
ADVERTISEMENT