Determine if a number is factor or not

Assignment Help Basic Computer Science
Reference no: EM13996601

Question:The objective ofthis exercise is to implement a multithreaded solution to find if a givennumber is a perfect number.Nis a perfect number if the sum of all its factors, excluding itself, isN;examples are 6 and 28. The input is an integer,N.The output istrue if the number is a perfect number and false otherwise.The main program will read the numbersNandPfrom the command line.The main process will spawn a set ofPthreads. The numbers from 1 toNwill be partitioned among these threads so that twothreads do not work on the name number.For each number in this set, the thread will determine if the number is a factor ofN.Ifitis, it adds the number to a shared buffer that stores factors ofN.The parent process waits till all the threads complete. Use the appropriate synchronization primitive here. Theparent will then determine if the input number is perfect, that is, ifNis a sum of all its factors and then report accordingly.(Note:You can makethe computation faster by restricting the numbers searched from 1 to the square root ofN).

Question:Implement a program to count the frequencyofwords in a text file. Thetext file is partitioned intoNsegments. Each segment is processed by a separate thread that outputs the intermediate frequencycount for its segment. The main process waits until all the threads complete; then it computes the consolidated word-frequencydata based on the individual threads' output.

Reference no: EM13996601

Questions Cloud

Determine the corresponding decimal equivalent and ratio : What was the average number of hospitalized days for this group-correct to one decimal place and what was the daily average-correct to one decimal place - What was the average number performed monthly-correct to the nearest whole number?
Convert pseudocode program into javascript : Use notepad to write a pseudocode program that allows a student to enter a percentage and the number of absences and then displays the display the grade and explanation if an adjustments were made. Save the file as gradeReporter.txt .... Also conv..
What is the velocity of the wave in the beam : A student strikes a metal rail (L = 22 m) at one end and uses a piezoelectric gauge at the other end to determine that the beam produces a λ= 2 kHz sound wave that takes t = 0.0071 s to reach the end of the beam within the metal. Input an expressio..
Explain how sex offenders need to be treated : State the issues that are associated with offenders who have tuberculosis, Hepatitis C, and HIV/AIDS. Explain how sex offenders need to be treated and supervised differently than other offenders. Describe how DWI/DUI offenders strain the corrections ..
Determine if a number is factor or not : Implement a program to count the frequencyofwords in a text file. Thetext file is partitioned intoNsegments. Each segment is processed by a separate thread that outputs the intermediate frequencycount for its segment. The main process waits until ..
What is the amplitude of oscillation of the mass : A student is studying a 100.0g mass oscillating on a horizontal spring of spring constant k=18N/m. At t=0, the object was at rest and its position was x= 2.55cm from its equilibrium position. What is the amplitude of oscillation of the mass?
What are the magnitudes of the momenta of the photons : Explain why the electron and positron cannot annihilate to become a single photon. What are the magnitudes of the momenta of the photons?
Determine the magnitude of the balloon initial velocity : The target is located a horizontal distance d = 7.5 m from the student's feet. Assume that the balloon moves without air resistance. Use a Cartesian coordinate system with the origin at the balloon's initial position. What is the position vector,..
Is commodities liable to e-products under the sales : Is Commodities liable to E-Products under the sales contract for the computers, printers and scanners? Why or why not? Is Brenda personally liable to E-Products to pay for the computers, printers and scanners? Why or why not

Reviews

Write a Review

 

Basic Computer Science Questions & Answers

  How will sensitive information be handled

How will sensitive information be handled?

  Underlying array structure

Ef?ciently implement a queue class using a circular array. You may use a vector (rather than a primitive array) as the underlying array structure.

  Explain radio frequency identification technology

Write discussion of radio frequency identification (RFID) technology and Information Technology Infrastructure Library (ITIL) standards.

  Research a writing guide for forensics organization

Your manager has asked you to research and recommend a writing guide that examiners in your computer forensics organization will use for all official written reports.

  Creating a file reader

The program begins by creating a File Reader object and a BufferedReader object to read the file terms.txt.

  What are some uses for wrapper classes

Wrapper classes are classes that surround primitive types with additional functionality. What are some uses for wrapper classes? Show some examples of how they could be used.

  Complement in tcp and udp connections

UDP and TCP use the 1s complement for their check sums. Suppose you have the following three 8-bit bytes: 10011001, 01010010, and 01011001.

  Show how the hodgkin-huxley fast subsystem depends

Show how the Hodgkin-Huxley fast subsystem depends on the slow variables: i.e., show how the nullcline moves as and are changed, and demonstrate the saddle-node bifurcation in which and disappear.

  Write a program that contains a main function

Write a program that contains a main function and three other functions that will return various attribute information about an array of floating point numbers:

  Which of the following runs as a dedicated server only

Which of the following runs as a dedicated server only?

  What is the purpose of a cross join in mdx

Question 8 Given the range of reporting and data extraction tools, when does it make sense to use OLAP? What would you consider the main selling points of OLAP technology? When would OLAP not be a good choice?

  Determine features of ram to include in web server

Determine the features and capacities (RAM, disk storage, processor speed) that Amy should include in the Web server computer that she will need for her site.

Free Assignment Quote

Assured A++ Grade

Get guaranteed satisfaction & time on delivery in every assignment order you paid with us! We ensure premium quality solution document along with free turntin report!

All rights reserved! Copyrights ©2019-2020 ExpertsMind IT Educational Pvt Ltd