This file holds ideas for new sample problems to be completed using DALPy.
You are tasked with adding a new 2D array data structure to DALPy. However, this data structure will be efficient at representing sparse 2D arrays. That is, arrays that are primarily made up of zeros.
You have to implement this as a Python class that supports the following functionality:
- Initialize
Sparse2Dto have particular dimensions. - Get the value at a row, column index.
- Set the value at a row, column index.
- Multiply each element in it by a scalar.
- Add another
Sparse2Dto it. - Right multiply another
Sparse2Dwith it.
You are tasked with adding a new 2D array data structure to DALPy. However, this data structure will be efficient at representing sparse 2D arrays as well as multiplying them.
You have to implement this as a Python class that supports the following functionality:
- Initialize
FastMultiply2Dto have particular dimensions. - Get the value at a row, column index.
- Set the value at a row, column index.
- Multiply each element in it by a scalar.
- Add another
FastMultiply2Dto it. - Right multiply another
FastMultiply2Dwith it.
You are tasked with building a new hash table to DALPy. You will build upon the standard chaining hash table so that when its keys are returned, they are in the order in which they were inserted.
You have to implement this as a Python class that supports the following functionality:
- Initialize
OrderedHashTable. - Insert a new key, value pair.
- Get the value associated with a key.
- Delete a key, value pair.
- Check if the
OrderedHashTablecontains a particular key. - Get the keys of the
OrderedHashTablein the order in which they were inserted.
Note: If a key was removed, then reinserted, it should be placed at the end (i.e. not in its original place).
Given a sorted Array of tuples of the form (x, y) and a point x, find y by linear interpolation fits two nearest points.