Show the result of inserting 10, 12, 1, 14, 6, 5, 8, 15, 3, 9, 7, 4, 11, 13, and 2, one at a time, into an initially empty binary heap. b. Show the result of using the linear-time algorithm to build a binary heap using the same input.
Show the result of performing three deleteMin operations in the heap of the previous exercise.

Answers

Answer 1

Answer:

Explanation:

A)

10 10 10 1 1

/ / \ --> / \ / \

12 12 1 12 10 12 10

/

14

1 1 1 1

/ \ / \ / \ / \

12 10 --> 6 10 6 10 --> 6 5

/ \ / \ / \ / / \ /

14 6 14 12 14 12 5 14 12 10

1 1 1 1

/ \ / \ / \ / \

6 5 6 5 6 5 --> 3 5

/ \ / \ / \ / \ / \ / \ / \ / \

14 12 10 8 14 12 10 8 14 12 10 8 6 12 10 8

/ / \ / \

15 15 3 15 14

After inserting all 1

/ \

3 2

/ \ / \

6 7 5 4

/ \ / \ / \ / \

15 14 12 9 10 11 13 8

b)

First level build : 10

/ \

12 1

/ \ / \

14 6 5 8

/ \ / \ / \ / \

15 3 9 7 4 11 13 2

Heap bottom level: 10

/ \

12 1

/ \ / \

3 6 4 2

/ \ / \ / \ / \

15 14 9 7 5 11 13 8

Heap next level up: 10

/ \

3 1

/ \ / \

12 6 4 2

/ \ / \ / \ / \

15 14 9 7 5 11 13 8

Final heap: 1

/ \

3 2

/ \ / \

12 6 4 8

/ \ / \ / \ / \

15 14 9 7 5 11 13 10

c)

Duing the first time,

First, assume the last element, the 8, is at the root and bubble down.

Then, assume the last element, the 13, is at the root and bubble down.

Then, assume the last element, the 11, is at the root and bubble down.

Final heap:

4

/ \

6 5

/ \ / \

13 7 10 8

/ \ / \ /

15 14 12 9 11

In the next iteration,

First, assume the last element, the 10, is at the root and bubble down.

Then, assume the last element, the 13, is at the root and bubble down.

Then, asssume the last element, the 11, is at the root and bubble down.

So, after performing all operations, the heap looks like below:

4

/ \

6 5

/ \ / \

12 7 10 8

/ \ / \ /

15 14 9 13 11


Related Questions

Spending plans serve as a tool to analyze program execution, an indicator of potential problems, and a predictor of future program performance. True False

Answers

Answer:

True

Explanation:

Spending plans serve as a tool to analyze program execution, an indicator of potential problems, and a predictor of future program performance.

Consider the following class in Java:

public class MountainBike extends Bicycle {
public int seatHeight;
public MountainBike(int startHeight,
int startCadence,
int startSpeed,
int startGear) {
super(startCadence, startSpeed, startGear);
seatHeight = startHeight;
}

public void setHeight(int newValue) {
seatHeight = newValue;
}
}
What is this trying to accomplish?

super(startCadence, startSpeed, startGear);

a. Four fields of the MountainBike class are defined: super, startCadence, startSpeed and startGear.
b. The constructor for the parent class is called.
c. A method of the MountainBike class named super is defined.
d. Three fields are defined for the MountainBike class as intances of the class named super.

Answers

Answer:

b. The constructor for the parent class is called.

Explanation:

In this case this specific piece of code is calling the constructor for the parent class. Since a MountainBike object is being created. This creation uses the MountainBike class constructor but since this is a subclass of the Bicycle class, the super() method is calling the parent class constructor and passing the variables startCadence, startSpeed, startGear to that constructor. The Bicycle constructor is the one being called by super() and it will handle what to do with the variables inputs being passed.

Explain the following terms.
a) Explain Final keyword with example. b) Define Static and Instance variables

Answers

Answer:

A.

the final keyword is used to denote constants. It can be used with variables, methods, and classes. Once any entity (variable, method or class) is declared final , it can be assigned only once.

B.

Static variables are declared in the same place as instance variables, but with the keyword 'static' before the data type. While instance variables hold values that are associated with an individual object, static variables' values are associated with the class as a whole.

