This problem is based on a "Nifty Assignment" by Steve Wolfman (http://nifty. stanford.edu/2006/wolfman-pretid). Consider lists of numbers from real-life data sources-for example, a list containing the number of students enrolled in different course sections, the number of comments posted for different Facebook status up dates, the number of books in different library holdings, the number of votes per precinct, etc. It might seem like the leading digit of each number in the list could be 1-9 with an equally likely probability. However, Benford's Law states that the leading digit is 1 about 30% of the time and drops with larger digits. The leading digit is 9 only about 5% of the time.
Write a
Want to see the full answer?
Check out a sample textbook solutionChapter 3 Solutions
Absolute Java (6th Edition)
Additional Engineering Textbook Solutions
Java: An Introduction to Problem Solving and Programming (8th Edition)
Starting Out with C++: Early Objects (9th Edition)
Database Concepts (8th Edition)
Introduction to Java Programming and Data Structures, Comprehensive Version (11th Edition)
C How to Program (8th Edition)
Modern Database Management
- Python Question The campus is pretty big. There are n buildings scattered around it, numbered from 0 to n-1. These buildings are so far away from each other that the only way to get from one to another is to take a campus bus. There are m campus bus routes. The i-th one (0 <= i < m) takes you from building u_i to building v_i (but not the other way around). These buses run very frequently. Professor Zingaro is deciding where to hold his CS lectures. He believes a building x is accessible from a building y if you can get from y to x taking at most two buses. For his students’ convenience, he wants to hold his lectures in the most accessible building. Help him out by telling him how many buildings the most accessible building is accessible from. In addition, list all buildings that are the most accessible. Input The first line of the input contains two space-separated integers n and m, denoting the number of buildings and bus routes, respectively. m lines follow. The i-th one…arrow_forwardPersonal project Q5. This question is concerned with the design and analysis of recursive algorithms. You are given a problem statement as shown below. This problem is concerned with performing calculations on a sequence ? of real numbers. Whilst this could be done using a conventional loop-based approach, your answer must be developed using a recursive algorithm. No marks will be given if your answer uses loops. FindAverageAndProduct(a1, ...., an) such that n > 1 Input: A sequence of real values A = (a1, ..., an) Output:, A 2-tuple (average, product) containing the average (average) of all the values and the product (product) of all the values of the elements in A. Your recursive algorithm should use a single recursive structure to find the average and product values, and should not use two separate instances of a recursive design. You should not employ any global variables. (a) Produce a pseudo code design for a recursive algorithm to solve this problem. (b) Draw a call-stack…arrow_forwardWrite a C program for this problem: The partially initialized array "table" can be viewed as a primitive spreadsheet, in which the last column and bottom row have been left blank. Write the code to fill in this row and column with the totals of each column, each row, and the GRAND TOTAL. PS. Don't forget to add comments for every step you make.arrow_forward
- Write a program that prints an mxn matrix whose dimensions are specified by the user. Let the matrix values be random variables. You must use it within the repetition cycle. Example format: Enter dimension of matrix mxn: 2 4 The 2x4 matrix is : 1 2 3 4 5 6 7 8arrow_forwardWrite a C PROGRAM for this problem: The partially initialized array "table" can be viewed as a primitive spreadsheet, in which the last column and bottom row have been left blank. Write the code to fill in this row and column with the totals of each column, each row, and the grand total.arrow_forwardQ2: Ginormous Campus There are n buildings scattered around it, numbered from 0 to n-1. These buildings are so far away from each other that the only way to get from one to another is to take a campus bus. There are m campus bus routes. The i-th one (0 <= i < m) takes you from building u_i to building v_i (but not the other way around). These buses run very frequently. Professor Zingaro is deciding where to hold his CSC108 lectures. He believes a building x is accessible from a building y if you can get from y to x taking at most two buses. For his students’ convenience, he wants to hold his lectures in the most accessible building. Help him out by telling him how many buildings the most accessible building is accessible from. In addition, list all buildings that are the most accessible. Filename Your filename for this question must be q2.py. Input The first line of the input contains two space-separated integers n and m, denoting the number of buildings and bus routes,…arrow_forward
- The implementation of a queue in an array, as given in this chapter, uses the variable count to determine whether the queue is empty or full. You can also use the variable count to return the number of elements in the queue. On the other hand, class linkedQueueType does not use such a variable to keep track of the number of elements in the queue. Redefine the class linkedQueueType by adding the variable count to keep track of the number of elements in the queue. Modify the definitions of the functions addQueue and deleteQueue as necessary. Add the function queueCount to return the number of elements in the queue. Also, write a program to test various operations of the class you defined.arrow_forwardWrite in Javaarrow_forwardPart 4. sum Method Define a method in simpy named sum. Its purpose is to compute and return the sum of all items in the values attribute. You are encouraged to use Python's built-in sum function to assist in the implementation of your sum method. Doing so is illustrative of a pattern called delegation, where the implementation of some algorithm is delegated to existing algorithm. It should take no arguments and return a float. ones = Simpy([1.0, 1.0, 1.0]) print("Actual: ", ones. sum(), Expected: 3.0") one_to_nine = Simpy([]) one_to_nine.arange(1.0, 10.0) print("Actual: ", one_to_nine.sum(), - Expected: 45.0") Pythonarrow_forward
- An n x n matrix that is filled with the numbers 1, 2, 3, ... n² is a magic square if the sum of the elements in each row, each column, and in the two diagonals is the same value. 1 14 15 4 12 7 6 9 8 11 10 5 13 2 3 16 Write a program that reads in 16 values from the keyboard and tests whether they form a magic square when put into a 4 x 4 table. You need to test two features: 1. Does each of the numbers 1, 2, 3, ... 16 occur in the user's input? 2. When the numbers are put into a square, are the sums of the rows, columns, and diagonals equal to each other? Sample output is below. This 4 x 4 is a magic square with the sum of each row, column, and diagonal is 34.arrow_forwardIn this java assignment, we will need to use arraylists so we can store data for an employee. If the user wants to enter data for more than one employee, it should print like this: Employee ListId Name ----------------------- 1. First Name 2. Bob Smith If the user only enters one employee, it should print out a paystub for that employee that would look like this (with overtime coming into play as well, paying an extra 50% beyond 40 hours): ------------------------------- Id - 1 Name - First M. Last Address - 1234 Main St, City, St, Zip Phone - 1234567890 Email - sample@gmail.com Hours worked - 45 Hourly Rate - $10 Regular Pay, 40 hours at $10/hr - $400 Overtime Pay, 5 hours at $15/hr - $75 Gross Total - $475 ------------------------------ Federal tax (20%) - $95 State Tax (5%) - $23.75 Fica Tax (3%) - $14.25 ------------------------------ Net Check - $342 The program should have one class per .java file all calling to a main.java file using getters and setters. Here are the…arrow_forwardIn java, create a program that uses array lists to display either the paystub of one employee or a list of all employees entered. The list of employees would only appear if more than one employee is entered (I.e. if the user chooses to enter an additional employee from the do while). If only one employee is entered, then their paystub would be printed instead.arrow_forward
- C++ Programming: From Problem Analysis to Program...Computer ScienceISBN:9781337102087Author:D. S. MalikPublisher:Cengage Learning