884 Words2 Pages

Class Notes: Data Structures and Algorithms

Summer-C Semester 1999 - M WRF 2nd Period CSE/E119, Section 7344

Homework #2 -- Due Fri 28 May 1999 : 09.30am

* Question 1. Assume that an n-element array (vector) a contains distinct integers arranged in no particular order. Write an algorithm to find the value and location of (a) the mean of a and (b) the value v in a closest to the mean. Note: If v equals the mean, then v is the value closest to the mean.

Example. If a = (1,2,3,5,4,6,7,9), then the mean equals 37/8 = 4.625. The value 5, which is in the fourth location (i = 4), happens to be the value closest to the mean.

Answer:

FindMean(a : array [1..n] of int):

{ sum = 0; posmean = -1, posclose = -1

for i = 1 to n do:

sum = sum + a[i]

endfor

mean = float(sum) / n

mdif = 9E13

for i = 1 to n do:

dif = abs(a[i] - mean)

if (dif < mdif) then

if (dif = 0) then

Related

## Nt1330 Unit 3 Exercise 1

441 Words | 1 Pages1. Signed Business Associate Agreement – This is to cover yourself, as well as to experience peace of mind. You want your host to understand and accept the risks of hosting patient health information.

## Pt1420 Unit 4 Assignment

378 Words | 1 PagesI have four quiz scores: 94, 93, 85, and 0. what is the mean (average) of my quiz scores? Would you code this as a factor or a numeric value in R?

## Cs3306 Unit 1 Research Paper

662 Words | 2 PagesThe graph in figure 16.18 does not have any cycles and therefore it is not in a deadlock state. However, connecting T28 to T27 will create a cycle and thus a deadlock state. Each transaction (T26, T27 and T28) will now be dependent each other because one transaction will have a lock on sources that will be needed by the next transaction and so on. Deadlocks should be prevented. Mechanisms should be put in place to detect deadlocks and to correct them as soon as

## Differences in Absentees in the Workplace between Smokers and Non-smokers

807 Words | 2 PagesFor this statistical inference, the question was whether the means were truly different or could they have been samples from the same population. To do draw a conclusion, we must first assume normal distribution. We must also set the null hypothesis to m1 - m2 = 0. And per this assignment we must set the a-level at .05 and the hypothesis alternative to m1 - m2 ¹ 0; thus requiring a two-tailed test.

## Pt1420 Unit 5 Assignment

1787 Words | 4 PagesSo, for figure 5 which is the means plot, we use the means plots to see if our mean will be different with the groups of data. Because when we are ale to see the visual interpretation of this section, we will come to the following conclusions, which we can the mean scores for the section that is higher than our mean scores for the section 2 and 3.

## Live Born Singletons Case Study

3402 Words | 7 PagesThis method is used since it is the most appropriate for calculating the mean and the standard deviation of a grouped data.

## Psy 315 Week 3 Assignment

485 Words | 1 PagesThe first thing that was decided upon was to find the Mean, Median, and Mode. Using a calculator they were able to obtain the exact numbers.

## Paul Revere Biography

706 Words | 2 Pages...will fall within the first standard deviation, 95% within the first two standard deviations, and 99.7% will fall within the first three standard deviations of the mean. The Empirical Rule is used in statistics for showing final outcomes. After a standard deviation is found, and before exact data can be collected, this rule can be used as an estimate to the outcome of the new data. This probability can be used for gathering data that may be time consuming, or even impossible to found. When the mean equals the median and the values cluster around the mean and median, producing a bell-shaped distribution, then we can use the empirical rule to examine the variability. In this bell-shaped data set, we can calculate the mean and the standard deviation. The mean means the average value of the set of data. The standard deviation means the average scatter around the mean.

## Investigating the Relationship Between Foot Size and Height

1850 Words | 4 Pagescloser the line of best fit is to 1; the more evidence there is to

## The Doum Tree Analysis

176 Words | 1 PagesNear the end of the narrative, the people were still fighting to ensure the safety of their distinct tree. They were skeptical of what governmental scheme they would endure next. At the end of the story, during a conversation between two men, one asked "When will they set up the water pump?" to which the other man replied "When people go to sleep and don't see the doum tree in their dreams."(pg 824) paragraph 3). He also said that cutting down the doom tree is not needed, that "What all these people have overlooked is that there's plenty of room for all these things: the doom tree, the tomb, the water-pump, and the steamer's stopping-place." (Pg 824 paragraph 5) Just as villagers found meaning by having the doum tree in their community, people

## Basic Data Structures and Algorithms Homework Exercises

2324 Words | 5 Pages* (less than 10 pages, less than 20 pages, or more than 20 pages). You may assume that the

## Psychological Analysis Of Machiavellianism And Narcissism

757 Words | 2 PagesBased on the total means, the values of A and B were computed from the total means and standard deviations from each trait group.

## Cluster Analysis: Clustering Methods

722 Words | 2 PagesCentroid Method: Calculates the distance between two clusters as the total of distances between their means for all of the variables. (J. Norušis, 2012)

## Discrete Mathematics Algorithm

969 Words | 2 PagesAlgorithm is a part of discrete mathematics and very useful for the computer science. An algorithm is the ability to carry out the correct steps in the correct order and should always be considered in the context of the certain assumptions. Algorithms of arithmetic, operate with integers which they depend on a digit integer. That was the definition of an algorithm in numerical situation. The connection with the computing science is that in nowadays the algorithms are designed to be used by a machine. So algorithms can be expressed in more languages like natural language , Java, C++. The computer solves a problem by way of a computer program, which as it is mentioned above is a list of orders giving detailed instructions about the action of the computer. Algo...

## Computer Programming Assignment

1067 Words | 3 PagesFirst of all I had no much computer programming skill from the past , but I do have some short-term programming courses completion. of course the basic idea from the past about python language programming is a big deal to me to prepared myself early for this class. Otherwise not easy to find out exactly what is going on around computer language program; programming a computer is not so simple and controlled within a short period of time, computer programming is need big time and a lot of effort.

### Nt1330 Unit 3 Exercise 1

441 Words | 1 Pages### Pt1420 Unit 4 Assignment

378 Words | 1 Pages### Cs3306 Unit 1 Research Paper

662 Words | 2 Pages### Differences in Absentees in the Workplace between Smokers and Non-smokers

807 Words | 2 Pages### Pt1420 Unit 5 Assignment

1787 Words | 4 Pages### Live Born Singletons Case Study

3402 Words | 7 Pages### Psy 315 Week 3 Assignment

485 Words | 1 Pages### Paul Revere Biography

706 Words | 2 Pages### Investigating the Relationship Between Foot Size and Height

1850 Words | 4 Pages### The Doum Tree Analysis

176 Words | 1 Pages### Basic Data Structures and Algorithms Homework Exercises

2324 Words | 5 Pages### Psychological Analysis Of Machiavellianism And Narcissism

757 Words | 2 Pages### Cluster Analysis: Clustering Methods

722 Words | 2 Pages### Discrete Mathematics Algorithm

969 Words | 2 Pages### Computer Programming Assignment

1067 Words | 3 Pages