A coin is tossed repeatedly, and a payoff of 2n dollars is made, where n is the number of the toss on which the first Head appears. So TTH pays $8, TH pays $4 and H pays $2. Write a program to simulate playing the game 10 times. Display the result of the tosses and the payoff. At the end, display the average payoff for the games played. A typical run would be:

Answers

Answer:

Explanation:

The following code is written in Java. It creates a loop within a loop that plays the game 10 times. As soon as the inner loop tosses a Heads (represented by 1) the inner loop breaks and the cost of that game is printed to the screen. A test case has been made and the output is shown in the attached image below.

import java.util.Random;

import java.util.Scanner;

class Brainly {

   public static void main(String[] args) {

       int count = 0;

       int loopCount = 0;

       while (loopCount < 10) {

           while (true) {

               Random rand = new Random();

               int coinFlip = rand.nextInt(2);

               count++;

               if (coinFlip == 1) {

                   System.out.println("Cost: $" + 2*count);

                   count = 0;

                   break;

               }

               loopCount++;

           }

       }

   }

}

Consists of forging the return address on an email so that the message appears to come from someone other than the actual sender:_____.
A. Malicious code.
B. Hoaxes.
C. Spoofing.
D. Sniffer.

Answers

Answer:

C. Spoofing.

Explanation:

Cyber security can be defined as preventive practice of protecting computers, software programs, electronic devices, networks, servers and data from potential theft, attack, damage, or unauthorized access by using a body of technology, frameworks, processes and network engineers.

Some examples of cyber attacks are phishing, zero-day exploits, denial of service, man in the middle, cryptojacking, malware, SQL injection, spoofing etc.

Spoofing can be defined as a type of cyber attack which typically involves the deceptive creation of packets from an unknown or false source (IP address), as though it is from a known and trusted source. Thus, spoofing is mainly used for the impersonation of computer systems on a network.

Basically, the computer of an attacker or a hacker assumes false internet address during a spoofing attack so as to gain an unauthorized access to a network.

Which of the following financial functions can you use to calculate the payments to repay your loan

Answers

Answer:

PMT function. PMT, one of the financial functions, calculates the payment for a loan based on constant payments and a constant interest rate. Use the Excel Formula Coach to figure out a monthly loan payment.

Explanation:

Write a function that takes six arguments of floating type (four input arguments and two output arguments). This function will calculate sum and average of the input arguments and storethem in output arguments respectively. Take input arguments from the user in the main function.

Answers

Answer:

Answer:Functions in C+

The integer variable n is the input to the function and it is also called the parameter of the function. If a function is defined after the main() .....

Sophia is putting together a training manual for her new batch of employees.Which of the following features can she use to add a document title at the top of each page?
A) Heading style
B) Page margin
C) References
D) Header and Footer

Answers

Answer:

A heading style to add a document title

The feature can she use to add a document title at the top of each page is - Heading style. Therefore option A is the correct resposne.

What are Header and Footer?

A footer is a text that is positioned at the bottom of a page, whereas a header is text that is positioned at the top of a page. Usually, details about the document, such as the title, chapter heading, page numbers, and creation date, are inserted in these spaces.

A piece of the document that appears in the top margin is called the header, while a section that appears in the bottom margin is called the footer. Longer papers may be kept structured and made simpler to read by including more information in the headers and footers, such as page numbers, dates, author names, and footnotes. Each page of the paper will have the header or footer text you input.

To read more about Header and Footer, refer to - https://brainly.com/question/20998839

#SPJ2

If the signal is going through a 2 MHz Bandwidth Channel, what will be the maximum bit rate that can be achieved in this channel? What will be the appropriate signal level?

Answers

Answer:

caca

Explanation:

Coding 5 - Classes The Item class is defined for you. See the bottom of the file to see how we will run the code. Define a class ShoppingCart which supports the following functions: add_item(), get_total_price(), and print_summary(). Write code only where the three TODO's are. Below is the expected output: Added 2 Pizza(s) to Cart, at $13.12 each. Added 1 Soap(s) to Cart, at $2.25 each. Added 5 Cookie(s) to Cart, at $3.77 each.

Answers

Answer:

Explanation:

The following is written in Java. It creates the ShoppingCart class as requested and implements the requested methods. A test class has been added to the main method and the output is highlighted in red down below.

import java.util.ArrayList;

