Question: answer all #include #include #include // size_t // bucket of size n stores the smallest (at most) n ints ever inserted within itself. class min_bucket
answer all
#include
// bucket of size n stores the smallest (at most) n ints ever inserted within itself.
class min_bucket { public: min_bucket(size_t); ~min_bucket(); void insert(int); int operator[](size_t); // copy constructor and copy assignment unavailable min_bucket(const min_bucket&) = delete; min_bucket& operator=(const min_bucket&) = delete; private: size_t size, count; int* nums = nullptr; };
min_bucket::min_bucket(size_t n): size(n), count(0) { nums = new int [n]; if (nums == nullptr) throw std::exception(); }
min_bucket::~min_bucket() { delete [] nums; }
void min_bucket::insert(int x) { int i=0; while (i nums[i]) i++; // now i is in the correct insertion position if (i >= size) return; // "move" items before inserting: // This is the for statement from the text you // must fix. j should count down, not up. for (int j = /* ??? */; /* ??? */; --j) { if (j+1
int min_bucket::operator[](size_t n) { if (n >= size) throw std::exception(); return nums[n]; }
int main() { std::mt19937 e; // Twister engine std::uniform_int_distribution
// min_bucket size 5 min_bucket bukit(5); // insert random ints for (int i=0; i
Fix the following program


Professor Elbow-Patch is not the man he used to be, and in particular has a tendency to fall over for no apparent reason. This problem is made worse if he has drunk port with his dinner. He almost always drinks port on a Sunday, and if he drinks on any given day he is unlikely-for the sake of his long-suffering liver-to drink port on the following day. However, if he does not drink on a given day then he is very likely to succumb to temptation on the following day. The probability that he falls over after drinking is Pr(fall|drank) = 0.7. The probability that he falls over when he has not drunk is Pr(fall/-drank) = 0.1. He drinks on a Sunday with probability 0.9. If he has not drunk on a given day then the probability that he drinks the following day is Pr(drink today|-drank yesterday) = 0.8. If he has drunk on a given day then the probability that he drinks the following day is Pr(drink today(drank yesterday) = 0.1. (a) Explain how this problem can be represented as a hidden Markov model. What assumptions are required? [4 marks] (b) Denoting observations at time i by E; and states at time i by S; give a derivation of the filtering algorithm for computing Pr( St| E1, .. ., Et). [8 marks](a) For a domain D, recall that by Tarski's Fixed-Point Theorem every continuous function fe (D - D) has a least pre-fixed point fur(/) E D. Prove that the function fix : (D - D) - D is continuous. [10 marks] (b) For a partially ordered set (P. [), let (Ch(P), [pew ) be the partially ordered set of chains in P ordered pointwise. That is, Ch(P) = = {{n)nEN | for all i j in N, r, Cr; in P and I Cpew p' fer In [ r, for all n EN Show that if P is a domain then so is Ch(P). [10 marks]
Step by Step Solution
There are 3 Steps involved in it
Get step-by-step solutions from verified subject matter experts
