Assignment Week 6 - Graphs and Combinatorics
Please submit using the Fire system
Assignments
(1.) For a directed graph ("riktad graf") G with n nodes, what is the maximum number of arrows ("pilar", "riktade kanter") we can have, without G having a cycle?
Examples:
- A directed graph with 2 nodes can have 1 arrow without there being a cycle, but it must have a cycle with more than 1 arrow.
- A directed graph with 3 nodes can have 3 arrows without there being a cycle, but it must have a cycle with more than 3 arrows.
- A directed graph with 4 nodes can have 6 arrows without there being a cycle, but it must have a cycle with more than 6 arrows.
Express your answer A in terms of n. For your answer, explain both:
(a) that there exist directed graphs that have A arrows and no cycles, and
(b) that directed graphs with more arrows than A must have a cycle.
Hint: A graph without cycles must have a topological order. Once you know the order of the nodes, which arrows can you add without introducing a cycle?
See also exercise 10 from last week.
|
(2.) How many different strings can you form using exactly the 8 letters A, N, A, C, O, N, D, A in any order?
Compute your answer in two different ways: (a) Write a program that enumerates all possibilities, and (b) Show how the answer can be calculated using formulas from combinatorics.
Ideally, you should get the same answer :)
Hint: If you write your program in Haskell, use the standard Haskell functions nub and permutations from the module Data.List. Don't forget to import Data.List.
|
Submission
Submission of this assignment should be done electronically through the Fire system.
The submission deadline is Friday, October 20, at 23:59. At this time, you should have submitted a serious attempt to solve the assignment. A serious attempt is either an answer you believe to be correct, or a partial answer plus a detailed explanation of what you have tried to come up with a full answer. An empty document is not a serious attempt.
After submitting, you have until Sunday October 29 (midnight) to submit a completely correct version.
You can submit your answers in any of the following formats:
If you submit multiple files, please name and/or number them such that the order in which we should read them is obvious. You can also write a text file, and have it refer to pictures that you upload separately.
|