import java.util.Scanner;

class Brainly {

   public static void main(String[] args) {

       ShoppingCart newCart = new ShoppingCart();

       newCart.add_item();

       newCart.add_item();

       newCart.add_item();

       newCart.print_summary();

   }

}

class ShoppingCart {

   Scanner in = new Scanner(System.in);

   ArrayList<String> items = new ArrayList<>();

   ArrayList<Integer> amount = new ArrayList<>();

   ArrayList<Double> cost = new ArrayList<>();

   public ShoppingCart() {

   }

   public void add_item() {

       System.out.println("Enter Item:");

       this.items.add(this.in.next());

       System.out.println("Enter Item Amount:");

       this.amount.add(this.in.nextInt());

       System.out.println("Enter Cost Per Item:");

       this.cost.add(this.in.nextDouble());

   }

   public void get_total_price() {

       double total = 0;

       for (double price: cost) {

           total += price;

       }

       System.out.println("Total Cost: $" + total);

   }

   public void print_summary() {

       for (int i = 0; i < items.size(); i++) {

           System.out.println(amount.get(i) + " " + items.get(i) + " at " + cost.get(i) + " each.");

       }

       get_total_price();

   }

}

Java programming
*11.13 (Remove duplicates) Write a method that removes the duplicate elements from
an array list of integers using the following header:
public static void removeDuplicate(ArrayList list)
Write a test program that prompts the user to enter 10 integers to a list and displays
the distinct integers separated by exactly one space. Here is a sample run:
Enter ten integers: 34 5 3 5 6 4 33 2 2 4
The distinct integers are 34 5 3 6 4 33 2

Answers

Answer:

The program in Java is as follows:

import java.util.*;

public class Main {

public static void removeDuplicate(ArrayList<Integer> list){

 ArrayList<Integer> newList = new ArrayList<Integer>();

 for (int num : list) {

  if (!newList.contains(num)) {

   newList.add(num);  }  }

 for (int num : newList) {

     System.out.print(num+" ");  } }

public static void main(String args[]){

 Scanner input = new Scanner(System.in);

 ArrayList<Integer> list = new ArrayList<Integer>();

 System.out.print("Enter ten integers: ");

 for(int i = 0; i<10;i++){

     list.add(input.nextInt());  }

 System.out.print("The distinct integers are: ");

 removeDuplicate(list);

}}

Explanation:

This defines the removeDuplicate function

public static void removeDuplicate(ArrayList<Integer> list){

This creates a new array list

 ArrayList<Integer> newList = new ArrayList<Integer>();

This iterates through the original list

 for (int num : list) {

This checks if the new list contains an item of the original list

  if (!newList.contains(num)) {

If no, the item is added to the new list

   newList.add(num);  }  }

This iterates through the new list

 for (int num : newList) {

This prints every element of the new list (At this point, the duplicates have been removed)

     System.out.print(num+" ");  } }

The main (i.e. test case begins here)

public static void main(String args[]){

 Scanner input = new Scanner(System.in);

This declares the array list

 ArrayList<Integer> list = new ArrayList<Integer>();

This prompts the user for ten integers

 System.out.print("Enter ten integers: ");

The following loop gets input for the array list

 for(int i = 0; i<10;i++){

     list.add(input.nextInt());  }

This prints the output header

 System.out.print("The distinct integers are: ");

This calls the function to remove the duplicates

 removeDuplicate(list);

}}

Write a recursive method to form the sum of two positive integers a and b. Test your program by calling it from a main program that reads two integers from the keyboard and users your method to complete and print their sum, along with two numbers.

Answers

Answer:

see the code snippet below writing in Kotlin Language

Explanation:

fun main(args: Array<String>) {

   sumOfNumbers()

}

fun sumOfNumbers(): Int{

   var firstNum:Int

   var secondNum:Int

   println("Enter the value of first +ve Number")

   firstNum= Integer.valueOf(readLine())

   println("Enter the value of second +ve Number")

   secondNum= Integer.valueOf(readLine())

   var sum:Int= firstNum+secondNum

  println("The sum of $firstNum and $secondNum is $sum")

   return sum

}

In Interactive Charting, which chart type allows you to chart the current spread between a corporate bond and a benchmark government bond?
a. Price
b. Price Impact
c. Bond Spread
d. Yield Curve

