Task 1: Iterators & Generators – Fibonacci Numbers (20 Points)
First, write an iterator class (FibonnaciNumberIterator) which allows to iterate over the Fibonnacci numbers (possibly infinitely many …). Fibonacci numbers fib(n) for n=1,2, … are defined as follows: fib(1)=fib(2)=1, fib(n)=fib(n-1)+fib(n-2), for n greater or equal to 3.
Second, write a generator class (FibonacciNumberGenerator) which generates (also possibly infinitely many) Fibonnaci numbers.
Write unit tests for both the iterator and the generator implementations, testing the Fibonnacci numbers for n=1,2,…,10. The tests should, of course, finish in finite time. The tests should assess all methods of the two classes, and should of course test for the correctness of the implementation.
Task 2: Recursion & Decorators (20 Points)
First provide a recursive implementation of a function which returns the nth fibonnacci number. This function should be named fib, then fib(1) should return 1, fib(2) should return 1, fib(3) should return 2, and so on (see the definition of the Fibonnaci numbers in Task 1).
Then, implement a decorator function trace (hint: a “higher order function”) which takes a function fun as an argument, calls the function, and both prints the arguments the function fun is called with as well as the value that function fun returns. To make the output more readable, add indentation levels to (recursive) function calls, such that an indented “|-- “ is printed for each recursive call, while increasing the “indentation depth” level by level of the recursion. As a test, use your decorator function, for tracing the function fib.
Then, as an example, fib(5) would result in something like the following output:
|-- fib 5
| |-- fib 4
| | |-- fib 3
| | | |-- fib 2
| | | | |-- return 1
| | | |-- fib 1
| | | | |-- return 1
| | | |-- return 2
| | |-- fib 2
| | | |-- return 1
| | |-- return 3
| |-- fib 3
| | |-- fib 2
| | | |-- return 1
| | |-- fib 1
| | | |-- return 1
| | |-- return 2
| |-- return 5 5
In the file that you submit, provide some example output, calling the decorated function fib with exemplary input, e.g. using fib(5) for producing output similar to that shown above.
Task 3: OOP Design: Graphs and a simple Graph Generator (20 Points)
A graph generator is a program for generating random graphs (also known as random networks, or social networks) according to some models. A graph consists of nodes and edges. Edges can be undirected and directed. Implement the specific classes in good object-oriented fashion.
A simple strategy for generating graphs is the Erdos-Renyi model. In the Erdos-Renyi model, the number of nodes n is specified, in addition to an edge probability p. Then, in the graph generation, each of all possible edges in the graph are chosen with probability p. Implement a Erdos-Renyi generation strategy using the Strategy Pattern for directed and undirected graphs (each), with a generate method. Provide unit tests for the classes (instantiation), and graph generation, where you test for typical cases and difficult border cases.
For the implementation, you are not allowed to use any graph-/network-specific packages like NetworkX, etc. Numpy and SciPy are allowed.
Task 4: Optimization – Graph Generation (20 Points)
Another model for graph generation is the Barabasi-Albert model: Here, the network begins with an initial connected network of m’ nodes (initially 1). Then, new nodes are added to the network one at a time, until a maximum number of nodes max_nodes is reached. Each new node is connected to m <= m’ nodes with a probability proportional to the number of links that the existing nodes already have, i.e.
for each node i with a probability pi as follows:
where ki is the degree of node i, and the denominator sums over all the pre-existing nodes j. The degree of a node is the number of connections (edges) it has so far.
Implement a Graph-Generator according to the model above which returns the generated graph using the generate method, i.e. implement this in an OOP design using the Strategy Pattern. Optimize your graph generator in at least two different methodological ways (e.g. using functional programming and Numba), and test the impact (using the timeit function). Document that in your IPython Notebook. Provide unit tests for the graph generation, where you test for typical cases and difficult border cases.
For the implementation, you are not allowed to use any graph-/network-specific packages like NetworkX, etc. Numpy and SciPy are allowed.
CS 340 Milestone One Guidelines and Rubric Overview: For this assignment, you will implement the fundamental operations of create, read, update,
Retail Transaction Programming Project Project Requirements: Develop a program to emulate a purchase transaction at a retail store. This
7COM1028 Secure Systems Programming Referral Coursework: Secure
Create a GUI program that:Accepts the following from a user:Item NameItem QuantityItem PriceAllows the user to create a file to store the sales receip
CS 340 Final Project Guidelines and Rubric Overview The final project will encompass developing a web service using a software stack and impleme