Trusted by Students Everywhere
Why Choose Us?
0% AI Guarantee

Human-written only.

24/7 Support

Anytime, anywhere.

Plagiarism Free

100% Original.

Expert Tutors

Masters & PhDs.

100% Confidential

Your privacy matters.

On-Time Delivery

Never miss a deadline.

The COVID-19 pandemic situation has challenged the medical equipment supply chain leading to an uneven distribution of personal protective equipment (PPEs) at local hospitals

Computer Science Nov 06, 2022

The COVID-19 pandemic situation has challenged the medical equipment supply chain leading to an uneven distribution of personal protective equipment (PPEs) at local hospitals. Assuming the following:

  • These hospitals are represented as nodes (of type BSTNode) in a binary tree.
  • There are N numbers of hospitals.
  • There are N numbers of PPEs.
  • Even distribution means each hospital receives 1 PPE (in a real situation, this 1 PPE can be 1 truckload of PPEs but we are using 1 PPE to simplify this problem).

3 1

/ \ -----> / \

0 0 1 1

For brevity, the above tree can be flattened level-order-wide in an array as [3,0,0]. The resulting tree is [1,1,1]. The above initial distribution requires TWO (2) moves to arrive at an even distribution with each node receiving 1 PPE, namely, 1 PPE going from root -> root. left, and another PPE from root -> root. right. You will start with the following code template.

Homework Assignment #8 Homework Assignment #8 Details PLATFORM INDEPENDENCE 5/6/2021 –/10 Points Calculated by: Most Recent Please see Syllabus for more information. Unlimited Attempts MISSING Your solution has to be platform-independent; it must run on any platforms including any online SUBMITTED IDEs: 1 Attempt View Feedback Next Up: Review Feedback You solution should be free of any use of packages. Example, absolutely no /* Java Program Example - Java Import Packages * package YOUR_CUSTOM_PACKAGE HERE; Your solution, regardless of how many classes it has, should be in one .java file. Your solution has to run on any online IDEs. If your solution fails the platform-independence criteria, you will have to resubmit work subject to the late penalty. The Late Work policy applies for all late submissions. Your solution should be reusable, meaning it will be invoked and validated against a series of input sequentially to produce consistent outcomes like so: Solution sol = new Solution(); sol.your_method1(test_input_1...); sol.your_method2(test_input_2 ...); PROBLEM 1 Try Again https://online.smc.edu/courses/38679/assignments/739873 1/5 5/8/2021 Homework Assignment #8 VIDEO DESCRIPTION HERE (https://cccconfer.zoom.us/rec/share/yvq8poxULRwC9smTbp0X31mFC_mmxZ6ydlYIewsnzeg5aj1M3qDVZ3o6ld91YOT.GVyjqNqsdaYzo5QH? startTime=1620099281000) ( 10 points ) The COVID-19 pandemic situation has challenged the medical equipment supply chain leading to an uneven distribution of personal protective equipments (PPEs) at local hospitals. Assuming the following: These hospitals are represented as nodes (of type BSTNode) in a binary tree. There are N number of hospitals. There are N number of PPEs. Even distribution means each hospital receives 1 PPE (in real situation, this 1 PPE can be 1 truck load of PPEs but we are using 1 PPE to simplify this problem). To solve the supply chain logistic, you are asked to write a quick software to output the number of moves required to evenly distribute PPEs amongst the hospitals such that each receives 1 PPE. For example you may have an initial distribution map looking like so: 3 1 /\ 0 0 -----> / \ 1 1 For brevity the above tree can be flattened level-order-wide in an array as [3,0,0]. The resulting tree is [1,1,1]. The above initial distribution requires TWO (2) moves to arrive at an even distribution with each node receiving 1 PPE, namely, 1 PPE going from root -> root.left, and another PPE from root -> root.right. You will start with the following code template. STARTER CODE import java.util.*; public class Solution1 { public static void main(String[] args) { // create a solution instance Solution sol = new Solution(); // create a random BSTNode tree = new tree.left = new tree.right = new } } binary tree of your choice BSTNode(3); BSTNode(0); BSTNode(0); // your solution method will be tested with // a random tree of your choice System.out.println(sol.distribute(tree)); // 2 // =============================================== // DO NOT MODIFY TREE BELOW THIS LINE // =============================================== class BSTNode { int val; BSTNode left; BSTNode right; BSTNode(int x) { val = x; } https://online.smc.edu/courses/38679/assignments/739873 Try Again 2/5 5/8/2021 Homework Assignment #8 } // =============================================== // DO NOT MODIFY TREE ABOVE THIS LINE // =============================================== class Solution { // YOUR MAY ADD ANY GLOBAL VARIABLES, // HELPER METHODS, etc., in this class } /** * PURPOSE: * PARAMETERS: * RETURN VALUES: */ public int distribute(BSTNode root) { // YOUR CODE HERE } EXAMPLES // TEST CASE #1 Input: [3,0,0] // level-order wise representation in array 3 / \ 0 0 Output: 2 // TEST CASE #2 Input: 0 / \ 0 3 Output: 3 // TEST CASE #3 Input: 0 / \ 0 1 / / \ 1 1 3 Output: 5 // TEST CASE #4 Input: 0 / \ 0 3 / / \ 0 3 0 / / \ 0 2 1 Output: 13 // TEST CASE #5 Input: 9 / \ 0 0 / / \ 0 0 0 / / \ https://online.smc.edu/courses/38679/assignments/739873 Try Again 3/5 5/8/2021 Homework Assignment #8 0 0 0 Output: 17 // TEST CASE #6 Input: 0 / \ 0 1 / 0 / 0 / 5 Output: 10 CONSTRAINTS / ASSUMPTIONS If root tree (input) is null , return 0; Number of hospitals = number of PPEs. 1

Archived Solution
Unlocked Solution

You have full access to this solution. To save a copy with all formatting and attachments, use the button below.

Already a member? Sign In
Important Note: This solution is from our archive and has been purchased by others. Submitting it as-is may trigger plagiarism detection. Use it for reference only.

For ready-to-submit work, please order a fresh solution below.

Or get 100% fresh solution
Get Custom Quote
Secure Payment