Answers

Answer:

c. Bond Spread

Explanation:

An interactive chart is used to show all the details in the chart and the user can extend or shrink the details that is presented in the charts by using the slider control.

The bond spread in an interactive is a chart that is used to compare and chart the current spread between the corporate bond as well as the benchmark government bond.

In Interactive Charting, the chart type that give room for charting the current spread between a corporate bond and a benchmark government bond is C:Bond Spread.

An interactive charts serves as a chart that give room to the user to carry out zooming actions as well as hovering a marker to get a tooltip and avenue to choose variable.

One of the notable type of this chart is Bond Spread, with this chart type, it is possible to charting the current spread that exist between a corporate bond as well as benchmark government bond.

Therefore, option C is correct because it allows charting of the current spread between a corporate bond.

Learn note about interactive charts at:

https://brainly.com/question/7040405

let's have a class named Distance having two private data members such as feet(integer), inches(float), one input function to input values to the data members, one Display function to show the distance. The distance 5 feet and 6.4 inches should be displayed as 5’- 6.4”. Then add the two objects of Distance class and then display the result (the + operator should be overloaded). You should also take care of inches if it's more than 12 then the inches should be decremented by 12 and feet to be incremented by 1.

Answers

Answer:

Humildade

Ser justo (Fair Play)

Vencer independente

A user reports network resources can no longer be accessed. The PC reports a link but will only accept static IP addresses. The technician pings other devices on the subnet, but the PC displays the message Destination unreachable. Wh are MOST likley the causes of this issue?

Answers

Answer: is this a real question but I think it would be Ip address hope this helps :)))

Explanation:

Being the Sales Manager of a company you have to hire more salesperson for the company to expand the sales territory. Kindly suggest an effective Recruitment and Selection Process to HR by explaining the all the stages in detail.

Answers

Answer:

1. Identification of a vacancy and development of the job description.

2. Recruitment planning

3. Advertising

4. Assessment and Interview of applicants

5. Selection and Appointment of candidates

6. Onboarding

Explanation:

The Recruitment process refers to all the stages in the planning, assessment, and absorption of candidates in an organization. The stages involved include;

1. Identification of a vacancy and development of the job description: This is the stage where an obvious need in the organization is identified and the duties of the job requirement are stipulated.

2. Recruitment planning: This is the stage where the HR team comes together to discuss the specific ways they can attract qualified candidates for the job.

3. Advertising: The HR team at this point seeks out job sites, newspapers, and other platforms that will make the opportunities accessible to applicants.

4. Assessment and Interview of applicants: Assessments are conducted to gauge the candidates' knowledge and thinking abilities. This will provide insight into their suitability for the job.

5. Selection and Appointment of candidates: Successful candidates are appointed to their respective positions. A letter of appointment is given.

6. Onboarding: Candidates are trained and guided as to the best ways of discharging their duties.

Which key should you press to leave the cell as it originally was?

Answers

Answer:

Backspace.

Explanation:

Cancel Button you should press to leave the cell as it originally was. Cancel Button you should press to leave the cell as it originally was. This answer has been confirmed as correct and helpful.

Backspace is press to leave the cell as it originally was.

What is Backspace key?

The Backspace key is situated in the top-right corner of the character keys part of the keyboard.

Backspace is replaced by a "delete" key on Apple computers, although it serves the same purpose.

There are no "backspace" keys on an Android or Apple iPhone smartphone or iPad tablet, but there is a key that serves the same purpose. Look for a key that resembles an arrow with a "X" or an arrow pointing left, as illustrated in the image.

Therefore, Backspace is press to leave the cell as it originally was.

To learn more about backspace, refer to the link:

https://brainly.com/question/29790869

#SPJ2

How can I pass the variable argument list passed to one function to another function.

Answers

Answer:

Explanation:

#include <stdarg.h>  

main()  

{  

display("Hello", 4, 12, 13, 14, 44);  

}  

display(char *s,...)  

{  

va_list ptr;  

va_start(ptr, s);  

show(s,ptr);  

}  

show(char *t, va_list ptr1)  

{  

int a, n, i;  

a=va_arg(ptr1, int);  

for(i=0; i<a; i++)  

 {  

n=va_arg(ptr1, int);  

printf("\n%d", n);  

}  

}

