Topical Information
Use C++. This lab will help you practice with dynamic memory (NOT mixed with classes).
Program Information
One statistic of interest to many researchers is the median of a set of data. The median is the value in the middle. (This is NOT the average, mind you.) Being in the middle, of course implies that the data are in order (sorted). If there are an odd number of data items, the middle is simple to find. If there are an even number of data items, you are supposed to take the average of the two middle values.
You'll need to find the median of a set of data from a file. You don't know how many data are in the file, of course. You'll have to count the data, then read them in to sort, then find the median, and finally print it (the median) out.
Do NOT use any more memory than is necessary!!
Trending nowThis is a popular solution!
Step by stepSolved in 4 steps with 2 images
- ASSEMBLY It is preferable to pass Arrays by reference when calling subroutines. True Falsearrow_forwardBus Loading Problem. You are in charge of filling busses with passengers at a bus terminal. Each bus has space for ten (10) passengers. Four (4) of those spaces can hold only wheelchair passengers, and the other six (6) can hold only non-wheelchair passengers. Busses and both types of passengers arrive at random. As busses arrive, you are to fill them up with passengers. Once a bus is full (containing 6 non-wheelchair, and 4 wheelchair passengers), it is allowed to leave the terminal, along with its passengers. You are responsible only for loading the passengers on the bus and having the bus depart. You do not need to worry about what happens to the busses or passengers after they leave. Each bus process has available to it the functions ArriveAtTerminal(), OpenDoors(), CloseDoors(), and DepartTerminal(). Each passenger process has available to it the functions ArriveAtTerminal() and GetOnBus(). Executing GetOnBus() loads the passenger on the bus, and the function returns when the…arrow_forward3. Number Sorter in Matlab Requirements: ● Must be a console program ● Reads integers from standard input (i.e from the user via the keyboard) until a number less than or equal to zero is input. This indicates the end of input. ● Once end of input is detected, the program sorts all of the numbers in ascending order and displays them ● You can choose any sort algorithms. For instance: ○ choose a random input, n, not yet sorted in the list of input values ○ go through the list of input values and place all values less than n to the left of n and all other values to the right of n ○ Once this is done then n is sorted, so go back and repeat the first step ○ Once all values n are sorted the entire list is sorted ● You are not allowed the built-in function sort in Matlab to solve this problem. * use octave to do this question * write 150 words to explain the program and how it works . .arrow_forward
- Task- Median elements (C Language) Example #4 expected output is 5, but from the program below its coming out to 4. Please help make it come out to 5 as expected Given an array of integer elements, the median is the value that separates the higher half from the lower half of the values. In other words, the median is the central element of a sorted array. Since multiple elements of an input array can be equal to the median, in this task you are asked to compute the number of elements equal to the median in an input array of size N, with N being an odd number. Requirements Name your program project4_median.c. Follow the format of the examples below. The program will read the value of N, then read in the values that compose the array. These values are not necessarily sorted. The program should include the following function. Do not modify the function prototype. int compute_median(int *a, int n); a represents the input array, n is the length of the array. The function returns the…arrow_forwardData Structure Using C++ (Queue) C++ code (NOT JAVA C++ JUST) C++ PROGRAMMING LANGUAGE PLEASE :: We can use a queue to simulate the flow of customers through a check-out line in a store. In this simulation we will have the following details: one check-out line the expected service time for each customer is one minute (However, they may have to wait in line before being serviced) between zero and two customers join the line every minute We can simulate the flow of customers through the line during a time period n minutes long using the following algorithm: Initialize the queue to empty. for ( minute = 0 ; minute < n ; ++minute ) { if the queue is not empty, then remove the customer at the front of the queue. Compute a random number k between 0 and 3. If k is 1, then add one customer to the line. If k is 2, then add two customers to the line. Otherwise (if k is 0 or 3), do not add any customers to the line. } In addition, the algorithm will keep track…arrow_forwardEncrypt The following correspondence between letters and numbers is used in the Caesar cypher. a b c d f h i j k lm n t V W e g 6. u y 0 1 2 3 4 7 8. 9. 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 Encrypt the animal name zebra with the Caesar cypher with a key of 3. What is the encrypted animal name (enter a string of letters with no spaces)? Decrypt An animal name was encrypted with the scheme described in the previous question (it was encoded with the key 3). The encrypted animal name is pduprw .What is the animal name?arrow_forward
- Python only** define the following function: 1. This function must add a task to a checklist, setting its initial value to False. It will accept two parameters: the checklist object to add to, and the task name to add. In addition to adding the task, it must return the (now modified) checklist object that it was given. There is one issue, however: a task cannot be added to a checklist if the name requested is already being used by another task in that checklist. In that case, this function must print a specific message and must return None Define addTask with 2 parameters Use def to define addTask with 2 parameters Use a return statement Within the definition of addTask with 2 parameters, use return _ in at least one place. Do not use any kind of loop Within the definition of addTask with 2 parameters, do not use any kind of loop.arrow_forwardHaskell Programming: Jeff and Elon are discussing about space how will it increase their business. They are planning to make an international space station, We have N asteroids in the space also there has been N-1 pairs asteroids with Links. Each link has a unique assignment of numbers and since Elon is fond of palindromes he wants that the path chooses is such that it is a palindrome. Print YES if it is possible else NO. Input Output 1 4 NO 2653arrow_forwardFunction Implementation with Data Abstraction in C Programming 1. Create a new file and SAVE as MATHV1.H Define and Implement the following functions: int sum(int x, int y); - returns the computed sum of two numbers x and y int diff(int x, int y); - returns the computed difference of two numbers x and y. Make sure that the larger number is deducted by the smaller number to avoid a negative answer long int prod(int x, int y); - returns the computed product of two number x and y float quot(int x, int y); - returns the computed quotient of two numbers x and y. Make sure that the larger number is always the numerator and divided by the smaller number to avoid division by zero error. int mod(int x, int y); - returns the computed remainder of two numbers x and y using the modulo operator %2. Create another new file and save as MYTOOLS.H void center(int row, char str[]); /*centers text across the screen -calculate here for the center col using the formula col=(80-strlen(str))/2; -then use…arrow_forward
- Python Big-O Notation/Time Complexity Pls answer only if u know big-o Thanks! Item #3.arrow_forwardStructural Verification Structural verification is, in this case, validating that a data structure is formed according to its specification. For this lab you are given an essentially arbitrary specification, but you could think of this being used to verify a data structure produced by a program that must have certain properties in order to be used correctly. For example, a list must not be circular, or an image file might require a particular header describing its contents. You must implement this function, which examines a matrix and ensures that it adheres to the following specification: bool verify_matrix(int x, int y, int **matrix); This function accepts an X dimension, a Y dimension, and a matrix of y rows and x columns; although it is declared as int **, this is the same type of matrix as returned by parse_life() in PA1, and you should access it as a two-dimensional array. Note that it is stored in Y-major orientation; that is, matrix ranges from matrix[0][0] to matrix[y 1][x -…arrow_forward
- Database System ConceptsComputer ScienceISBN:9780078022159Author:Abraham Silberschatz Professor, Henry F. Korth, S. SudarshanPublisher:McGraw-Hill EducationStarting Out with Python (4th Edition)Computer ScienceISBN:9780134444321Author:Tony GaddisPublisher:PEARSONDigital Fundamentals (11th Edition)Computer ScienceISBN:9780132737968Author:Thomas L. FloydPublisher:PEARSON
- C How to Program (8th Edition)Computer ScienceISBN:9780133976892Author:Paul J. Deitel, Harvey DeitelPublisher:PEARSONDatabase Systems: Design, Implementation, & Manag...Computer ScienceISBN:9781337627900Author:Carlos Coronel, Steven MorrisPublisher:Cengage LearningProgrammable Logic ControllersComputer ScienceISBN:9780073373843Author:Frank D. PetruzellaPublisher:McGraw-Hill Education