Horner’s Rule Polynomials

This program generates 25 polynomials of increasing degree randomly using a Mersenne twister, solves them via Horner’s rule and records runtime. /////////////////////////////////////////////////////////////////////////////// #include <iostream> #include <vector> #include <random> #include <iomanip> #include <chrono> /////////////////////////////////////////////////////////////////////////////// std::vector<int> randIntGen(int count); float randRealGen(void); void polyPrint(float x, std::vector<int> polyVals); void hornersRuleTime(float x, int n, std::vector<int> polyVals); …

RSA Decryption

/////////////////////////////////////////////////////////////////////////////// // This program takes a RSA encrypted message in a text file, // by given parameters, and decrypts it. After which it outputs to console. /////////////////////////////////////////////////////////////////////////////// #include <iostream> #include <fstream> #include <sstream> #include <vector> #include <math.h> /////////////////////////////////////////////////////////////////////////////// void fileRead(std::ifstream &inFile, std::vector &fileBuff); void decrypt(std::vector<int> cipherText, std::vector<char> &plaintText, int pq, …

Kruskal’s and Prim’s algorithm on weighted adjacency matrice

This program takes an input WAM, and applies Kruskal’s and Prim’s algorithms to it. /////////////////////////////////////////////////////////////////////////////// #include <iostream> #include <vector> #include <sstream> /////////////////////////////////////////////////////////////////////////////// struct Edge { int vertOne, vertTwo, weight; Edge(int one, int two, int passedWeight) { this->vertOne = one; this->vertTwo = two; this->weight = passedWeight; } }; class Vertex { …

Set Operations

This program generates the intersection, union, relative composition, cross product, and power set, of given input (which generates the sets the operations are performed on. ///////////////////////////////////////////////////////////////////////////////// #include <iostream> #include <vector> #include <algorithm> #include <iterator> #include <sstream> //////////////////////////////////////////////////////////////////////////////// std::vector<std::string> createSet(void); // creates set from user input std::vector<std::string> getIntersection(std::vector<std::string> set_A, std::vector<std::string> set_B); …

Modulo Congruence

//////////////////////////////////////////////////////////////////////////////// #include <iostream> #include <math> //////////////////////////////////////////////////////////////////////////////// void numberQuery(unsigned long long &a, unsigned long long &n, unsigned long long &m); unsigned long long powertworesidual(unsigned long long a, unsigned long long n, unsigned long long m); unsigned long long nonpowertworesidual(unsigned long long a, unsigned long long n, unsigned long long m); //////////////////////////////////////////////////////////////////////////////// …