Complete the calcAverage() method that has an integer array parameter and returns the average value of the elements in the array as a double.(Java program)

Ex: If the input array is:

1 2 3 4 5
then the returned average will be:

3.0

Answers

Answer:

Explanation:

The following Java program has the method calcAverage(). It creates a sum variable which holds the sum of all the values in the array and the count variable which holds the number of elements in the array. Then it uses a For Each loop to loop through the array and go adding each element to the sum variable. Finally it calculates the average by dividing the sum by the variable count and returns the average to the user. A test case has been created in the main method using the example in the question. The output can be seen in the image attached below.

class Brainly {

   public static void main(String[] args) {

       int[] myArr = {1, 2, 3, 4, 5};

       System.out.println(calcAverage(myArr));

   }

   

   public static double calcAverage(int[] myArr) {

       double sum = 0;

       double count = myArr.length;

       for (int x: myArr) {

           sum += x;

       }

       double average = sum / count;

       return average;

   }

}

Base conversion. Perform the following conversion (you must have to show the steps to get any credit.
3DF16 = ?

Answers

Base to be converted to was not included but we would assume conversion to base 10(decimal)

Answer and Explanation:

The 3DF in base 16 is a hex number so we need to convert to its equivalent binary/base 2 form:

We therefore each digit of given hex number 3DF in base 16 to equivalent binary, 4 digits each.

3 = 0011

D = 1101

F = 1111

We then arrange the binary numbers in order

3DF base 16 = 1111011111 in base 2

We then convert to base 10 =

= 1x2^9+1x2^8+1x2^7+1x2^6+0x2^5+1x2^4+1x2^3+1x2^2+1×2^1+1×2^0

= 991 in base 10

That's the code that's was already provided with the assignment
// Program takes a hot dog order
// And determines price
using System;
using static System.Console;
class DebugFour1
{
static void Main()
{
const double BASIC_DOG_PRICE = 2.00;
const double CHILI_PRICE = 0.69;
const double CHEESE_PRICE = 0.49;
String wantChili, wantCheese;
double price;
Write("Do you want chili on your dog? ");
wantChilli = ReadLine();
Write("Do you want cheese on your dog? ");
wantCheese = ReadLine();
if(wantChili = "Y")
if(wantCheese = "Y")
price == BASIC_DOG_PRICE + CHILI_PRICE + CHEESE_PRICE;
else
price == BASIC_DOG_PRICE + CHILI_PRICE;
else
if(wantCheese = "Y")
price = BASIC_DOG_PRICE;
else
price == BASIC_DOG_PRICE;
WriteLine("Your total is {0}", price.ToString("C"));
}
}

Answers

Answer:

Code:-

// Program takes a hot dog order

// And determines price  

using System;

using static System.Console;  

class DebugFour1

{

   static void Main()

   {

       const double BASIC_DOG_PRICE = 2.00;

       const double CHILI_PRICE = 0.69;

       const double CHEESE_PRICE = 0.49;

       String wantChili, wantCheese;

       double price;

       Write("Do you want chili on your dog? ");

       wantChili = ReadLine();

       Write("Do you want cheese on your dog? ");

       wantCheese = ReadLine();

       if (wantChili == "Y")

       {

           if (wantCheese == "Y")

               price = BASIC_DOG_PRICE + CHILI_PRICE + CHEESE_PRICE;

           else

               price = BASIC_DOG_PRICE + CHILI_PRICE;

       }

       else

       {

           if (wantCheese == "Y")

               price = BASIC_DOG_PRICE + CHEESE_PRICE;

           else

               price = BASIC_DOG_PRICE;

       }

       WriteLine("Your total is {0}", price.ToString("C"));

   }

}

The DevOps team is requesting read/write access to a storage bucket in the public cloud that is located in a backup region. What kind of services are they requesting

Answers

Answer:

Authorization

Explanation:

The kind of service that they are requesting is known as Authorization. This is basically when a user, such as the DevOps team in this scenario, is requesting permission to access a certain service or function that is locked. In this scenario, the services being requested are the read/write access which would allow the DevOps team to manipulate the data in the storage bucket. This is usually locked because the data is sensitive and innapropriate changes can cause many errors in the system. Therefore, authorization is needed to make sure that only specific users have access.

Write a program using integers user_num and x as input, and output user_num divided by x three times.Ex: If the input is:20002Then the output is:1000 500 250Note: In Python 3, integer division discards fractions. Ex: 6 // 4 is 1 (the 0.5 is discarded).LAB ACTIVITY2.29.1: LAB: Divide by x0 / 10main.pyLoad default template...12''' Type your code here. '''

Answers

Answer:

Following are the code to the given question:

user_num = int(input())#defining a variable user_num that takes input from user-end

x = int(input())#defining a variable x that takes input from user-end

for j in range(3):#defining for loop that divides the value three times

   user_num = user_num // x#dividing the value and store integer part

   print(user_num)#print value

Output:

2000

2

1000

500

250

Explanation:

In the above-given program code two-variable "user_num and x" is declared that inputs the value from the user-end and define a for loop that uses the "j" variable with the range method.

In the loop, it divides the "user_num" value with the "x" value and holds the integer part in the "user_num" variable, and prints its value.  

Assume that an O(log2N) algorithm runs for 10 milliseconds when the input size (N) is 32. What input size makes the algorithm run for 14 milliseconds

Answers

Answer:

An input size of N = 128 makes the algorithm run for 14 milliseconds

Explanation:

O(log2N)

This means that the running time for an algorithm of length N is given by:

[tex]F(N) = c\log_{2}{N}[/tex]

In which C is a constant.

Runs for 10 milliseconds when the input size (N) is 32.

This means that [tex]F(32) = 10[/tex]

So

[tex]F(N) = c\log_{2}{N}[/tex]

[tex]10 = c\log_{2}{32}[/tex]

Since [tex]2^5 = 32, \log_{2}{32} = 5[/tex]

Then

[tex]5c = 10[/tex]

[tex]c = \frac{10}{5}[/tex]

[tex]c = 2[/tex]

Thus:

[tex]F(N) = 2\log_{2}{N}[/tex]

What input size makes the algorithm run for 14 milliseconds

N for which [tex]F(N) = 14[/tex]. So

[tex]F(N) = 2\log_{2}{N}[/tex]

[tex]14 = 2\log_{2}{N}[/tex]

[tex]\log_{2}{N} = 7[/tex]

[tex]2^{\log_{2}{N}} = 2^7[/tex]

[tex]N = 128[/tex]

An input size of N = 128 makes the algorithm run for 14 milliseconds

now now now now mowewweedeeee

Answers

Answer:

15

Inside the type declaration, you specify the maximum length the entry can be. For branch, it would be 15.

I can't seem to type the full "vc(15)" phrase because brainly won't let me.

Your dashboard should show the sum and average as two separate columns. If you use measure names as the column field, what should you use for the marks

Answers

Answer:

Hence the answer is a sum.

Explanation:

Here the statement shows that the dashboard should show the sum and average as two separate columns if we name measure names because the column field then for marks we'll use the sum. Since the sum displays the sum of the values of all the fields, which refers to the marks of the person.

Therefore the answer is a sum.

If we use measure names as the column field, we should use "the sum".

A set of cells that are support equipment on about a similar vertical line, is considered as a column.

Usually, the name of the user or a client represents a field column, while the total and sometimes even averaging columns in our dashboards or screen are different.When using a summation of total summary, perhaps the column field (title), as well as its amount and averaging marking, are indicated.

The preceding reply is thus right.

Learn more:

https://brainly.com/question/17271202

What variable(s) is/are used in stack to keep track the position where a new item to be inserted or an item to be deleted from the stack

Answers

Answer:

Hence the answer is top and peek.

Explanation:

In a stack, we insert and delete an item from the top of the stack. So we use variables top, peek to stay track of the position.

The insertion operation is understood as push and deletion operation is understood as entering stack.

Hence the answer is top and peek.

Data representation and interactivity are important aspects of data visualization.

a. True
b. False

Answers

Answer:

a. True

Explanation:

Data visualization are defined as the representation of the data and information in graphical way. The data visualization tool uses charts, diagrams, graphs, maps, etc. to represent and visualized the information and understand the patter or trend in the data.

It is an effective way to interact with the user and works likes a form of a visual art.

Thus interactivity and data representations are the two important aspect of the data visualization.

Hence, the answer is true.

Large computer programs, such as operating systems, achieve zero defects prior to release. Group of answer choices True False PreviousNext

Answers

Answer:

The answer is "False"

Explanation:

It is put to use Six Sigma had 3.4 defects per million opportunities (DPMO) from the start, allowing for a 1.5-sigma process shift. However, the definition of zero faults is a little hazy. Perhaps the area beyond 3.4 DPMO is referred to by the term "zero faults.", that's why Before being released, large computer programs, such as operating systems, must have no faults the wrong choice.

Write a program that launches 1,000 threads. Each thread adds 1 to a variable sum that initially is 0. You need to pass sum by reference to each thread. In order to pass it by reference, define an Integer wrapper object to hold sum. Run the program with and without synchronization to see its effect. Submit the code of the program and your comments on the execution of the program.

Answers

Answer:

Following are the code to the given question:

import java.util.concurrent.*; //import package

public class Threads //defining a class Threads

{

private Integer s = new Integer(0);//defining Integer class object

public synchronized static void main(String[] args)//defining main method  

{

Threads t = new Threads();//defining threads class object

System.out.println("What is sum ?" + t.s);//print value with message

}

Threads()//defining default constructor

{

ExecutorService exe = Executors.newFixedThreadPool(1000);//defining ExecutorService class object

System.out.println("With SYNCHRONIZATION........");//print message

for(int i = 1; i <= 1000; i++)//defining a for loop

{

exe.execute(new SumTask2());//calling execute method

System.out.println("At Thread " + i +" Sum= " + s + " , ");//print message with value

}

exe.shutdown();//calling shutdown method

while(!exe.isTerminated())//defining while loop that calls isTerminated method

{

}

}

class SumTask2 implements Runnable//calling SumTask2 that inherits Runnable class

{

public synchronized void run()//defining method run

{

int value = s.intValue() + 1;//defining variable value that calls intvalue which is increment by 1

s = new Integer(value);//use s to hold value

}

}

}

Output:

Please find the attached file.

Explanation:

In this code, a Threads class is defined in which an integer class object and the main method is declared that creates the Threads class object and calls its values.

Outside the method, the default constructor is declared that creates the "ExecutorService" and prints its message, and use a for loop that calls execute method which prints its value with the message.

In the class, a while loop is declared that calls "isTerminated" method, and outside the class "SumTask2" that inherits Runnable class and defined the run method and define a variable "value" that calls "intvalue" method which is increment by 1 and define s variable that holds method value.

Other Questions
Please help ASAP!!! Thank you!!! NEED ANSWER QUICK!!Camillo needs 2,400 oz of jelly for the food challenge. If 48 oz of jelly cost $3.84, how much will Camillo spend on jelly? Explain how you can find your answer. VINE BUSCANDO ORO Y ENCONTRE PIEDRAS Simple percent question!!!!My question says that line segment DC is 50% longer than line segment BD, and BD is 40 ft. Does that mean DC is 60 ft or 80? Please explain, brainliest to whoever explains it properly and quickly nimas letter to her brother class 9 what are produced by ovaries Which of the following best represents the accomplishments of Spain's golden century? Help please guys if you dont mind 9. Which property is not important when selecting a material to use as a light bulb filament?dhigh melting pointhigh vapor pressurehigh ductility pls help me with this The 100th term of 8, 8^4, 8^7, 8^10, The diagram shows a cylinder of diameter 6 cm and height 20 cm what is the volume in cm3 The expression 2(a+b)-8.1 for certain values of a and b.find the value of the following expressions for the same values of a and b: 3(a+b) If you could do any job from home, what would do? Why? How do you explain Meiosis? Which one of the following micronutrients is routinely added to TPN? solve: 28 7( 4)(show your work)real answers only pls :( Below are the four common places where you are exposed to everyday. Read and answer the question by writing it on the cloud chart. (15 points) Question: How will you encourage others to cooperate in the given places?plss pahelp po pasahan napo namin bukas bibigyan kita 20 points kapag nasagutan moto ng maayos What is the present value of an investment that will pay $2,000 at the end of the year when interest is compounded annually at 5.10% The area of a smaller circle is one twenty-fifth of the area of a larger circle. What is the ratio of the radius of the larger circle to the radius of the smaller circle?E. 1 : 25F. 5 : 1G. 1 : 5H. None of the above