Include and use as follows:
// one for int -> int
#define HASHTABLE_KEY_TYPE int
#define HASHTABLE_VALUE_TYPE int
#define HASHTABLE_ADT_NAME IntHashTable
#include "hashtable.h"
// one for string -> int
Include and use as follows:
// one for int -> int
#define HASHTABLE_KEY_TYPE int
#define HASHTABLE_VALUE_TYPE int
#define HASHTABLE_ADT_NAME IntHashTable
#include "hashtable.h"
// one for string -> int
In the exercises and assignments, you may have made use of the >>
operator. If not, here is its implementation:
(>>) :: (Monad m) => m t -> m u -> m u
a >> b = a >>= (\_ -> b)
It behaves identically to >>=
, except that it discards the result of the first monadic operation.
Prove by careful equational reasoning that >>
is associative, i.e. (a >> b) >> c == a >> (b >> c)
.
Give an example to explain why >>=
must be left-associative.
#include <cassert> | |
#include <string> | |
// A storage class for DNA sequences, which are sequences (i.e. strings) | |
// consisting of one of four bases: A, C, T and G. | |
class dna_store { | |
public: | |
// Adds a sequence to the store. You may assume that the sequence | |
// is a nonempty string made up only of the letters {A, C, T, G}. | |
void add(const std::string &seq) { |
#include <cassert> | |
#include <vector> | |
// Given some price information at discrete time intervals, returns a suitable | |
// value for the price at a given time interval. You may assume that times is | |
// sorted in ascending order, and that there are at least two datapoints (i.e. | |
// prices for at least two times). | |
auto stock_price(int time, std::vector<int> const ×, | |
std::vector<float> const &prices) -> float { | |
return 0; |
eval
first, and then try satisfiable
.eval.c
and satisfiable.c
to your machine by copy/pasting the code into files with the same name.dcc -o eval eval.c
and dcc -o satisfiable satisfiable.c
respectively.######################## | |
# File system commands # | |
######################## | |
# Show the current working directory | |
pwd | |
# View the contents of the working directory | |
ls |
% I'm assuming you have the package imported already | |
\usepackage{bussproofs} | |
% In these examples, I like indenting the InfC part of each proof tree from the AxiomC(s) that spawned it, | |
% and keeping those AxiomC(s) on the same indent level, but I keep the bottom, final InfC unindented | |
% This is a personal choice but it makes it easier to keep track of what's happening for large trees | |
% A rule with no assumptions (i.e. an axiom) | |
\begin{prooftree} | |
\AxiomC{} |
These exercises are some I did while studying for COMP2521, as well as some others which I've found afterwards which I think will be relevant. I've collected these problems mostly from LeetCode and HackerRank, which are excellent sites for practicing your coding abilities. Accounts on both sites will be necessary to do the problems listed.
The difficulty ranking is obviously my opinion, but generally speaking here is what they mean:
If you're able to solve the easy and intermediate problems without much difficulty, you're probably very well prepared for any programming questions you'll receive in the ex