Computers and Technology
Implement a binary search function in three substantially different programming languages. In each program (identical, except for the programming language), carry out the same 10,000,000 unsuccessful searches for eight different-sized arrays, namely arrays of sizes 128, 512, 2048, 8192, 32768, 131072, 524288, and 2,097,152. Measure in each of the three programs the time it takes to do the 10,000,000 searches for each of the eight arrays. Compare these timings to the theoretical timings the algorithm binary search provides. Are there differences between the three programs? Explain your timings and observations!!
Assignment Create an HTML form that will accept four fields: pet name, pet ID, pet weight, and birthdate. Name this file petInfo.html. There should be a submit and reset button on your html form. Your input fields for your form should be inside of a table. The submit button should send the data to a php file named updateInfo.php. The updateInfo.php file should check the data submitted by the html file for proper formatting. While it is allowable that you may check input on the client side (either HTML or Javascript), you MUST check for valid input on the server using PHP. ***IMPORTANT*** Your POST variables in your HTML file must be labeled as follows. I have written an automated script to run tests on your code, and it depends on the POST variables being labeled correctly within the HTML Form. 1) "pet_name" 2) "pet_id" 3) "pet_weight" 4) "birth_date" The following rules must be enforced by your PHP script about the input. No field is allowed to be blank. Maximum length of pet name is 20 characters. Pet ID must be 4 lowercase letters followed by 3 numbers. Example: abcd123 Max length of pet weight is 7 characters. Max of two digits after decimal point. Must be a positive value. Range: 0.00 9999.99. The name should be only made up of alphabetical characters. (no numbers or symbols). Birthdate should be in the format 1/1/2002. Examples of valid input: 01/01/2002, 12/1/1999, 12/25/2015. Do not allow: 12/25/02 (The whole year should appear in the input).If all the fields are valid, your PHP script should save the data into a file named petInfo.txt which should have the following format, and be sorted by "pet_name". Put each record on its own line. To simplify things, you can assume that Names are unique - i.e. you can use the name as a key for your associative array. (I won't use two of the same name when I test your code). PetName, PetID, PetWeight, PetBirthDate\n Once the new data has been received, you should also display ALL data that has been entered into the text file from your PHP script into an HTML table. The table should be sorted by last name just like the text file. After successfully displaying your table, create a link back to the petInfo.html page.
Create a function min_mid_max which takes a list as its formal parameter and returns a new list with the following characteristics: element 0 contains the minimum value element 1 contains the middle value (not the median -- which would require an average if the list had an even number of elements). If the list is even (e.g. [1,2,3,4]) the 'middle' value will be the right value of the two possible choices (e.g. 3 rather than 2). element 2 contains the maximum value Notes: You can only use Python syntax shown so far (even if you know more) You cannot use any math library (we have yet to see this) You should use the function sorted. Remember the function sorted does not change its input, it returns a new list. You should only need to call sorted one time. print(sorted(3,2,1])) You can use the function int (another built in function) to help determine the index of the middle value. This function takes a floating point (or any kind of number) and converts it into an integer (e.g.print(int(4.32)). This will allow you to treat lists with an even number of elements the same as a list with a odd number of elements. If min_mid_max is called with an empty list, return an empty list. If min_mid_max is called with 1 item that item is the min, mid, and the max If min_mid_max is called with 2 items, the mid and the max should be the same No need to worry about the incoming list being the value None
We are designing a program that must do the following:Read 3 integers from a file called "data.txt"Sum the integersCompute the mean of the integersOutput the mean to a file called "mean.txt".We are required to select functions from the library provided below to complete our program. Inside of the main () function, fill in the correct C statements to satisfy the four requirements listed above. You must fill in all the lines labeled with "statement x", where x is 2, 3, 4, 5, or 6. The first statement has been completed for you.// These are the library functions that we must invoke!// Precondition: The input file must already be open.int read_integer (FILE *infile){ int number = 0; fscanf (infile, "%d", &number); return number;}int calculate_sum (int number1, int number2, int number3){ int sum = 0; sum = number1 + number2 + number3; return sum;}double calculate_mean (int sum, int number){ double mean = 0.0; mean = ((double) sum) / number; return mean;}// Precondition: The input file must already be open.void print_double (FILE *outfile, double number){ fprintf (outfile, "%0.2lf\n", number);}// Fill in the appropriate statements for main ().#include int main (void){ int n1 = 0, n2 = 0, n3 = 0, sum = 0; double average = 0.0; FILE *infile = NULL, *outfile = NULL; // We will not check to see if files were opened successfully; assume they are infile = fopen ("data.txt", "r"); outfile = fopen ("mean.txt", "w"); ______n1 = read_integer (infile)_________________________ // statement 1 _________________________________________________________ // statement 2 (2 pts) _________________________________________________________ // statement 3 (2pts) _________________________________________________________ // statement 4 (2 pts) _________________________________________________________ // statement 5 (2 pts) _________________________________________________________ // statement 6 (2pts) fclose (infile); fclose (outfile); return 0; }