#include #include #include #include #include #include using namespace std; // missing lines struct memo { int argument; int value; memo*left; memo*right; }; // missing lines void insert(memo*&root,int n,int val); memo*find(memo*root,int n) { if(root) if(n == root->argument) return root; else if (n < root->argument) return find(root->left,n); else if (n > root->argument) return find(root->right,n); else assert(false); else return NULL; } int fetch(int n) { memo*nplace = find(rootmemo,n); if (nplace) return nplace->value; else { int rslt = 1+fetch(f(n)); insert(rootmemo,n,rslt); return rslt; } } // missing lines int main() { // missing lines for(int n = 1; n <= maxn; n++) cout << "f*(" << n << ") = " << fetch(n) << endl; // more missing lines return 0; }