solution
1 Approved Answer![]() Malla s 3 Ratings, (9 Votes) Answer:
Working code implemented in C++ and appropriate comments provided for better understanding. Here I am attaching code for these files:
AAGenerator.cpp Code: #include <utility> using namespace std; bool debug = false; class attribute { std::string name; class query { std::string query_s; void remove_carriage_return(std::string& line) { std::vector<attribute> readAttributes(const std::string &attribute_file_name) { vector<attribute> attributes; if (!attribute_file) { string line; if (debug) { return attributes; std::vector<query> readQueries(const std::string &queries_file_name) { if (!queries_file) { string line; if (debug) { return queries; vector<vector<int>> readAccessFrequency(const std::string &freq_file_name, unsigned long no_queries) { if (!access_file) { string line; size_t current; if (debug) { return access; vector<vector<int>> populateUsage(vector<attribute> attributes, vector<query> queries) { for (int i = 0; i < queries.size(); i++) { if (debug) { } else { } if (debug) { return usage; bool textBook = false; for (int i = 0; i < no_attributes; i++) { if (textBook) { // Method described in the text book for (int x = 0; x < access[k].size(); x++) { // sum up the usage across the sites int totalSum[no_queries]; // Calculate the number of times each query is executed on each site // A_ik = use (q_k, A_i) * sum (all sites) access_matrix(q_k,S_j) return affinity; /** // Parse command line arguments if (argc != 4) { // The first argument is the name of the program vector<attribute> attributes = readAttributes(attributes_file); vector<vector<int>> affinity = populateAffinityMatrix(usage, access, attributes.size(), queries.size()); for (int i = 0; i < affinity.size(); i++) { AAGenerator.h Code: #ifndef ASSIGNMENT1_AAGENERATOR_H
};
|
评论
发表评论