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 elementsin that array. - A function that takes two integers and returns an
array of odd numbersstrictly between them. - Add
testsfor 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.Concatenationof two lists — a function that takes two lists and returns a third list, which is the concatenation of the two input lists- Add
testsfor all of this functions.
Use recursion and unmutable variables.
- Describe an algebraic type that defines a
treein 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 elementsstored in the nodes. - Implement a function that constructs a list containing
all the values from all the nodes. - Add
testsfor all of this functions.
- Using algebraic data types, implement the
treesnecessary 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 typeand thematrix typeusing the previously implemented trees. - Implement a function for
multiplying a vector by a matrix. - Add
testsfor all of this functions.
- Implement the
necessary operationsfor BFS. The mask can be any vector. The element-wise operation can be any operation. - Implement the
BFSalgorithm using matrix-vector operations. - Add
testsfor 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
graphbased on the read adjacency matrix. - Implement
parallel versionsof matrix and vector operations. - Conduct
experimental performanceresearch 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 unixTo find more options take a look at the MiniScaffold template.