
Write an application that simulates coin tossing. Let the

Want to see the full answer?
Check out a sample textbook solution
Chapter 6 Solutions
Java How to Program, Early Objects (11th Edition) (Deitel: How to Program)
Additional Engineering Textbook Solutions
Concepts Of Programming Languages
Computer Science: An Overview (13th Edition) (What's New in Computer Science)
Thinking Like an Engineer: An Active Learning Approach (4th Edition)
Java: An Introduction to Problem Solving and Programming (8th Edition)
Introduction To Programming Using Visual Basic (11th Edition)
Web Development and Design Foundations with HTML5 (8th Edition)
- Average case complexity Consider this function: def put (1st, first, last, value): i = last while i last = i first and value < 1st [i]: last = last i-i-1 - 1 1st [last] value return 1st Assume 1st is a list of integers, value is an integer, and first <= last are nat- ural numbers. For the purpose of our computations, we will define n-last-first+1 (the size of 1st). Also, assume the elements of 1st are almost sorted, in the sense that the probability that each element of the array has a probability of being out of order with a distance m units from its correct place m, 0 ≤m ≤ n − 1, is propor- tional with, that is this probability equals 1. In order to determine c, keep in mind that all involved probabilities sum to 1. Additionally, you may use the formula Inn (which is true for large n) to determine the value of c. Once you have determined the value of c, compute the average runtime of the function put and determine its complexity class. m+1arrow_forwardHelp me with number 5 and 6arrow_forwardCorrectness of recursive functions Here is code for a recursive function that finds the minimum element of a list. def rec_min (A): if len(A) == 1: return A [0] else: m = len (A) // 2 min1 = rec_min (A[O..m-1]) min2 = rec_min (A [m..len (A)-1]) return min (min1, min2) State preconditions and postconditions for this function. Then, prove that this algorithm is correct according to your specifications.arrow_forward
- Use a loop invariant as a debugging tool Consider this alogrithm: Precondition: nЄ N. Postcondition: The returned value equals n(n + 1). Invariant: ri(i + 1)^i≤n+2 Variant: n-i +1 def f(n): r, i = 0,0 while i < n+2: i = 1+1 r = r+2*i return r Its implementation, however is buggy. In order to find the bug, you are required to attempt a proof of correctness of this algorithm using the provided invariant and variant. Please follow the process of the proof as instructed in class, and eventually you will get to a point where the proof breaks down, revealing the bug. Identify the bug. You do not actually need to write a corrected code, also you do not need to complete the proof after identifying the bug. All is required is to do, is to identify the bug, while presenting a proof of correcteness.arrow_forwardcan you please help me with number 5 and 6arrow_forwardIN C++ you will simulate a simple multithreading application with a “producer and consumer” problem Modify “Producer and Consumer Problem” from the lecture note so that it can use all buffer space, not “buffersize – 1” as in the lecture note. This program should work as follows: 1. The user will run the program and will enter two numbers on the command line.Those numbers will be used for buffersize and counter limit.2. The main program will then create separate producer and consumer threads.3. The Producer thread generates a random number through a random number generator function, inserts it into the buffer, prints the number, and increment counter.4. The Consumer thread goes to the buffer, takes a number in the proper order, prints it out, and increment counter.5. After the counter reaches its limit, both threads should be terminated and returned to the main.6. Main program terminates. program and sample run should clearly show the implementation of subtasks through…arrow_forward
- IN C++ you will simulate a simple multithreading application with a “producer and consumer” problem Modify “Producer and Consumer Problem” from the lecture note so that it can use all buffer space, not “buffersize – 1” as in the lecture note. This program should work as follows: 1. The user will run the program and will enter two numbers on the command line.Those numbers will be used for buffersize and counter limit.2. The main program will then create separate producer and consumer threads.3. The Producer thread generates a random number through a random number generator function, inserts it into the buffer, prints the number, and increment counter.4. The Consumer thread goes to the buffer, takes a number in the proper order, prints it out, and increment counter.5. After the counter reaches its limit, both threads should be terminated and returned to the main.6. Main program terminates. program and sample run should clearly show the implementation of subtasks through…arrow_forwardIN C++ you will simulate a simple multithreading application with a “producer and consumer” problem Modify “Producer and Consumer Problem” from the lecture note so that it can use all buffer space, not “buffersize – 1” as in the lecture note. This program should work as follows: 1. The user will run the program and will enter two numbers on the command line.Those numbers will be used for buffersize and counter limit.2. The main program will then create separate producer and consumer threads.3. The Producer thread generates a random number through a random number generator function, inserts it into the buffer, prints the number, and increment counter.4. The Consumer thread goes to the buffer, takes a number in the proper order, prints it out, and increment counter.5. After the counter reaches its limit, both threads should be terminated and returned to the main.6. Main program terminates.arrow_forwardConsider the following relations: Professor (profid: integer, name: varchar, salary: integer, age: integer, depid: integer)Department (did: integer, budget: integer, location: varchar, mgr eid: integer) Salaries range from $30,000 to $100,000, ages vary from 20 to 80, each department has about 20 employees on average, there are 10 locations, and budgets vary from $100,000 to $1 million. You can assume uniform distributions of values. For each of the following queries, what index would you choose to speed up the query? If your database system does not consider index-only plans (i.e., data records are always retrieved even if enough information is available in the index entry), how would your answer change? Query1: Print name, age, and salary for all professors. Query2: Find the dids of departments that are located in Edmonton and have a budget of more than $150,000.arrow_forward
- Does the final structure of a B+ tree depend on the order in which the terms are added to it? Answer using an illustration example.arrow_forwardHigh Incidence of Pressure Injuries Due to Delayed Risk Identification: The unit currently relies on manual assessments and paper-based documentation to identify patients at risk of pressure injuries. This often leads to delayed interventions, increasing patient discomfort, length of stay, and costs. An electronic risk assessment and monitoring system could enable earlier identification and timely preventive care. Draw swim lane diagrams with textual descriptions to identify the primary participants and key activities in the business process. The purpose is to capture just the primary steps in the process and who is involved. Note: Please I woud like you to generate a downloadable version or editable Word version of swimlane diagram.arrow_forwardHigh Incidence of Pressure Injuries Due to Delayed Risk Identification: The unit currently relies on manual assessments and paper-based documentation to identify patients at risk of pressure injuries. This often leads to delayed interventions, increasing patient discomfort, length of stay, and costs. An electronic risk assessment and monitoring system could enable earlier identification and timely preventive care. Draw swim lane diagrams with textual descriptions to identify the primary participants and key activities in the business process. The purpose is to capture just the primary steps in the process and who is involved.arrow_forward
- EBK JAVA PROGRAMMINGComputer ScienceISBN:9781337671385Author:FARRELLPublisher:CENGAGE LEARNING - CONSIGNMENTC++ Programming: From Problem Analysis to Program...Computer ScienceISBN:9781337102087Author:D. S. MalikPublisher:Cengage LearningC++ for Engineers and ScientistsComputer ScienceISBN:9781133187844Author:Bronson, Gary J.Publisher:Course Technology Ptr
- Programming Logic & Design ComprehensiveComputer ScienceISBN:9781337669405Author:FARRELLPublisher:CengageMicrosoft Visual C#Computer ScienceISBN:9781337102100Author:Joyce, Farrell.Publisher:Cengage Learning,EBK JAVA PROGRAMMINGComputer ScienceISBN:9781305480537Author:FARRELLPublisher:CENGAGE LEARNING - CONSIGNMENT




