
Database System Concepts
7th Edition
ISBN: 9780078022159
Author: Abraham Silberschatz Professor, Henry F. Korth, S. Sudarshan
Publisher: McGraw-Hill Education
expand_more
expand_more
format_list_bulleted
Concept explainers
Question
![double median()
//Before calculating the median, we must sort the
//array.
//If the array is even...
if (numbers.size() % 2 -- 0)
{
//Get the mid index
int mid - numbers.size()/ 2;
//Get the two numbers in the mid. (mid is the i
ndex of the right most middle number.)
//Get mid ar'd mid - 1
double numl - numbers [mid];
double num2 = numbers [mid - 1];
//Calculate the average of the two middle numbe
rs and return
//the average.
return average_mid;
else
//Determine the median index and return the
//number at the median.
int mid - numbers.size() /2;
return numbers [mid];
}
//Sorts the array in ascending order.
void BubbleSort)
for (int i - 0; i < numbers.size(); i++)
{
bool swapped false;
for (int j - 0; j< numbers.size() - i - 1; j++
{
if (numbers[j] > numbers[j + 1]
swap(numbers[), number
s[j + 11);
swapped - true;
if (swapped -- false)
return;
}
private:
//Used only in Bubble Sort. Ignore...
void swap(double& a, double& b)
{
double temp- a;
a - b;
b - temp;
};
int main)
VCreate a StatSet variable called "s".
//Add the number "55" to the StatSet "s".
//Calculate the median of the numbers.
return 0;
PIC CO](https://content.bartleby.com/qna-images/question/d2291e09-7fcf-4fac-bc31-e34a7ce4842f/c77b4014-f6db-4f30-89a0-752d8cbf3383/8dssxa8_thumbnail.jpeg)
Transcribed Image Text:double median()
//Before calculating the median, we must sort the
//array.
//If the array is even...
if (numbers.size() % 2 -- 0)
{
//Get the mid index
int mid - numbers.size()/ 2;
//Get the two numbers in the mid. (mid is the i
ndex of the right most middle number.)
//Get mid ar'd mid - 1
double numl - numbers [mid];
double num2 = numbers [mid - 1];
//Calculate the average of the two middle numbe
rs and return
//the average.
return average_mid;
else
//Determine the median index and return the
//number at the median.
int mid - numbers.size() /2;
return numbers [mid];
}
//Sorts the array in ascending order.
void BubbleSort)
for (int i - 0; i < numbers.size(); i++)
{
bool swapped false;
for (int j - 0; j< numbers.size() - i - 1; j++
{
if (numbers[j] > numbers[j + 1]
swap(numbers[), number
s[j + 11);
swapped - true;
if (swapped -- false)
return;
}
private:
//Used only in Bubble Sort. Ignore...
void swap(double& a, double& b)
{
double temp- a;
a - b;
b - temp;
};
int main)
VCreate a StatSet variable called "s".
//Add the number "55" to the StatSet "s".
//Calculate the median of the numbers.
return 0;
PIC CO
![#include <iostream>
#include <vector>
using std::cout;
using std::vector;
class StatSet
{
private:
HCreate a vector of doubles that is called "numbers."
public:
//Nothing to do in the constructor.
StatSet()
}
// Add a new number to the set.
vòid add_num(double num)
{
}
double mean()
{
//Sum up the values and return the average.
double sum = 0;
//Write a loop that would iterate through the vector.
sum += numbers[i];
return sum / numbers.size();
}
double median()
//Before calculating the median, we must sort the
//array.](https://content.bartleby.com/qna-images/question/d2291e09-7fcf-4fac-bc31-e34a7ce4842f/c77b4014-f6db-4f30-89a0-752d8cbf3383/z3cnzud_thumbnail.jpeg)
Transcribed Image Text:#include <iostream>
#include <vector>
using std::cout;
using std::vector;
class StatSet
{
private:
HCreate a vector of doubles that is called "numbers."
public:
//Nothing to do in the constructor.
StatSet()
}
// Add a new number to the set.
vòid add_num(double num)
{
}
double mean()
{
//Sum up the values and return the average.
double sum = 0;
//Write a loop that would iterate through the vector.
sum += numbers[i];
return sum / numbers.size();
}
double median()
//Before calculating the median, we must sort the
//array.
Expert Solution

This question has been solved!
Explore an expertly crafted, step-by-step solution for a thorough understanding of key concepts.
Step by stepSolved in 5 steps with 3 images

Knowledge Booster
Learn more about
Need a deep-dive on the concept behind this application? Look no further. Learn more about this topic, computer-science and related others by exploring similar questions and additional content below.Similar questions
- Programming language: Processing from Java Question attached as photo Topic: Use of Patial- Full Arraysarrow_forwardConstruct a row array countValues from 0 to 25, elements incremented by incrementValue. Ex: If incrementValue is 5, countValues should be [0, 5, 10, 15, 20, 25].arrow_forwardWrite the function lastOf which searches the array a for the last occurance of any value contained in the array b. Returns the index if found. If not found, return -1. arrays.cpp 1 #include 2 int last0f(const int a[], int alen, const int b[], int bLen) { 3 4 5 6 7 8 }arrow_forward
arrow_back_ios
arrow_forward_ios
Recommended textbooks for you
- 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

Database System Concepts
Computer Science
ISBN:9780078022159
Author:Abraham Silberschatz Professor, Henry F. Korth, S. Sudarshan
Publisher:McGraw-Hill Education

Starting Out with Python (4th Edition)
Computer Science
ISBN:9780134444321
Author:Tony Gaddis
Publisher:PEARSON

Digital Fundamentals (11th Edition)
Computer Science
ISBN:9780132737968
Author:Thomas L. Floyd
Publisher:PEARSON

C How to Program (8th Edition)
Computer Science
ISBN:9780133976892
Author:Paul J. Deitel, Harvey Deitel
Publisher:PEARSON

Database Systems: Design, Implementation, & Manag...
Computer Science
ISBN:9781337627900
Author:Carlos Coronel, Steven Morris
Publisher:Cengage Learning

Programmable Logic Controllers
Computer Science
ISBN:9780073373843
Author:Frank D. Petruzella
Publisher:McGraw-Hill Education