/**
* @author Jane Programmer
* @cwid 123 45 678
* @class COSC 2336, Spring 2019
* @ide Visual Studio Community 2017
* @date January 12, 2019
* @assg Assignment 04
*
* @description Assignment 04 Practice defining recursive functions. We
* implement factorial and counting combinations functions using the
* binomial coefficient in this assignment. This file containts unit
* tests of the required functions for this assignment.
*/
#include <iostream>
#include <cassert>
#include <chrono> // measure elapsed time of functions using high resolution clock
#include "BinomialFunctions.hpp"
using namespace std;
/** main
* The main entry point for this program. Execution of this program
* will begin with this main function.
*
* @param argc The command line argument count which is the number of
* command line arguments provided by user when they started
* the program.
* @param argv The command line arguments, an array of character
* arrays.
*
* @returns An int value indicating program exit status. Usually 0
* is returned to indicate normal exit and a non-zero value
* is returned to indicate an error condition.
*/
int main(int argc, char** argv)
{
// test iterative version of factorial
cout << "Testing iterative version factorialIterative() " << endl;
cout << "-------------------------------------------------------------" << endl;
bigint res;
//res = factorialIterative(0);
//cout << "Test base case: factorialIterative(0) = " << res << endl;
//assert(res == 1);
//res = factorialIterative(1);
//cout << "Test edge case: factorialIterative(1) = " << res << endl;
//assert(res == 1);
//res = factorialIterative(-1);
//cout << "Test error case: factorialIterative(-1) = " << res << endl;
//assert(res == 1);
//res = factorialIterative(10);
//cout << "Test general case: factorialIterative(10) = " << res << endl;
//assert(res == 3628800);
//res = factorialIterative(12);
//cout << "Test general case (largest 32 bit int): factorialIterative(12) = " << res << endl;
//assert(res == 479001600);
//res = factorialIterative(20);
//cout << "Test general case (largest 64 bit int): factorialIterative(20) = " << res << endl;
//assert(res == 2432902008176640000);
// timing test for factorialIterative, do it 10000 times and see how much time
// elapses
// https://www.pluralsight.com/blog/software-development/how-to-measure-execution-time-intervals-in-c--
const int NUM_TIMING_LOOPS = 10000;
//auto start = chrono::high_resolution_clock::now();
//for (int testnum = 0; testnum < NUM_TIMING_LOOPS; testnum++)
//{
// res = factorialIterative(20);
//}
//auto finish = chrono::high_resolution_clock::now();
//chrono::duration<double> elapsed = finish - start;
//cout << "Elapsed time " << NUM_TIMING_LOOPS << " loops of factorialIterative(20) "
// << elapsed.count() << endl;
// test recursive version of factorial
cout << endl;
co.
#define ENABLE_COMMANDER
#define ENABLE_REPORTER
#include <cctype> // for toupper()
#include <cstdlib> // for EXIT_SUCCESS and EXIT_FAILURE
#include <cstring> // for strerror()
#include <cerrno> // for errno
#include <deque> // for deque (used for ready and blocked queues)
#include <fstream> // for ifstream (used for reading simulated process programs)
#include <iostream> // for cout, endl, and cin
#include <sstream> // for stringstream (for parsing simulated process programs)
#include <sys/wait.h> // for wait()
#include <unistd.h> // for pipe(), read(), write(), close(), fork(), and _exit()
#include <vector> // for vector (used for PCB table)
using namespace std;
class Instruction {
public:
char operation;
int intArg;
string stringArg;
};
class Cpu {
public:
vector<Instruction> *pProgram;
int programCounter;
int value;
int timeSlice;
int timeSliceUsed;
};
enum State {
STATE_READY,
STATE_RUNNING,
STATE_BLOCKED,
STATE_END
};
class PcbEntry {
public:
int processId;
int parentProcessId;
vector<Instruction> program;
unsigned int programCounter;
int value;
unsigned int priority;
State state;
unsigned int startTime;
unsigned int timeUsed;
};
// The number of valid priorities.
#define NUM_PRIORITIES 4
// An array that maps priorities to their allotted time slices.
static const unsigned int PRIORITY_TIME_SLICES[NUM_PRIORITIES] = {
1,
2,
4,
8
};
unsigned int timestamp = 0;
Cpu cpu;
// For the states below, -1 indicates empty (since it is an invalid index).
int runningState = -1; // The index of the running process in the PCB table.
// readyStates is an array of queues. Each queue holds PCB indices for ready processes
// of a particular priority.
deque<int> readyStates[NUM_PRIORITIES];
deque<int> blockedState; // A queue fo PCB indices for blocked processes.
deque<int> deadState;
// In this implementation, we'll never explicitly clear PCB entries and the
// index in the table will always be the process ID. These choices waste memory,
// but since this program is just a simulation it the easiest approach.
// Additionally, debugging is simpler since table slots and process IDs are
// never re-used.
vector<PcbEntry *> pcbTable;
double cumulativeTimeDiff = 0;
int numTerminatedProcesses = 0;
// Sadly, C++ has no built-in way to trim strings:
string &trim(string &argument)
{
string whitespace(" \t\n\v\f\r");
size_t found = argument.find_last_not_of(whitespace);
if (found != string::npos) {
argument.erase(found + 1);
argument.erase(0, argument.find_first_not_of(whitespace));
} else {
argument.clear(); // all whitespace
}
return argument;
}
bool createProgram(const string &filename, vector<Instruction> &program)
{
ifstream file;
int lineNum = 0;
program.clear();
file.open(filename.c_str());
if (!file.is_open()) {
cout << "Error opening file " << filename << ...
The document provides information on control structures in C++ including relational operators, loops, and decisions. It discusses relational operators like ==, <, > that compare values and return true or false. It describes the three types of loops in C++ - for, while, and do-while loops. The for loop executes a fixed number of times based on initialization, test, and increment expressions. The while loop repeats while a test condition is true. The do-while loop executes the body at least once and then repeats while the test condition is true. The document also covers the if statement for simple conditions and if-else for alternative paths, and provides code examples to demonstrate each control structure.
C++ code only(Retrieve of Malik D., 2015, p. 742) Programming Exer.pdfandreaplotner1
The document describes classes for integer manipulation and prime factorization. It defines member functions to perform operations on integers such as counting digits, reversing digits, splitting integers into blocks, determining primality, and finding prime factorization. It also provides code for driver programs that test the classes and allow the user to select operations via a menu. The full solution includes implementing the remaining member functions, adding constructors/destructors, overloading operators, and separating class specifications from implementation code.
The document discusses various operators in C++ including assignment operators, increment and decrement operators, logical operators, and the common mistake of confusing the equality operator (==) and the assignment operator (=).
It provides examples of how to use assignment operator abbreviations, preincrement and postincrement operators, logical operators like AND (&&), OR (||), and NOT (!) in conditions. It also demonstrates the different repetition structures like while, for, and do-while loops. Finally, it cautions about accidentally using the assignment operator instead of equality operator in conditions.
This document contains code snippets from a student's practical work using Microsoft Visual Studio C++. It includes 15 code modules that demonstrate basics of C++ programming like input/output, data types, operators, conditional statements and functions. The modules progress from simple print statements to more complex concepts like nested if-else statements and switch cases. Each module is preceded by comments identifying the topic and module number.
#ifndef RATIONAL_H if this compiler macro is not defined #def.pdfexxonzone
#ifndef RATIONAL_H // if this compiler macro is not defined
#define RATIONAL_H // then define it so this file will not be processed again
#include \"stdafx.h\" // use only for Microsoft Visual Studio C++
#include
using namespace std;
class Rational
{
// Friend functions are actually declared outside the scope of the
// class but have the right to access public and private data and
// member function members that belong to the class. The friend
// function below gives the << operator for ostreams (including cout)
// the ability to output a Rational object by accessing its member data.
friend ostream &operator<< (ostream &out, Rational const &r);
public:
Rational(int num = 0, int denom = 1); // also provides default constructor
Rational add(Rational right);
Rational operator+ (Rational right); // + addition operator
Rational operator+= (Rational right); // += addition assignment operator
Rational operator- (Rational right); // + addition operator
Rational operator-= (Rational right); // += addition assignment operator
void display();
operator double() const; // convert Rational to double
private:
int numerator;
int denominator;
// helper functions are private and not accessible by the main program
int LCD(int v1, int v2);
Rational setRational(int n, int d);
};
#endif
#include \"stdafx.h\"
#include
#include \"Rational.h\"
using namespace std;
// By using the default parameter settings in Rational.h, this
// constructor also provides the default constructor Rational()
Rational::Rational(int num, int denom)
{
setRational(num, denom); // set numerator and denominator, reduce fraction, fix the sign
}
// Helper function to fix a zero denominator and fix the sign if denominator is negative
Rational Rational::setRational(int n, int d) // helper function
{
numerator = n;
denominator = d;
// if denominator == 0 then set it = 1
if (denominator == 0)
denominator = 1;
if (denominator < 0) // if denominator is neg, multiply num and denom by -1
{
numerator = -numerator; // fix sign of numerator +/-
denominator = -denominator; // denominator always +
}
int lcd = LCD(numerator, denominator);
if (denominator != 0)
{
numerator /= lcd;
denominator /= lcd;
}
return *this; // return the current object
}
// find the lowest common divisor using a recursive function
int Rational::LCD(int v1, int v2)
{
if (v2 == 0) return v1;
else return LCD(v2, v1%v2);
}
Rational Rational::add(Rational right)
{
int newNumerator;
int newDenominator;
newNumerator = numerator*right.denominator + right.numerator*denominator;
newDenominator = denominator * right.denominator;
// create a new Rational object and return it
return setRational(newNumerator, newDenominator);
}
// the operator+ method does the same thing as the add method
Rational Rational::operator+ (Rational right)
{
int newNumerator;
int newDenominator;
newNumerator = numerator*right.denominator + right.numerator*denominator;
newDenominator = denominator * right.denominator;
// create a new Rational object and return it
return .
The document provides an introduction and overview of conditions and loops in C++ programming. It covers arithmetic operations, relational expressions, if/else statements, while loops, do-while loops, and for loops. Examples are given for each concept to demonstrate their syntax and usage. Key topics covered include operators, increment/decrement, if/elseif statements, comparing values, and using loops to repeat blocks of code multiple times.
Control structures in C++ include loops like while, do/while and for to repeat actions. Switch, break and continue statements are also covered. The document discusses counter-controlled and sentinel-controlled repetition, and provides examples of calculating a class average using different loop structures. Nested control structures are demonstrated with an example analyzing exam results from 10 students.
#define ENABLE_COMMANDER
#define ENABLE_REPORTER
#include <cctype> // for toupper()
#include <cstdlib> // for EXIT_SUCCESS and EXIT_FAILURE
#include <cstring> // for strerror()
#include <cerrno> // for errno
#include <deque> // for deque (used for ready and blocked queues)
#include <fstream> // for ifstream (used for reading simulated process programs)
#include <iostream> // for cout, endl, and cin
#include <sstream> // for stringstream (for parsing simulated process programs)
#include <sys/wait.h> // for wait()
#include <unistd.h> // for pipe(), read(), write(), close(), fork(), and _exit()
#include <vector> // for vector (used for PCB table)
using namespace std;
class Instruction {
public:
char operation;
int intArg;
string stringArg;
};
class Cpu {
public:
vector<Instruction> *pProgram;
int programCounter;
int value;
int timeSlice;
int timeSliceUsed;
};
enum State {
STATE_READY,
STATE_RUNNING,
STATE_BLOCKED,
STATE_END
};
class PcbEntry {
public:
int processId;
int parentProcessId;
vector<Instruction> program;
unsigned int programCounter;
int value;
unsigned int priority;
State state;
unsigned int startTime;
unsigned int timeUsed;
};
// The number of valid priorities.
#define NUM_PRIORITIES 4
// An array that maps priorities to their allotted time slices.
static const unsigned int PRIORITY_TIME_SLICES[NUM_PRIORITIES] = {
1,
2,
4,
8
};
unsigned int timestamp = 0;
Cpu cpu;
// For the states below, -1 indicates empty (since it is an invalid index).
int runningState = -1; // The index of the running process in the PCB table.
// readyStates is an array of queues. Each queue holds PCB indices for ready processes
// of a particular priority.
deque<int> readyStates[NUM_PRIORITIES];
deque<int> blockedState; // A queue fo PCB indices for blocked processes.
deque<int> deadState;
// In this implementation, we'll never explicitly clear PCB entries and the
// index in the table will always be the process ID. These choices waste memory,
// but since this program is just a simulation it the easiest approach.
// Additionally, debugging is simpler since table slots and process IDs are
// never re-used.
vector<PcbEntry *> pcbTable;
double cumulativeTimeDiff = 0;
int numTerminatedProcesses = 0;
// Sadly, C++ has no built-in way to trim strings:
string &trim(string &argument)
{
string whitespace(" \t\n\v\f\r");
size_t found = argument.find_last_not_of(whitespace);
if (found != string::npos) {
argument.erase(found + 1);
argument.erase(0, argument.find_first_not_of(whitespace));
} else {
argument.clear(); // all whitespace
}
return argument;
}
bool createProgram(const string &filename, vector<Instruction> &program)
{
ifstream file;
int lineNum = 0;
program.clear();
file.open(filename.c_str());
if (!file.is_open()) {
cout << "Error opening file " << filename << ...
The document provides information on control structures in C++ including relational operators, loops, and decisions. It discusses relational operators like ==, <, > that compare values and return true or false. It describes the three types of loops in C++ - for, while, and do-while loops. The for loop executes a fixed number of times based on initialization, test, and increment expressions. The while loop repeats while a test condition is true. The do-while loop executes the body at least once and then repeats while the test condition is true. The document also covers the if statement for simple conditions and if-else for alternative paths, and provides code examples to demonstrate each control structure.
C++ code only(Retrieve of Malik D., 2015, p. 742) Programming Exer.pdfandreaplotner1
The document describes classes for integer manipulation and prime factorization. It defines member functions to perform operations on integers such as counting digits, reversing digits, splitting integers into blocks, determining primality, and finding prime factorization. It also provides code for driver programs that test the classes and allow the user to select operations via a menu. The full solution includes implementing the remaining member functions, adding constructors/destructors, overloading operators, and separating class specifications from implementation code.
The document discusses various operators in C++ including assignment operators, increment and decrement operators, logical operators, and the common mistake of confusing the equality operator (==) and the assignment operator (=).
It provides examples of how to use assignment operator abbreviations, preincrement and postincrement operators, logical operators like AND (&&), OR (||), and NOT (!) in conditions. It also demonstrates the different repetition structures like while, for, and do-while loops. Finally, it cautions about accidentally using the assignment operator instead of equality operator in conditions.
This document contains code snippets from a student's practical work using Microsoft Visual Studio C++. It includes 15 code modules that demonstrate basics of C++ programming like input/output, data types, operators, conditional statements and functions. The modules progress from simple print statements to more complex concepts like nested if-else statements and switch cases. Each module is preceded by comments identifying the topic and module number.
#ifndef RATIONAL_H if this compiler macro is not defined #def.pdfexxonzone
#ifndef RATIONAL_H // if this compiler macro is not defined
#define RATIONAL_H // then define it so this file will not be processed again
#include \"stdafx.h\" // use only for Microsoft Visual Studio C++
#include
using namespace std;
class Rational
{
// Friend functions are actually declared outside the scope of the
// class but have the right to access public and private data and
// member function members that belong to the class. The friend
// function below gives the << operator for ostreams (including cout)
// the ability to output a Rational object by accessing its member data.
friend ostream &operator<< (ostream &out, Rational const &r);
public:
Rational(int num = 0, int denom = 1); // also provides default constructor
Rational add(Rational right);
Rational operator+ (Rational right); // + addition operator
Rational operator+= (Rational right); // += addition assignment operator
Rational operator- (Rational right); // + addition operator
Rational operator-= (Rational right); // += addition assignment operator
void display();
operator double() const; // convert Rational to double
private:
int numerator;
int denominator;
// helper functions are private and not accessible by the main program
int LCD(int v1, int v2);
Rational setRational(int n, int d);
};
#endif
#include \"stdafx.h\"
#include
#include \"Rational.h\"
using namespace std;
// By using the default parameter settings in Rational.h, this
// constructor also provides the default constructor Rational()
Rational::Rational(int num, int denom)
{
setRational(num, denom); // set numerator and denominator, reduce fraction, fix the sign
}
// Helper function to fix a zero denominator and fix the sign if denominator is negative
Rational Rational::setRational(int n, int d) // helper function
{
numerator = n;
denominator = d;
// if denominator == 0 then set it = 1
if (denominator == 0)
denominator = 1;
if (denominator < 0) // if denominator is neg, multiply num and denom by -1
{
numerator = -numerator; // fix sign of numerator +/-
denominator = -denominator; // denominator always +
}
int lcd = LCD(numerator, denominator);
if (denominator != 0)
{
numerator /= lcd;
denominator /= lcd;
}
return *this; // return the current object
}
// find the lowest common divisor using a recursive function
int Rational::LCD(int v1, int v2)
{
if (v2 == 0) return v1;
else return LCD(v2, v1%v2);
}
Rational Rational::add(Rational right)
{
int newNumerator;
int newDenominator;
newNumerator = numerator*right.denominator + right.numerator*denominator;
newDenominator = denominator * right.denominator;
// create a new Rational object and return it
return setRational(newNumerator, newDenominator);
}
// the operator+ method does the same thing as the add method
Rational Rational::operator+ (Rational right)
{
int newNumerator;
int newDenominator;
newNumerator = numerator*right.denominator + right.numerator*denominator;
newDenominator = denominator * right.denominator;
// create a new Rational object and return it
return .
The document provides an introduction and overview of conditions and loops in C++ programming. It covers arithmetic operations, relational expressions, if/else statements, while loops, do-while loops, and for loops. Examples are given for each concept to demonstrate their syntax and usage. Key topics covered include operators, increment/decrement, if/elseif statements, comparing values, and using loops to repeat blocks of code multiple times.
Control structures in C++ include loops like while, do/while and for to repeat actions. Switch, break and continue statements are also covered. The document discusses counter-controlled and sentinel-controlled repetition, and provides examples of calculating a class average using different loop structures. Nested control structures are demonstrated with an example analyzing exam results from 10 students.
Router Queue Simulation in C++ in MMNN and MM1 conditionsMorteza Mahdilar
The document describes modifications made to a queue simulation program to measure the average time packets spend in the system. It is modified to track the arrival and departure time of each packet. When a packet arrives, its arrival time is recorded. When the packet departs, its processing time is calculated as the difference between departure and arrival time. These processing times are summed over all packets to calculate the average time spent in the system. The key code changes involve adding variables to track each packet's arrival and departure times, calculate processing time, and sum times across all packets.
This document contains code snippets and explanations for 5 questions on structured programming in C++. Question 1 involves writing a program to determine if a number is odd or even. Question 2 prints a multiplication table as a lower triangular matrix using different loop structures. Question 3 solves quadratic equations. Question 4 finds the mean of N numbers using various loops. Question 5 calculates the sum of even and odd numbers up to N using different loops. The document provides the code and output for each question using different loop structures like for, while, and do-while loops.
The document discusses different types of loops in programming languages including for, while, and do-while loops. It provides examples of each loop type in C programming code. The for loop repeats a specific number of times, the while loop repeats as long as a condition is true, and the do-while loop repeats at least once and then checks the condition. Switch/case statements provide an alternative to long if/else statements when comparing a variable to multiple values.
1. The document discusses various control structures in C++ including while, do/while, for, switch, break, and continue. It provides examples of how each structure is used.
2. One example calculates the class average of test grades by prompting the user to input 10 grades, summing them, and dividing by 10.
3. Another example analyzes exam results by inputting 10 results, counting passes and failures, and printing a message to raise tuition if passes exceed 8. It uses nested control structures including while, if/else, and if statements.
This C++ program uses random number generation and timing functions to insert random integers into a forward list a specified number of times. It gets user input for the number of iterations, uses a random number engine and distribution to generate random integers between -1000 and 1000 to insert into the list, records the start and end time of the iterations using steady clocks, calculates the elapsed time, and reports the time and number of iterations to the user before looping or quitting.
Tasks and functions allow designers to abstract commonly used Verilog code into reusable routines. Tasks can contain timing constructs and pass multiple values through input, output, and inout arguments. Functions must not contain timing constructs and return a single value. Tasks are similar to subroutines while functions are similar to functions in other languages like FORTRAN. Automatic tasks make tasks re-entrant to avoid issues with concurrent calls operating on shared variables.
The document contains code for several C++ programs that use functions to calculate factorials, sums of even and odd numbers, solutions to quadratic equations, averages, and combinations. Functions are implemented using for, while, do-while loops. Output examples are provided for sample inputs and calculations for each program.
Lab Assignment #6, part 3 Time ConversionProgram Name lab.docxsmile790243
This document contains code for multiple C++ programs that demonstrate various concepts. The first section shows code for a time conversion program that converts between military and standard time formats. The second section shows code for a cookie sales tracking program that uses vectors to store cookie names and sales amounts, and includes functions to calculate totals, percentages, and find best/worst sellers. The third section covers various aspects of the C++ string data type, including initialization, input/output, concatenation, comparison operators, and common string methods.
The document contains code snippets demonstrating different types of loops in C++ including for, while, do-while loops. It also shows examples of using break, continue and flag-controlled loops. Nested loops and sentinel controlled loops are presented. The output of the code snippets is also discussed in some cases.
Instruction1. Please read the two articles. (Kincheloe part 1 &.docxcarliotwaycave
Instruction:
1. Please read the two articles. (Kincheloe part 1 & 2)
2. Please choose some of the topics covered in each chapter, provide a brief summary (2-3 sentences) of those topics.
3. Then add your reflections, insights, or relevant experiences, etc. to help illustrate or expand upon the course.
4. This journal should be at least 400 words.
p5-start.cppp5-start.cpp/**
* @author Jane Student
* @cwid 123 45 678
* @class CSci 430, Spring 2018
* @ide Visual Studio Express 2010
* @date November 15, 2018
* @assg prog-04
*
* @description This program implements a simulation of process
* scheduling policies. In this program, we implement round-robin
* scheduling, where the time slice quantum can be specified as
* as a command line parameter. And we also implement shortest
* remaining time (SRT) scheduling policy
*/
#include<stdlib.h>
#include<iostream>
#include<iomanip>
#include<fstream>
#include<string>
#include<list>
usingnamespace std;
// global constants
// I won't test your round robin implementation with more than 20 processes
constint MAX_PROCESSES =20;
constint NO_PROCESS =0;
// Simple structure, holds all of the information about processes, their names
// arrival and service times, that we are to simulate.
typedefstruct
{
string processName;
int arrivalTime;
int serviceTime;
// holds running count of time slices for current time quantum, when
// serviceTime == quantum, time slice is up
int sliceTime;
// holds total number of time steps currently run, when == to
// serviceTime process is done
int totalTime;
// holds time when process finishes, used to calculate final stats,
// like T_r, T_r/T_s
int finishTime;
// a boolean flag, we will set this to true when the process is complete
bool finished;
}Process;
// Process table, holds table of information about processes we are simulating
typedefstruct
{
int numProcesses;
Process* process[MAX_PROCESSES];
}ProcessTable;
/** Create process table
* Allocate memory for a new process table. Load the process
* information from the simulation file into a table with the process
* information needed to perform the simulation. At the same time we
* initialize other information in process table for use in the
* simulation. Return the newly created ProcessTable
*
* @param processFilanem The name (char*) of the file to open and read
* the process information from.
* @param processTable This is actually a return parameter. This
* should be a pointer to an already allocated array of
* Process structure items. We will fill in this structure
* and return the process information.
*
* @returns ProcessTable* The newly allocated and initialized ProcessTable
* structure.
*/
ProcessTable* createProcessTable(char* processFilename)
{
ifstream simprocessfile(processFilename);
ProcessTable* processTable;
int pid;
string processName;
int arrivalTime;
int serviceTime;
// If we can't open file, abort and let ...
Start with the inclusion of libraries#include iostream .docxMARRY7
// Start with the inclusion of libraries
#include <iostream> //The library of io functions
#include <fstream> //The library of external stream functions
#include <cstdlib> //The library for external errors
#include <string> //The library for string functions
#include <cmath> //The library of C math functions
#include <iomanip> //Allows setting widths, etc. for I/O
#include <stdlib.h>
#include <stdio.h>
#include<vector>
using namespace std;
// Define all of the prototypes for functions used in the program
// Counts the number of unique letters seen
int countunique(int *array, int size);
// Creates the input file and formats it for use by the cipher section.
void createinput(string ifile, string ofile);
// Creates the encoded input file
void createcipher(int key, string ifile, string ofile);
// Finds and counts the number of digrams
int digram(int *pointer, string ifile);
// Counts the letter frequency in the encoded input file
int lettercount(int*, string ifile, string ofile);
// Finds the highest count in the singlton (or any other) array
int singleton(int*, int size);
// Trims an input file to the right size starting at an offset
void trimfile(string ifile, string ofile, int offset, int size);
// Begin the main function for testing
int main(int argc, char* argv[])
{
int count = 0;
int second = 0;
int singlefreq[26];
int *single = singlefreq;
int delta;
int loop; //The loop counter for arguments
int final = 0;
int totalcnt;
int key = -1; //Sets the key value
int len = 0; //The length to investigate for testing
int off; //Holds the offset into the file
double m; //Holds the metric error value
char loopletter;
float percent;
string ifile1 = "";
string ofile1 = "";
string deflt = "c:\\dissertation\\ShiftandSubcipherC++files\\clean.txt";
string ifile2 = "";
string ofile2 = ""; //Holds selected file path names
string cmdarg; //Holds the command line argument
string stop = "l"; //Gives the stop condition, assumes l
string reportfile = "c:\\dissertation\\test\\report.txt";
ofstream outs; //Declare an output stream for reporting
int digramc[676]; //Set up the digram array
int *two = digramc; //Point to the digram array
int dicount = 0; //Holds the count of the number of digrams
int total = 0; //Counts the total number of letters seen for analysis
for (loop = 1; loop<argc; loop++) //Decide if we have arguments or must use defaults
{
if (!argv[1])
{
// cout << "No argument found.\n";
ifile1 = deflt;
}
else
{
cmdarg = argv[loop];
if (cmdarg == "-k")
{
loop++;
key = atoi(argv[loop]);
cout << "key = " << key << endl;
}
if (cmdarg == "-l")
{
loop++;
len = atoi(argv[loop]);
cout << "Run for " << len << " characters.\n";
}
if (cmdarg == "-m")
{
loop++;
m = atof(argv[loop]);
cout << "Run until and error of " << m << "\n";
}
if (cmdarg == "-off")
{
loop++;
off = atoi(argv[loop]);
cout << ...
The document describes a problem statement to create a simple calculation module that can process arithmetic expressions. It provides the input specification using Backus-Naur Form to define the syntax. It then describes taking a simple approach to solve this without using .NET Expression Trees, including possible test failures. It includes the code for a CalcEngine class to calculate expressions and CalcEngineTest class with unit tests to validate the calculations and failures.
This document provides an overview of structural programming concepts in C++ including operators, conditional statements, repetitive statements, functions, and structures. It discusses relational and logical operators, if/else and switch conditional statements, for, while, and do loops, defining and calling functions, and using structures to group related data. The key topics are explained through examples to illustrate how to implement each concept in a C++ program.
The document discusses loop control structures in C++. It explains the for, while, and do-while loops and provides examples. It also covers break, continue, return, and goto statements used to control program flow in loops.
This programming allows the user to input a decimal number and converts it to octal. It displays the decimal number entered by the user and its equivalent octal value. The user is also prompted if they want to do another conversion or end the program.
This document provides 39 practice problems and solutions for a C++ exam. The problems cover topics like output of code snippets, conditional statements, loops, functions, and more. Sample inputs and outputs are given for some problems to test code behavior. The goal is to help students master C++ concepts before taking the exam.
Checking the World of Warcraft CMaNGOS open source serverPVS-Studio
In this article, I would like to share the results of our analysis of the open source implementation of the World of Warcraft server, CMaNGOS, as done by the PVS-Studio static analyzer.
The document discusses iterative statements in C++. It introduces the for loop as one type of iterative statement that allows repetitive execution of a block of code. The for loop syntax includes an initialization statement, condition, and increment/decrement statement. Examples are provided to illustrate calculating sums and factorials using for loops. Infinite for loops and auto increment/decrement operators are also described.
-I am unable to accept emailed exams or late exams. No exception.docxgertrudebellgrove
-I am unable to accept emailed exams or late exams. No exceptions.
-For technical issues you would need to go through tech support.
-Turn in work early to avoid technical issues. Technical issues are not a valid reason for failing to submit work.
-Make sure to research the exam drop box and where to find it a week or more ahead.
-Make sure to read all announcements and most importantly around exam times.
-The Professor has 2-3 days to grade the exam and once graded you need to check your grade book. I do not release exam grades via email.
-For any directions only contact your Professor, DO NOT use “all student” email to email other students because this only confuses them and points will be deducted as well as violations of the course policies
--Most exams you are given a FULL WEEK to complete. I also indicate day one of the course what the exam will cover and include. Do not email me the last minute to turn in work or ask any questions. I may not be available the hour before an exam so it is important to plan ahead.
- Review the sample exam to gain an A. Follow the length, and structured, apply APA format and go in depth. It is not too rough but points are deducted for failing to following the samples.
-Please do BOTH (1) copy and paste your work into the dropbox comment are or area provided, PLUS (2) attach the file. PLEASE DO BOTH. For attachments it must be in word. If it is any other format, or I am unable to open the file (such as word perfect) a 0 (zero) will be granted and no re-submissions will be allowed)
-See your course due dates for any dates as well as announcements. These are set and well planned week 1.
-Do not use work you previously submitted this term or a past one, do not work with anyone and do not plagiarize. This will result in a 0/F and I want you to gain an A!
-1 page each question, APA format.
-Keep an eye on your gradebook for grades. I am unable to respond to “confirm” if it is submitted or not, you can do so with tech support if needed.
NOTE +++IF YOUR TEXT DOES NOT HAVE END OF CHAPTER QUESTIONS, YOU MAY SUMMARIZE EACH CHAPTER IN DEPTH, THAT MEANS ALL CHAPTERS 7,8,9,10,11,12
EXAM worth 25 points.
READ ALL OF THE DIRECTIONS OR POINTS WILL BE DEDUCTED.
Grades will be final and I will not discuss the grade or
change a grade under any circumstances.
Work alone.
IMPORTANT NOTES:
Feel free to attach and/or copy and paste the work into the provided drop box.
No emailed papers will count.
IF YOUR CLASS HAS A DROPBOX THAT IS THE MAIN AREA TO SUBMIT THE EXAM
If I cannot open it I will not GRADE IT.
I will not accept ANY late work for exams.
FOLLOW THE DATES IN THE SYLLABUS ONLY!
YOU HAVE till the date listed on the syllabus to email it back to me. Good luck!
USE APA FORMAT
Please email me with any questions. DO NOT WORK WITH ANYONE! Put time into it and go IN DEPTH!
Please apply Primary sources, journals, articles, etc.
The Midterm is essay/short answer. Use the readings, the discussion .
-delineate characteristics, prevalence of exceptionality-evalua.docxgertrudebellgrove
-delineate characteristics, prevalence of exceptionality
-evaluate causes and concerns of each exceptionality
-critique and analyses component of the IEP
-identify and analyze instructional assessment and strategies to the individual with the exceptional needs
Follow the rubs. 4 DOUBLE SPACE with running head
.
More Related Content
Similar to @author Jane Programmer @cwid 123 45 678 @class.docx
Router Queue Simulation in C++ in MMNN and MM1 conditionsMorteza Mahdilar
The document describes modifications made to a queue simulation program to measure the average time packets spend in the system. It is modified to track the arrival and departure time of each packet. When a packet arrives, its arrival time is recorded. When the packet departs, its processing time is calculated as the difference between departure and arrival time. These processing times are summed over all packets to calculate the average time spent in the system. The key code changes involve adding variables to track each packet's arrival and departure times, calculate processing time, and sum times across all packets.
This document contains code snippets and explanations for 5 questions on structured programming in C++. Question 1 involves writing a program to determine if a number is odd or even. Question 2 prints a multiplication table as a lower triangular matrix using different loop structures. Question 3 solves quadratic equations. Question 4 finds the mean of N numbers using various loops. Question 5 calculates the sum of even and odd numbers up to N using different loops. The document provides the code and output for each question using different loop structures like for, while, and do-while loops.
The document discusses different types of loops in programming languages including for, while, and do-while loops. It provides examples of each loop type in C programming code. The for loop repeats a specific number of times, the while loop repeats as long as a condition is true, and the do-while loop repeats at least once and then checks the condition. Switch/case statements provide an alternative to long if/else statements when comparing a variable to multiple values.
1. The document discusses various control structures in C++ including while, do/while, for, switch, break, and continue. It provides examples of how each structure is used.
2. One example calculates the class average of test grades by prompting the user to input 10 grades, summing them, and dividing by 10.
3. Another example analyzes exam results by inputting 10 results, counting passes and failures, and printing a message to raise tuition if passes exceed 8. It uses nested control structures including while, if/else, and if statements.
This C++ program uses random number generation and timing functions to insert random integers into a forward list a specified number of times. It gets user input for the number of iterations, uses a random number engine and distribution to generate random integers between -1000 and 1000 to insert into the list, records the start and end time of the iterations using steady clocks, calculates the elapsed time, and reports the time and number of iterations to the user before looping or quitting.
Tasks and functions allow designers to abstract commonly used Verilog code into reusable routines. Tasks can contain timing constructs and pass multiple values through input, output, and inout arguments. Functions must not contain timing constructs and return a single value. Tasks are similar to subroutines while functions are similar to functions in other languages like FORTRAN. Automatic tasks make tasks re-entrant to avoid issues with concurrent calls operating on shared variables.
The document contains code for several C++ programs that use functions to calculate factorials, sums of even and odd numbers, solutions to quadratic equations, averages, and combinations. Functions are implemented using for, while, do-while loops. Output examples are provided for sample inputs and calculations for each program.
Lab Assignment #6, part 3 Time ConversionProgram Name lab.docxsmile790243
This document contains code for multiple C++ programs that demonstrate various concepts. The first section shows code for a time conversion program that converts between military and standard time formats. The second section shows code for a cookie sales tracking program that uses vectors to store cookie names and sales amounts, and includes functions to calculate totals, percentages, and find best/worst sellers. The third section covers various aspects of the C++ string data type, including initialization, input/output, concatenation, comparison operators, and common string methods.
The document contains code snippets demonstrating different types of loops in C++ including for, while, do-while loops. It also shows examples of using break, continue and flag-controlled loops. Nested loops and sentinel controlled loops are presented. The output of the code snippets is also discussed in some cases.
Instruction1. Please read the two articles. (Kincheloe part 1 &.docxcarliotwaycave
Instruction:
1. Please read the two articles. (Kincheloe part 1 & 2)
2. Please choose some of the topics covered in each chapter, provide a brief summary (2-3 sentences) of those topics.
3. Then add your reflections, insights, or relevant experiences, etc. to help illustrate or expand upon the course.
4. This journal should be at least 400 words.
p5-start.cppp5-start.cpp/**
* @author Jane Student
* @cwid 123 45 678
* @class CSci 430, Spring 2018
* @ide Visual Studio Express 2010
* @date November 15, 2018
* @assg prog-04
*
* @description This program implements a simulation of process
* scheduling policies. In this program, we implement round-robin
* scheduling, where the time slice quantum can be specified as
* as a command line parameter. And we also implement shortest
* remaining time (SRT) scheduling policy
*/
#include<stdlib.h>
#include<iostream>
#include<iomanip>
#include<fstream>
#include<string>
#include<list>
usingnamespace std;
// global constants
// I won't test your round robin implementation with more than 20 processes
constint MAX_PROCESSES =20;
constint NO_PROCESS =0;
// Simple structure, holds all of the information about processes, their names
// arrival and service times, that we are to simulate.
typedefstruct
{
string processName;
int arrivalTime;
int serviceTime;
// holds running count of time slices for current time quantum, when
// serviceTime == quantum, time slice is up
int sliceTime;
// holds total number of time steps currently run, when == to
// serviceTime process is done
int totalTime;
// holds time when process finishes, used to calculate final stats,
// like T_r, T_r/T_s
int finishTime;
// a boolean flag, we will set this to true when the process is complete
bool finished;
}Process;
// Process table, holds table of information about processes we are simulating
typedefstruct
{
int numProcesses;
Process* process[MAX_PROCESSES];
}ProcessTable;
/** Create process table
* Allocate memory for a new process table. Load the process
* information from the simulation file into a table with the process
* information needed to perform the simulation. At the same time we
* initialize other information in process table for use in the
* simulation. Return the newly created ProcessTable
*
* @param processFilanem The name (char*) of the file to open and read
* the process information from.
* @param processTable This is actually a return parameter. This
* should be a pointer to an already allocated array of
* Process structure items. We will fill in this structure
* and return the process information.
*
* @returns ProcessTable* The newly allocated and initialized ProcessTable
* structure.
*/
ProcessTable* createProcessTable(char* processFilename)
{
ifstream simprocessfile(processFilename);
ProcessTable* processTable;
int pid;
string processName;
int arrivalTime;
int serviceTime;
// If we can't open file, abort and let ...
Start with the inclusion of libraries#include iostream .docxMARRY7
// Start with the inclusion of libraries
#include <iostream> //The library of io functions
#include <fstream> //The library of external stream functions
#include <cstdlib> //The library for external errors
#include <string> //The library for string functions
#include <cmath> //The library of C math functions
#include <iomanip> //Allows setting widths, etc. for I/O
#include <stdlib.h>
#include <stdio.h>
#include<vector>
using namespace std;
// Define all of the prototypes for functions used in the program
// Counts the number of unique letters seen
int countunique(int *array, int size);
// Creates the input file and formats it for use by the cipher section.
void createinput(string ifile, string ofile);
// Creates the encoded input file
void createcipher(int key, string ifile, string ofile);
// Finds and counts the number of digrams
int digram(int *pointer, string ifile);
// Counts the letter frequency in the encoded input file
int lettercount(int*, string ifile, string ofile);
// Finds the highest count in the singlton (or any other) array
int singleton(int*, int size);
// Trims an input file to the right size starting at an offset
void trimfile(string ifile, string ofile, int offset, int size);
// Begin the main function for testing
int main(int argc, char* argv[])
{
int count = 0;
int second = 0;
int singlefreq[26];
int *single = singlefreq;
int delta;
int loop; //The loop counter for arguments
int final = 0;
int totalcnt;
int key = -1; //Sets the key value
int len = 0; //The length to investigate for testing
int off; //Holds the offset into the file
double m; //Holds the metric error value
char loopletter;
float percent;
string ifile1 = "";
string ofile1 = "";
string deflt = "c:\\dissertation\\ShiftandSubcipherC++files\\clean.txt";
string ifile2 = "";
string ofile2 = ""; //Holds selected file path names
string cmdarg; //Holds the command line argument
string stop = "l"; //Gives the stop condition, assumes l
string reportfile = "c:\\dissertation\\test\\report.txt";
ofstream outs; //Declare an output stream for reporting
int digramc[676]; //Set up the digram array
int *two = digramc; //Point to the digram array
int dicount = 0; //Holds the count of the number of digrams
int total = 0; //Counts the total number of letters seen for analysis
for (loop = 1; loop<argc; loop++) //Decide if we have arguments or must use defaults
{
if (!argv[1])
{
// cout << "No argument found.\n";
ifile1 = deflt;
}
else
{
cmdarg = argv[loop];
if (cmdarg == "-k")
{
loop++;
key = atoi(argv[loop]);
cout << "key = " << key << endl;
}
if (cmdarg == "-l")
{
loop++;
len = atoi(argv[loop]);
cout << "Run for " << len << " characters.\n";
}
if (cmdarg == "-m")
{
loop++;
m = atof(argv[loop]);
cout << "Run until and error of " << m << "\n";
}
if (cmdarg == "-off")
{
loop++;
off = atoi(argv[loop]);
cout << ...
The document describes a problem statement to create a simple calculation module that can process arithmetic expressions. It provides the input specification using Backus-Naur Form to define the syntax. It then describes taking a simple approach to solve this without using .NET Expression Trees, including possible test failures. It includes the code for a CalcEngine class to calculate expressions and CalcEngineTest class with unit tests to validate the calculations and failures.
This document provides an overview of structural programming concepts in C++ including operators, conditional statements, repetitive statements, functions, and structures. It discusses relational and logical operators, if/else and switch conditional statements, for, while, and do loops, defining and calling functions, and using structures to group related data. The key topics are explained through examples to illustrate how to implement each concept in a C++ program.
The document discusses loop control structures in C++. It explains the for, while, and do-while loops and provides examples. It also covers break, continue, return, and goto statements used to control program flow in loops.
This programming allows the user to input a decimal number and converts it to octal. It displays the decimal number entered by the user and its equivalent octal value. The user is also prompted if they want to do another conversion or end the program.
This document provides 39 practice problems and solutions for a C++ exam. The problems cover topics like output of code snippets, conditional statements, loops, functions, and more. Sample inputs and outputs are given for some problems to test code behavior. The goal is to help students master C++ concepts before taking the exam.
Checking the World of Warcraft CMaNGOS open source serverPVS-Studio
In this article, I would like to share the results of our analysis of the open source implementation of the World of Warcraft server, CMaNGOS, as done by the PVS-Studio static analyzer.
The document discusses iterative statements in C++. It introduces the for loop as one type of iterative statement that allows repetitive execution of a block of code. The for loop syntax includes an initialization statement, condition, and increment/decrement statement. Examples are provided to illustrate calculating sums and factorials using for loops. Infinite for loops and auto increment/decrement operators are also described.
Similar to @author Jane Programmer @cwid 123 45 678 @class.docx (20)
-I am unable to accept emailed exams or late exams. No exception.docxgertrudebellgrove
-I am unable to accept emailed exams or late exams. No exceptions.
-For technical issues you would need to go through tech support.
-Turn in work early to avoid technical issues. Technical issues are not a valid reason for failing to submit work.
-Make sure to research the exam drop box and where to find it a week or more ahead.
-Make sure to read all announcements and most importantly around exam times.
-The Professor has 2-3 days to grade the exam and once graded you need to check your grade book. I do not release exam grades via email.
-For any directions only contact your Professor, DO NOT use “all student” email to email other students because this only confuses them and points will be deducted as well as violations of the course policies
--Most exams you are given a FULL WEEK to complete. I also indicate day one of the course what the exam will cover and include. Do not email me the last minute to turn in work or ask any questions. I may not be available the hour before an exam so it is important to plan ahead.
- Review the sample exam to gain an A. Follow the length, and structured, apply APA format and go in depth. It is not too rough but points are deducted for failing to following the samples.
-Please do BOTH (1) copy and paste your work into the dropbox comment are or area provided, PLUS (2) attach the file. PLEASE DO BOTH. For attachments it must be in word. If it is any other format, or I am unable to open the file (such as word perfect) a 0 (zero) will be granted and no re-submissions will be allowed)
-See your course due dates for any dates as well as announcements. These are set and well planned week 1.
-Do not use work you previously submitted this term or a past one, do not work with anyone and do not plagiarize. This will result in a 0/F and I want you to gain an A!
-1 page each question, APA format.
-Keep an eye on your gradebook for grades. I am unable to respond to “confirm” if it is submitted or not, you can do so with tech support if needed.
NOTE +++IF YOUR TEXT DOES NOT HAVE END OF CHAPTER QUESTIONS, YOU MAY SUMMARIZE EACH CHAPTER IN DEPTH, THAT MEANS ALL CHAPTERS 7,8,9,10,11,12
EXAM worth 25 points.
READ ALL OF THE DIRECTIONS OR POINTS WILL BE DEDUCTED.
Grades will be final and I will not discuss the grade or
change a grade under any circumstances.
Work alone.
IMPORTANT NOTES:
Feel free to attach and/or copy and paste the work into the provided drop box.
No emailed papers will count.
IF YOUR CLASS HAS A DROPBOX THAT IS THE MAIN AREA TO SUBMIT THE EXAM
If I cannot open it I will not GRADE IT.
I will not accept ANY late work for exams.
FOLLOW THE DATES IN THE SYLLABUS ONLY!
YOU HAVE till the date listed on the syllabus to email it back to me. Good luck!
USE APA FORMAT
Please email me with any questions. DO NOT WORK WITH ANYONE! Put time into it and go IN DEPTH!
Please apply Primary sources, journals, articles, etc.
The Midterm is essay/short answer. Use the readings, the discussion .
-delineate characteristics, prevalence of exceptionality-evalua.docxgertrudebellgrove
-delineate characteristics, prevalence of exceptionality
-evaluate causes and concerns of each exceptionality
-critique and analyses component of the IEP
-identify and analyze instructional assessment and strategies to the individual with the exceptional needs
Follow the rubs. 4 DOUBLE SPACE with running head
.
-1st play name is READY STEADY YETI GO-2nd play name is INTO .docxgertrudebellgrove
-1st play name is "READY STEADY YETI GO"
-2nd play name is "INTO THE WOODS "
REVIEW PAPER GUIDELINES (3 pages,
Essay format) Introduction
Plot
What happens?
E.g., “Mother Courage follows the misadventures of Courage and her children over a ten year period during the 100 Years War...”
How does it happen?
E.g., “The play is built in a series of episodes, alternating personal struggles against a backdrop of the larger social/political struggles.”
What does it mean?
A one-two sentence that captures the essence of the action. In the case of Epic Theatre, this statement is primarily about the intended “lesson” of the play. E.g., “MC is about how capitalism inevitably leads to the corruption then destruction of society—from nations to families.”
Rhythm
Flow of the plots?
Character
Main character Description
E.g., “Courage is a middle-aged mother of three who will stop at nothing to exploit the financial opportunities she encounters. Her role in the play is ‘survivor.’ Her character is the ‘anti-mom’—a woman who sees her children (and other human beings) as a collection of debits and credits.”
Second Character Description
Thought—what are the ideas in the play
e.g., Mother Courage looks at the intersection of war and commerce and how one feeds off the other, to the destruction of land, civilization, and families. The ideas arise out of the work of Karl Marx. Summarize--
Historical (Where and When) Philosophical (What & Why)
Diction--
Summarize the language the playwright uses. How do the characters speak?
E.g., prose, poetry, cliché, long speeches, short, etc.?
7 of 8
Music—
is more than song, but the SOUND of the play. Describe the aural environment created and executed in the production.
Spectacle
—describe the visual environment of light and scenery created for the production, and their execution and relevance (e.g., it could look great but mean nothing, or it could look terrible but somehow it works!)
Conclusion
A paragraph about your particular feelings about the play—did it engage you? Were you changed, even a little? Goethe asked three questions—What was it trying to do? How well was it done? Was it worth doing? Answer these questions.
.
-6th-Edition-Template-without-Abstract.dotWhat are Heuristics .docxgertrudebellgrove
-6th-Edition-Template-without-Abstract.dot
What are Heuristics and can it lead to bias?
Why is Maslow's Hierarchy a basic psychological stable? (Watch the video for better understanding and cite it)
How does FEAR keep you alive? (See emotions and feelings video)
Please write 300 or more words and APA to address the above concepts for week four.
.
- write one 5-7 page paper about All forms of Euthanasia are moral..docxgertrudebellgrove
- write one 5-7 page paper about All forms of Euthanasia are moral.
- Argumentative/Persuasive paper structure
- Include an introduction and conclusion. The main points of your paper should be identified in
the introduction.
- include at least three arguments to support the position
- Include at least one opposing argument against your topic
- times new roman font
- double spaced
- 12 point font size
- work cited page
.
-1st Play name is BERNHARDTHAMLET -2nd Play name is READY ST.docxgertrudebellgrove
-1st Play name is "BERNHARDT/HAMLET "
-2nd Play name is "READY STEADY YETI GO"
PREVIEW PAPER GUIDELINES
1. Title of Show
2. Playwright (and, if musical, Composer, Librettist)
3. Creative Team: Lead actors, Director, Designers (if musical, Choreographer and Music Director)
4. Venue: Broadway, Off-Broadway, College, etc. (incl. # of seats, cost of a regular ticket
5. Audience: (that is, what demographic is the production trying to attract?) Whom do you think would come and enjoy the performance?
Substantiate this claim by citing advertising evidence--type of ad, where it is advertised (e.g., NY Times, TimeOut New York, Internet, radio)
6. In one sentence, what's the story about?
7. In three sentences, what is your expectation? E.g., Deliriously excited? Modestly intrigued? Morbidly curious? Apathetic? Anxiously anticipating? Horrifically terrified? Dolefully dreading? And why?
.
. 1. Rutter and Sroufe identified _____________ as one of three impo.docxgertrudebellgrove
. 1. Rutter and Sroufe identified _____________ as one of three important areas of focus in the future of developmental psychopathology.
A. How cause and effect underlie childhood disorders
B. The role of the media in the life of the modern child.
C. Creating a stricter definition of normal behavior.
D. Fetal development’s influence on childhood behavior
2. Which of the following questions is not appropriate on a mental status exam?
A. What’s four times five?
B. Who’s the current president of the United States?
C. What day of the week is it today?
D. Who wrote the Harry Potter books?
3. State laws can influence decision making in all the following ways, except
A. who can legally provide consent for the child.
B. beneficence and maleficence
C. timelines for reporting suspected child abuse
D. custodial versus noncustodial parental rights
4. The transactional model was developed to
A. illustrate how even very disabled children are able to adapt to their environments.
B. analyze exactly which characteristics are passed from a caregiver to a child.
C. predict the future of a child’s development by analyzing past events and behaviors.
D. show how a child adapts to an environment and how the environment changes as a result.
5. All of the following are true concerning the APA 10 ethical standards except
A. the standards were useful in past decades but are no longer useful.
B. the standards address appropriate advertising and displays of public information.
C. the standards address matters pertaining to research and publication.
D. the standards assist professionals to resolve ethical issues.
6. Which of the following is true regarding the age of majority?
A. It’s 18 in 34 of the U.S. States.
B. It’s 19 years in all Canadian provinces.
C. It’s 18 years of age in every USA State
D. It’s not an important consideration for psychologists working with children.
7. In the context of Sue’s 2006 article on cultural competent treatment, gift giving refers to
A. giving a token gift to the client
B. rules about barbering
C. accepting a gift from the client
D. gifts of therapy, such as reduced tension
8. Which of the following is one of the guiding principle of the American Psychological Association (APA).
A. Generosity
B. Duplicity
C. Felicity
D. Integrity
9. Mash and Wolfe (2002) suggest three goals of assessment . Which of the following is not one of the goals?
A. Diagnosis
B. Treatment planning
C. Prognosis
D. Research
10. Using the K-3 Paradigm involves knowledge of
A. brain chemistry
B. the Diagnostic and Statistical Manual of Mental Disorders
C. a child’s family medical history
D. developmental expectations
12. Which of the following is true regarding a functional behavioral assessment?
A. An FBA assesses the degree to which a behavior exists.
B. An FBA is norms-based.
C. The FBA was developed to analyzed why a behavior exists.
D. The use of FBA has been discouraged by the American Psycholo.
-Prior to the Civil War, how did the (dominant) discourse over the U.docxgertrudebellgrove
-Prior to the Civil War, how did the (dominant) discourse over the United States’ future reach a crisis point? What were the arguments regarding the Constitutionality of slavery and notions of citizenship? How did relative definitions of liberty/freedom/equality become irreconcilable?
.
- Using the definition Awareness of sensation and perception to ex.docxgertrudebellgrove
- Using
the definition Awareness of sensation and perception to explain why or why not dolphins have consciousness
!
-
two to three paragraph explanation
-
Specify the definition you are using.
Then demonstrate appropriate application of that definition.
- You should describe the creature you are exploring and its behavior for those unfamiliar with it.
- Stick to behaviors that are relevant to whether the creature has consciousness or not under your chosen definition.
- The behavior must be observable! You declaring that a creature "looks fearful/happy/sad" is not on observation, it's an opinion.
- Present arguments that illustrates your position.
* For example, "Research has shown (citation if available can help) that Orangutans can recognize themselves in the mirror and realize the image they see is a reflection of themselves. This suggests they have awareness of their themselves as separate from the environment and others."
.
- should include an introduction to the environmental issue and its .docxgertrudebellgrove
- should include an introduction to the environmental issue and its location
- next portion should be about the opposing views (atleast 3 cons. and 3 possible solutions to the cons) The cons needs to be focused on the environmental impact of the problem, not just how it's affecting humans. What is it doing to the ecosystems?
- must be 4 pages double-spaced not including references and include in-text citation
-not opinion based!!
.
- FIRST EXAM SPRING 20201. Describe how the view of operations.docxgertrudebellgrove
- FIRST EXAM SPRING 2020
1. Describe how the view of operations as a process can be applied to the following:
a. Acquisition of another company
b. Marketing Research for a New Product
c. Design of an Information System
2. An operations manager was heard complaining
“My boss never listens to me ----- all the boss wants from me is to avoid making waves. I rarely get any capital to improve operations. Also, we do not have weekly, biweekly or even monthly meetings with our product managers, supply chain department, customer service or the sales department. We only meet with the accounting and finance departments when there are issues with the monthly budgets. Furthermore, our department has interacted with information service department about four times in past fiscal year”
Please assess the following:
a. Whether this business has a business strategy ?
b. Does it have an operations strategy?
c. What would you recommend?
3. Firm A has recorded the following costs in 2018:
Incoming materials and inspection $20,000
Training of Personnel $40,000
Warranty $45,000
Process Planning $15,000
Scrap $13,000
Quality Laboratory $30,000
Rework $25,000
Allowances $10,000
Complaints $14,000
a. What are the Prevention, Appraisal, Internal Failure and External Failure costs?
b. What inferences can you draw on Quality Measures taken by Firm A?
c. What would you recommend to improve quality programs in Firm A?
d. What initiatives should Firm A implement for 2019 and 2020?
4. Please explain the House of Quality (QFD) as discussed in class.
5. A certain process is under statistical control and has a mean value of 130 and a standard deviation of 8. The specifications for the process are:
a. USL (upper specification limit) = 150
b. LSL(lower specification limit) =100
a. Calculate the cp and cpk
b. Which of these indices is a better measure of process capability and why?
c. Assuminng a normal distribution what percentage of output is expected to fall ourside the specification. Why is it important to know this?
d. What would you recommend?
2
Chapter 7
Government Ethics
and the Law
William A. Myers, Ph.D.
Learning Objectives (1 of 2)
• Describe some of the reasons why there has
been a loss of trust in government.
• Explain the purpose of various government
committees on ethics.
• Discuss how public policy protects the rights of
citizens.
Learning Objectives (2 of 2)
• Describe federal laws designed to protect each
individual’s rights.
• Explain the concept of political malpractice.
• Understand the importance of ethics in public
service.
Let every American, every lover of liberty, every
well wisher to his posterity, swear by the blood
of the Revolution, never to violate in the least
particular, the laws of the country; and never to
tolerate their violation by others.
—Abraham Lincoln
Executive Branch:
U.S. Office of Government Ethics
• Exercises leadership .
- Considering the concepts, examples and learning from the v.docxgertrudebellgrove
- Considering the concepts, examples and learning from the various modules you have attended this year, summarise and reflect on in a critical way what you think are the key elements (both internal and external to businesses) that organisations should consider to develop and grow responsibly and effectively in today’s economy.
.
- Discuss why a computer incident response team (CIRT) plan is neede.docxgertrudebellgrove
- Discuss why a computer incident response team (CIRT) plan is needed, and its purpose.
- Why are the roles and responsibilities important to be listed and kept updated for a CIRT plan.
- Connect the dots: Discuss your understanding of the CIRT incident handling procedures, the role policies play, and the importance of communication escalation procedures.
- What are some best practices for implementing a CIRT plan? Do some personal research to answer this questions.
.
- Discuss why a computer incident response team (CIRT) plan is n.docxgertrudebellgrove
- Discuss why a computer incident response team (CIRT) plan is needed, and its purpose.
- Why are the roles and responsibilities important to be listed and kept updated for a CIRT plan.
- Connect the dots: Discuss your understanding of the CIRT incident handling procedures, the role policies play, and the importance of communication escalation procedures.
- What are some best practices for implementing a CIRT plan? Do some personal research to answer this questions.
.
- 2 -Section CPlease write your essay in the blue book.docxgertrudebellgrove
- 2 -
Section C
Please write your essay in the blue book.
Write an informal narrative about "some" composing process of yours. Essentially, you will write a Reflective Self-Evaluation of yourself as a college writer. What exactly does that mean? It requires you to:
a. look back over a recently completed process
b. think reflectively about that process
c. critically evaluate what went well, what didn’t go well, or what you might have done differently
As the aforementioned examples suggest, reflective writing is writing that describes, explains, interprets, and evaluates any past performance, action, belief, feeling, or experience. To reflect is to turn or look back, to reconsider something in the past from the perspective of the present. So, in your final essay, you will reflect and make an evaluation of your experience in this course.
Remember, reflection involves multiple angles of vision. Just as light waves are thrown or bent back from the surface of a mirror, so, too, reflective writing throws our experience, action, or performance back to us, allowing us to see differently. We view the past from the angle of the present, what was from the angle of what could have been or what might be. Multiplying your angle of vision through reflection often yields new insights and more complicated (complex) understanding of the issue on which you are reflecting.
Professors generally look for four kinds of knowledge in reflective self-evaluation essays: self-knowledge, content knowledge, rhetorical knowledge, and critical knowledge (aka judgment). Following are ideas for each of these types of knowledge, which may be used to generate ideas for your essay. Choose only a few of the questions to respond to, questions that allow you to explain and demonstrate your most important learning for the course.
You may write about your composing process for academic papers or creative genres or a combination of both. Reflect as thoroughly as possible upon your writing process and explain it. Your narrative should include whatever you DO when you write, as well as whatever you DO when you compose. Composing should be understood in the broad sense, i.e. composing goes on in your mind when you are cleaning your refrigerator, mowing your grass, etc. It also occurs when you are researching, taking notes, or procrastinating. In essence you are NEVER NOT composing something. So the key to your reflections is to include everything you do that makes a difference in your writing, from having to use a certain pen, to listening to music or sitting in the library. Both your formal and informal processes impact the way you produce a written work, if you use a formal method of note taking or outlining, if you compose on the computer or with pen and paper explore any and all of these activities that are helpful to you in your process. Explore all possible aspects that apply. This is a useful exercise for now and for you to revisit and revise in the future .
- Confidence intervals for a population mean, standard deviation kno.docxgertrudebellgrove
- Confidence intervals for a population mean, standard deviation known
- Confidence intervals for a population mean, standard deviation unknown
-Confidence intervals for population proportion
- Confidence intervals for a standard deviation
.
) Create a new thread. As indicated above, select two tools describ.docxgertrudebellgrove
) Create a new thread. As indicated above, select two tools described in chapter 7 from different categories, and describe how these tools could be used to develop a policy for optimizing bus and local train schedules to minimize energy use and passenger wait times in a SmartCity environment.
tools
•Visualization
•Argumentation
•eParticipation
•Opinion mining
•Simulation
•Serious games
•Tools specifically designed for policy makers
•Persuasive
•Social network analysis (SNA)
•Big data analytics
•Semantics and linked data
.
(Write 3 to 4 sentences per question) 1. Describe one way y.docxgertrudebellgrove
(Write 3 to 4 sentences per question)
1.
Describe one way you can leverage any strengths you have in research and information literacy to promote your success.
Consider successes, lessons learned, or skills you have gained as a result of your past academic, personal, or professional experiences.
2.
1.
Why do you think it is important to use source materials to support your viewpoints?
Why is it important that the sources you use in your coursework be scholarly sources?
.
( America and Venezuela) this is a ppt. groups assignment. Below is .docxgertrudebellgrove
( America and Venezuela) this is a ppt. groups assignment. Below is my part.
Explain how an American would apply the knowledge of verbal and nonverbal communication to foster effective cross-cultural communication within the selected country.
Lastly, summarize how cultural differences affect cross-cultural communications.
.
++ 2 PAGES++Topic Make a bill to legalize all felon has the rig.docxgertrudebellgrove
++ 2 PAGES++
Topic: Make a bill to legalize all felon has the right to vote with no condition (become a green state) https://www.aclu.org/issues/voting-rights/voter-restoration/felony-disenfranchisement-laws-map
Guideline: **only do part 2 (3-55)** follow guideline on this website: https://leg.wa.gov/CodeReviser/Documents/2019BillDraftingGuide.pdf
additional websites (or you can search more info beside the websites i provide):
https://www.sos.wa.gov/elections/voters/felons-and-voting-rights.aspxhttps://www.sos.wa.gov/elections/voter-eligibility.aspx
.
Exploiting Artificial Intelligence for Empowering Researchers and Faculty, In...Dr. Vinod Kumar Kanvaria
Exploiting Artificial Intelligence for Empowering Researchers and Faculty,
International FDP on Fundamentals of Research in Social Sciences
at Integral University, Lucknow, 06.06.2024
By Dr. Vinod Kumar Kanvaria
How to Setup Warehouse & Location in Odoo 17 InventoryCeline George
In this slide, we'll explore how to set up warehouses and locations in Odoo 17 Inventory. This will help us manage our stock effectively, track inventory levels, and streamline warehouse operations.
A review of the growth of the Israel Genealogy Research Association Database Collection for the last 12 months. Our collection is now passed the 3 million mark and still growing. See which archives have contributed the most. See the different types of records we have, and which years have had records added. You can also see what we have for the future.
How to Build a Module in Odoo 17 Using the Scaffold MethodCeline George
Odoo provides an option for creating a module by using a single line command. By using this command the user can make a whole structure of a module. It is very easy for a beginner to make a module. There is no need to make each file manually. This slide will show how to create a module using the scaffold method.
This presentation was provided by Steph Pollock of The American Psychological Association’s Journals Program, and Damita Snow, of The American Society of Civil Engineers (ASCE), for the initial session of NISO's 2024 Training Series "DEIA in the Scholarly Landscape." Session One: 'Setting Expectations: a DEIA Primer,' was held June 6, 2024.
The simplified electron and muon model, Oscillating Spacetime: The Foundation...RitikBhardwaj56
Discover the Simplified Electron and Muon Model: A New Wave-Based Approach to Understanding Particles delves into a groundbreaking theory that presents electrons and muons as rotating soliton waves within oscillating spacetime. Geared towards students, researchers, and science buffs, this book breaks down complex ideas into simple explanations. It covers topics such as electron waves, temporal dynamics, and the implications of this model on particle physics. With clear illustrations and easy-to-follow explanations, readers will gain a new outlook on the universe's fundamental nature.
हिंदी वर्णमाला पीपीटी, hindi alphabet PPT presentation, hindi varnamala PPT, Hindi Varnamala pdf, हिंदी स्वर, हिंदी व्यंजन, sikhiye hindi varnmala, dr. mulla adam ali, hindi language and literature, hindi alphabet with drawing, hindi alphabet pdf, hindi varnamala for childrens, hindi language, hindi varnamala practice for kids, https://www.drmullaadamali.com
Strategies for Effective Upskilling is a presentation by Chinwendu Peace in a Your Skill Boost Masterclass organisation by the Excellence Foundation for South Sudan on 08th and 09th June 2024 from 1 PM to 3 PM on each day.
Your Skill Boost Masterclass: Strategies for Effective Upskilling
@author Jane Programmer @cwid 123 45 678 @class.docx
1. /**
* @author Jane Programmer
* @cwid 123 45 678
* @class COSC 2336, Spring 2019
* @ide Visual Studio Community 2017
* @date January 12, 2019
* @assg Assignment 04
*
* @description Assignment 04 Practice defining recursive
functions. We
* implement factorial and counting combinations functions
using the
* binomial coefficient in this assignment. This file containts
unit
* tests of the required functions for this assignment.
*/
#include <iostream>
#include <cassert>
#include <chrono> // measure elapsed time of functions using
high resolution clock
#include "BinomialFunctions.hpp"
using namespace std;
/** main
* The main entry point for this program. Execution of this
program
* will begin with this main function.
*
* @param argc The command line argument count which is the
number of
* command line arguments provided by user when they
started
2. * the program.
* @param argv The command line arguments, an array of
character
* arrays.
*
* @returns An int value indicating program exit status.
Usually 0
* is returned to indicate normal exit and a non-zero value
* is returned to indicate an error condition.
*/
int main(int argc, char** argv)
{
// test iterative version of factorial
cout << "Testing iterative version factorialIterative() " <<
endl;
cout << "-------------------------------------------------------------"
<< endl;
bigint res;
//res = factorialIterative(0);
//cout << "Test base case: factorialIterative(0) = " << res <<
endl;
//assert(res == 1);
//res = factorialIterative(1);
//cout << "Test edge case: factorialIterative(1) = " << res <<
endl;
//assert(res == 1);
//res = factorialIterative(-1);
//cout << "Test error case: factorialIterative(-1) = " << res <<
endl;
//assert(res == 1);
//res = factorialIterative(10);
//cout << "Test general case: factorialIterative(10) = " << res
3. << endl;
//assert(res == 3628800);
//res = factorialIterative(12);
//cout << "Test general case (largest 32 bit int):
factorialIterative(12) = " << res << endl;
//assert(res == 479001600);
//res = factorialIterative(20);
//cout << "Test general case (largest 64 bit int):
factorialIterative(20) = " << res << endl;
//assert(res == 2432902008176640000);
// timing test for factorialIterative, do it 10000 times and see
how much time
// elapses
// https://www.pluralsight.com/blog/software-
development/how-to-measure-execution-time-intervals-in-c--
const int NUM_TIMING_LOOPS = 10000;
//auto start = chrono::high_resolution_clock::now();
//for (int testnum = 0; testnum < NUM_TIMING_LOOPS;
testnum++)
//{
// res = factorialIterative(20);
//}
//auto finish = chrono::high_resolution_clock::now();
//chrono::duration<double> elapsed = finish - start;
//cout << "Elapsed time " << NUM_TIMING_LOOPS << "
loops of factorialIterative(20) "
// << elapsed.count() << endl;
// test recursive version of factorial
cout << endl;
cout << "Testing recursive version factorialRecursive() " <<
endl;
4. cout << "-------------------------------------------------------------"
<< endl;
//res = factorialRecursive(0);
//cout << "Test base case: factorialRecursive(0) = " << res <<
endl;
//assert(res == 1);
//res = factorialRecursive(1);
//cout << "Test edge case: factorialRecursive(1) = " << res <<
endl;
//assert(res == 1);
//res = factorialRecursive(-1);
//cout << "Test error case: factorialRecursive(-1) = " << res
<< endl;
//assert(res == 1);
//res = factorialRecursive(10);
//cout << "Test general case: factorialRecursive(10) = " << res
<< endl;
//assert(res == 3628800);
//res = factorialRecursive(12);
//cout << "Test general case (largest 32 bit int):
factorialRecursive(12) = " << res << endl;
//assert(res == 479001600);
//res = factorialRecursive(20);
//cout << "Test general case (largest 64 bit int):
factorialRecursive(20) = " << res << endl;
//assert(res == 2432902008176640000);
//cout << "Test equivalence of iterative and recursive solutions
from n=0 to 20: " << endl;
//for (int n = 0; n <= 20; n++)
5. //{
// cout << " Testing n = " << n << "...";
// assert(factorialIterative(n) == factorialRecursive(n));
// cout << " passed" << endl;
//}
// timing test for factorialRecursive, do it 10000 times and see
how much time
// elapses
// https://www.pluralsight.com/blog/software-
development/how-to-measure-execution-time-intervals-in-c--
//start = chrono::high_resolution_clock::now();
//for (int testnum = 0; testnum < NUM_TIMING_LOOPS;
testnum++)
//{
// res = factorialRecursive(20);
//}
//finish = chrono::high_resolution_clock::now();
//elapsed = finish - start;
//cout << "Elapsed time " << NUM_TIMING_LOOPS << "
loops of factorialRecursive(20) "
// << elapsed.count() << endl;
// test direct calculation version of counting combinations
cout << endl;
cout << "Testing combinations countCombinationsDirectly() "
<< endl;
cout << "-------------------------------------------------------------"
<< endl;
int i;
int n;
//n=5; i=0;
//res = countCombinationsDirectly(n, i);
6. //cout << "Test base case: n=" << n << " choose i=" << i << ":
" << res << endl;
//assert(res == 1);
//n=5; i=5;
//res = countCombinationsDirectly(n, i);
//cout << "Test base case: n=" << n << " choose i=" << i << ":
" << res << endl;
//assert(res == 1);
//n=0; i=0;
//res = countCombinationsDirectly(n, i);
//cout << "Test edge case: n=" << n << " choose i=" << i << ":
" << res << endl;
//assert(res == 1);
//n=5; i=1;
//res = countCombinationsDirectly(n, i);
//cout << "Test general case: n=" << n << " choose i=" << i <<
": " << res << endl;
//assert(res == 5);
//n=4; i=2;
//res = countCombinationsDirectly(n, i);
//cout << "Test general case: n=" << n << " choose i=" << i <<
": " << res << endl;
//assert(res == 6);
//n=15; i=6;
//res = countCombinationsDirectly(n, i);
//cout << "Test general case: n=" << n << " choose i=" << i <<
": " << res << endl;
//assert(res == 5005);
//n=15; i=14;
//res = countCombinationsDirectly(n, i);
7. //cout << "Test general case: n=" << n << " choose i=" << i <<
": " << res << endl;
//assert(res == 15);
// max factorial using bigint
//n=20; i=10;
//res = countCombinationsDirectly(n, i);
//cout << "Test general case: n=" << n << " choose i=" << i <<
": " << res << endl;
//assert(res == 184756);
// timing test for countCobminationsDirectory, do it 10000
times and see how much time
// elapses
// https://www.pluralsight.com/blog/software-
development/how-to-measure-execution-time-intervals-in-c--
//start = chrono::high_resolution_clock::now();
//for (int testnum = 0; testnum < NUM_TIMING_LOOPS;
testnum++)
//{
// n=20; i=10;
// res = countCombinationsDirectly(n, i);
//}
//finish = chrono::high_resolution_clock::now();
//elapsed = finish - start;
//cout << "Elapsed time " << NUM_TIMING_LOOPS << "
loops of countCombinationsDirectly("
// << "n=" << n << " choose i=" << i << ") :"
// << elapsed.count() << endl;
// test recursive calculation version of counting combinations
cout << endl;
cout << "Testing combinations countCombinationsRecursive()
" << endl;
cout << "-------------------------------------------------------------"
8. << endl;
//n=5; i=0;
//res = countCombinationsRecursive(n, i);
//cout << "Test base case: n=" << n << " choose i=" << i << ":
" << res << endl;
//assert(res == 1);
//n=5; i=5;
//res = countCombinationsRecursive(n, i);
//cout << "Test base case: n=" << n << " choose i=" << i << ":
" << res << endl;
//assert(res == 1);
//n=0; i=0;
//res = countCombinationsRecursive(n, i);
//cout << "Test edge case: n=" << n << " choose i=" << i << ":
" << res << endl;
//assert(res == 1);
//n=5; i=1;
//res = countCombinationsRecursive(n, i);
//cout << "Test general case: n=" << n << " choose i=" << i <<
": " << res << endl;
//assert(res == 5);
//n=4; i=2;
//res = countCombinationsRecursive(n, i);
//cout << "Test general case: n=" << n << " choose i=" << i <<
": " << res << endl;
//assert(res == 6);
//n=15; i=6;
//res = countCombinationsRecursive(n, i);
//cout << "Test general case: n=" << n << " choose i=" << i <<
": " << res << endl;
9. //assert(res == 5005);
//n=15; i=14;
//res = countCombinationsRecursive(n, i);
//cout << "Test general case: n=" << n << " choose i=" << i <<
": " << res << endl;
//assert(res == 15);
// max factorial using bigint
//n=20; i=10;
//res = countCombinationsRecursive(n, i);
//cout << "Test general case: n=" << n << " choose i=" << i <<
": " << res << endl;
//assert(res == 184756);
//cout << "Test equivalence of iterative and recursive solutions
for counting combinations" << endl
// << "This is an exhaustive test of all combinations of n
and i from 0 to 15" << endl;
//for (n = 0; n <= 15; n++)
//{
// for (i = 0; i <= n; i++)
// {
// cout << " Testing (n=" << n << " choose i=" << i << ")
equivalence...";
// assert(countCombinationsDirectly(n, i) ==
countCombinationsRecursive(n, i));
// cout << " passed" << endl;
// }
//}
// timing test for countCobminationsRecursive, do it 10000
times and see how much time
// elapses
// https://www.pluralsight.com/blog/software-
development/how-to-measure-execution-time-intervals-in-c--
10. //start = chrono::high_resolution_clock::now();
//for (int testnum = 0; testnum < NUM_TIMING_LOOPS;
testnum++)
//{
// n=20; i=10;
// res = countCombinationsRecursive(n, i);
//}
//finish = chrono::high_resolution_clock::now();
//elapsed = finish - start;
//cout << "Elapsed time " << NUM_TIMING_LOOPS << "
loops of countCombinationsRecursive("
// << "n=" << n << " choose i=" << i << ") :"
// << elapsed.count() << endl;
// return 0 to indicate successful completion
return 0;
}
Assg 04: Recursion
COSC 2336 Data Structures
Objectives
• Practice writing functions
• Practice writing recursive functions.
• Compare iterative vs. recursive implementation of functions.
• Learn to define base case and general case for recursion.
11. Description
In this assignment we will write a recursive function to
calculate what is
known as the binomial coefficient. The binomial coefficient is a
very useful
quantity, it allows us to count the number of combinations of
selecting i items
out of a set of n elements. For example, if we have 3 items A,
B, C, there are
3 ways to choose 1 element from the items: choose A, or choose
B or choose
C. There are also 3 ways to choose 2 elements from the items:
AB, AC, BC.
There is only 1 way to choose 3 elements from a set of 3 items:
ABC. When
we choose 2 elements from a set of 3 items, we normally speak
of this as
counting the number of combinations of 3 choose 2, and
mathematically we
write this as a binomial coefficient(
3
2
)
= 3 (1)
Where the result of the binomial coefficient is to count up the
number of
combinations we will have for n items when we select i
elements. As another
example, just to make this clear, if we have a set of 4 items,
ABCD, and we
choose 2 elements from this set, we get: AB, AC, AD, BC, BD,
12. CD = 6:(
4
2
)
= 6 (2)
1
Notice that for the binomial coefficient order doesn’t matter,
thus AB
and BA are considered the same when choosing 2 elements from
the set of
4, and we end up with only a count of 6 ways to choose 2 items
from a set
of 4 (look up permutations for a similar concept but where order
matters).
Mathematically we can compute directly the number of
combinations for
n choose i using factorials: (
n
i
)
=
n!
i!(n − i)!
13. (3)
Where ! represents the factorial of a number, as we discussed in
our
textbook.
However, another way of computing the number of
combinations is by
defining a recursive relationship:(
n
i
)
=
(
n − 1
i − 1
)
+
(
n − 1
i
)
(4)
You can think of this as the general case of a recursive function
that takes
two parameters n and i, and computes the answer recursively by
adding to-
gether two smaller subproblems. For this recursive definition of
14. the binomial
coefficient, the base cases are:(
n
0
)
=
(
n
n
)
= 1 (5)
We have already seen why n items choose n elements will
always be 1.
The other base case is used by definition, and simply means that
there is
only 1 way of choosing no items from a set (e.g. you don’t
choose).
In this assignment we will write several functions. First of all
you will
write your own version of the factorial function. Actually I want
you to write
two versions, a recursive version of factorial, and a version that
uses a loop
(iterative version). We will be using long int (64-bit) instead of
regular int
(32-bit) for all of the parameters and return values. You will
find a typedef
given to you in the starting .hpp template:
15. typedef long int bigint;
A typedef like this is really just an alias or name for the other
already
known type. In this case bigint means a long int. All of your
parameters
and return values for the functions in this assignment should be
defined to
be of type bitint. Why did we use the bigint? Well, the largest
result
from factorial that will fit into a regular 32-bit int is 12! =
479001600. By
2
using a 64-bit int, we can expand the maximum factorial we can
calculate a
bit, where 20! = 2432902008176640000 and this fits into a 64-
bit integer.
Then you will write two versions of the binomial coefficient to
count
combinations. One version will use one of your factorial
functions to directly
count the combinations, using the first formula given above.
Then your
second version will be a recursive version, that uses the
recursive general
and base case given to implement counting the number of
combinations.
For this assignment you need to perform the following tasks.
16. 1. Write a function called factorialIterative(). This function
should
take a single BIG integer (bigint) as its parameter n, and it will
com-
pute the factorial n! of the value and return it as its result (as a
bigint).
Write this functions using a loop (do not use recursion).
2. Write the factorial function again, but using recursion. Call
this func-
tion factorialRecursive(). The function takes the same
parameters
and returns the same result as described in 1.
3. Write a function called countCombinationsDirectly(). This
function
will compute the number of combinations that result from
choosing i el-
ements from set of n items. The function should take two bigint
values
as its parameters n and i, which will be integers >= 0. The
function
should use the equation 3 above to directly compute the number
of
combinations. You should use your factorialRecursive()
function
to compute the factorials in this function.
4. Write a function called countCombinationsRecursive(). This
func-
tion will also count the number of combinations of choosing i
elements
from a set of n items. However, you need to implement this
calcula-
tion as a recursive function, using the general and base cases
described
17. above for counting combinations in equation 4 (general case)
and equa-
tion 5 (base cases). Your function will take the same two bigint
pa-
rameters as input n and i with values >= 0, and will return a
bigint
result.
You will again be given 3 starting template files like before, an
assg-04.cpp
file of tests of your code, and a BinomialFunctions.hpp and
BinomialFunc-
tions.cpp header and implementation file. As before, you should
practice
incremental development, and uncomment the tests in the assg-
04.cpp file
one at a time, and implement the functions in the order shown.
If you im-
plement your code correctly and uncomment all of the tests, you
should get
the following correct output:
3
Testing iterative version factorialIterative()
-------------------------------------------------------------
Test base case: factorialIterative(0) = 1
Test edge case: factorialIterative(1) = 1
Test error case: factorialIterative(-1) = 1
Test general case: factorialIterative(10) = 3628800
Test general case (largest 32 bit int): factorialIterative(12) =
479001600
Test general case (largest 64 bit int): factorialIterative(20) =
2432902008176640000
18. Elapsed time 10000 loops of factorialIterative(20) 0.000880682
Testing recursive version factorialRecursive()
-------------------------------------------------------------
Test base case: factorialRecursive(0) = 1
Test edge case: factorialRecursive(1) = 1
Test error case: factorialRecursive(-1) = 1
Test general case: factorialRecursive(10) = 3628800
Test general case (largest 32 bit int): factorialRecursive(12) =
479001600
Test general case (largest 64 bit int): factorialRecursive(20) =
2432902008176640000
Test equivalence of iterative and recursive solutions from n=0
to 20:
Testing n = 0... passed
Testing n = 1... passed
Testing n = 2... passed
Testing n = 3... passed
Testing n = 4... passed
Testing n = 5... passed
Testing n = 6... passed
Testing n = 7... passed
Testing n = 8... passed
Testing n = 9... passed
Testing n = 10... passed
Testing n = 11... passed
Testing n = 12... passed
Testing n = 13... passed
Testing n = 14... passed
Testing n = 15... passed
Testing n = 16... passed
Testing n = 17... passed
Testing n = 18... passed
Testing n = 19... passed
Testing n = 20... passed
19. 4
Elapsed time 10000 loops of factorialRecursive(20) 0.00179999
Testing combinations countCombinationsDirectly()
-------------------------------------------------------------
Test base case: n=5 choose i=0: 1
Test base case: n=5 choose i=5: 1
Test edge case: n=0 choose i=0: 1
Test general case: n=5 choose i=1: 5
Test general case: n=4 choose i=2: 6
Test general case: n=15 choose i=6: 5005
Test general case: n=15 choose i=14: 15
Test general case: n=20 choose i=10: 184756
Elapsed time 10000 loops of countCombinationsDirectly(n=20
choose i=10) :0.00309266
Testing combinations countCombinationsRecursive()
-------------------------------------------------------------
Test base case: n=5 choose i=0: 1
Test base case: n=5 choose i=5: 1
Test edge case: n=0 choose i=0: 1
Test general case: n=5 choose i=1: 5
Test general case: n=4 choose i=2: 6
Test general case: n=15 choose i=6: 5005
Test general case: n=15 choose i=14: 15
Test general case: n=20 choose i=10: 184756
Test equivalence of iterative and recursive solutions for
counting combinations
This is an exhaustive test of all combinations of n and i from 0
to 15
Testing (n=0 choose i=0) equivalence... passed
24. Testing (n=15 choose i=10) equivalence... passed
Testing (n=15 choose i=11) equivalence... passed
Testing (n=15 choose i=12) equivalence... passed
Testing (n=15 choose i=13) equivalence... passed
8
Testing (n=15 choose i=14) equivalence... passed
Testing (n=15 choose i=15) equivalence... passed
Elapsed time 10000 loops of countCombinationsRecursive(n=20
choose i=10) :11.1177
Assignment Submission
A MyLeoOnline submission folder has been created for this
assignment. You
should attach and upload your completed .cpp source files to the
submission
folder to complete this assignment. You really do not need to
give me the
assg-04.cpp file again, as I will have my own file with
additional tests of
your functions. However, please leave the names of the other
two files as
BinomialFunctions.hpp and BinomialFunctions.cpp when you
submit them.
Requirements and Grading Rubrics
Program Execution, Output and Functional Requirements
1. Your program must compile, run and produce some sort of
output to
25. be graded. 0 if not satisfied.
2. 20 pts for implementing the factorialIterative() function
correctly.
3. 25 pts for implementing the factorialRecursive() function
correctly.
4. 15 pts for implementing the countCombinationsDirectly()
function
correctly.
5. 30 pts for implementing the countCombinationsRecursive()
function
correctly.
6. 5 pts. All output is correct and matches the correct example
output.
7. 5 pts. Followed class style guidelines, especially those
mentioned below.
Program Style
Your programs must conform to the style and formatting
guidelines given
for this class. The following is a list of the guidelines that are
required for
the assignment to be submitted this week.
1. Most importantly, make sure you figure out how to set your
indentation
settings correctly. All programs must use 2 spaces for all
indentation
9
26. levels, and all indentation levels must be correctly indented.
Also all
tabs must be removed from files, and only 2 spaces used for
indentation.
2. A function header must be present for member functions you
define.
You must give a short description of the function, and document
all of
the input parameters to the function, as well as the return value
and
data type of the function if it returns a value for the member
functions,
just like for regular functions. However, setter and getter
methods do
not require function headers.
3. You should have a document header for your class. The class
header
document should give a description of the class. Also you
should doc-
ument all private member variables that the class manages in
the class
document header.
4. Do not include any statements (such as system("pause") or
inputting
a key from the user to continue) that are meant to keep the
terminal
from going away. Do not include any code that is specific to a
single
operating system, such as the system("pause") which is
Microsoft
27. Windows specific.
10
/**
* @author Jane Programmer
* @cwid 123 45 678
* @class COSC 2336, Spring 2019
* @ide Visual Studio Community 2017
* @date January 22, 2019
* @assg Assignment 04
*
* @description Implementation file of function
implementations for
* the Binomial Coefficient functions. We have functions for
computing
* the factorial of an integer and for counting the number of
combinations
* of n choose i items in this library.
*/
#include "BinomialFunctions.hpp"
using namespace std;
/**
* @author Jane Programmer
* @cwid 123 45 678
* @class COSC 2336, Spring 2019
* @ide Visual Studio Community 2017
* @date January 22, 2019
* @assg Assignment 04
*
28. * @description Header file of definitions for implementation
* the Binomial Coefficient functions. We have functions for
computing
* the factorial of an integer and for counting the number of
combinations
* of n choose i items in this library.
*/
#ifndef _BINOMIALFUNCTIONS_H_
#define _BINOMIALFUNCTIONS_H_
#include <iostream>
using namespace std;
// global definitions
typedef long long int bigint; // give long int an alias name of
bigint
// Function prototypes for our BinomialFunctions library go
here
#endif // _BINOMIALFUNCTIONS_H_