SPBU's F# 1—2 semester homeworks
Implement things below.
- A function that takes two numbers (base and exponent) and calculates the
power in a naive way
. - A function that takes two numbers (base and exponent) and calculates the
power using fast exponentiation
. - A function that takes an array and returns the
difference between the largest and smallest elements
in that array. - A function that takes two integers and returns an
array of odd numbers
strictly between them. - Add
tests
for all of this functions.
For two types of lists, invented during the class, implement things below.
Bubble Sort
— a function that takes a list and returns the sorted list.Quick Sort
— a function that takes a list and returns the sorted list using the Hoare partition scheme.Concatenation
of two lists — a function that takes two lists and returns a third list, which is the concatenation of the two input lists- Add
tests
for all of this functions.
Use recursion and unmutable variables.
- Describe an algebraic type that defines a
tree
in which each node can have an arbitrary number of children. The leaves and nodes store values of some arbitrary (same for all) type. - Implement a function that finds the number of
different elements
stored in the nodes. - Implement a function that constructs a list containing
all the values from all the nodes
. - Add
tests
for all of this functions.
- Using algebraic data types, implement the
trees
necessary for representing sparse matrices and sparse vectors. Provide the ability to store values of different types in vectors and matrices (matrices can have rows of strings, rows of integers, etc.). - Implement the
vector type
and thematrix type
using the previously implemented trees. - Implement a function for
multiplying a vector by a matrix
. - Add
tests
for all of this functions.
- Implement the
necessary operations
for BFS. The mask can be any vector. The element-wise operation can be any operation. - Implement the
BFS
algorithm using matrix-vector operations. - Add
tests
for both individual operations and the BFS.
- Configure FSharpLint to run on the server during project build.
- Learn how to read files in the matrix market format.
- Learn how to construct a
graph
based on the read adjacency matrix. - Implement
parallel versions
of matrix and vector operations. - Conduct
experimental performance
research on BFS and answer the questions below. a. Under what graph parameter settings is it more beneficial to use the parallel version of the algorithm? b. What is the optimal number of threads that yields the highest performance improvement? Why? - Prepare a report on the conducted research.
Make sure the following requirements are installed on your system:
- dotnet SDK 3.0 or higher (recommended 6.0+)
- Mono if you're on Linux or macOS. or
- VSCode Dev Container
> build.cmd <optional buildtarget> // on windows
$ ./build.sh <optional buildtarget> // on unix
To find more options take a look at the MiniScaffold template.