乐趣区

关于算法:COMP-SCI-2201-7201-Algorithm-设计

COMP SCI 2201 & 7201 Algorithm and Data Structure Analysis Semester 1, 2021
Minimum Spanning Trees, Euler Path, Undecidable
Problems, and Turing Machines
Exercise 1 Kruskal’s Algorithm
Compute a minimum spanning for the following graph using Kruskal’s algorithm. Show
the status of your partial minimum spanning tree after each edge insertion and indicate
for each edge whether it is included in the minimum spanning tree.
Tutorial 5: Hashtables and Topological Sorting
General Instructions
You do not need to submit your solution. We will discuss the questions during the
workshop sessions in week 10.
Exercise 1 Hash Tables

  1. Insert the key sequence 7, 18, 2, 3, 14, 25, 1, 11, 12, 1332 with hashing by chaining
    in a hash table with size 11. Please show the final table by using the hash function
    h(k) = k mod 11.
  2. Please show the final table if we use linear probing instead.
  3. Investigate by yourself what is“quadratic probing”and“double hashing”. Both
    can be considered improved versions of linear probing. Please find out where they
    improve upon linear probing.
    Exercise 2 Single-source-shortest path problem in acyclic graphs
    We consider the single-source-shortest path problem of a given directed graph G = (V,E)
    with non-negative edge weights and a source node s. Furthermore, we assume that the
    given graph G is acyclic, i. e. it does not contain a cycle.
    ? Give an algorithm (in pseudo-code) that solves the single-source-shortest path prob-
    lem for a given acyclic graph in time O(m + n).
    ? Prove the correctness of your algorithm.
    ? Explain why your algorithm runs in time O(m + n).
    End of Questions
    Exercise 2 Euler tours of directed graphs
    A Hamiltonian tour is a tour that visits every node of a strongly directed graph just once.
    Determining if a Hamiltonian tour exists is an NP-Complete problem.
    In contrast an Euler tour of a strongly connected directed graph G = (V,E) is a cycle
    that traverses each edge of G exactly once, although it may visit a node more than once.
    Answer the following questions:
    ? Show that G has an Euler tour if and only if the in-degree of every node v equals
    the out degree of v.
    ? Describe an O(m) (where m is the number of edges in G) algorithm to find an Euler
    tour of G if such a tour exists (Hint: Merge edge-disjoint cycles).
    1
    COMP SCI 2201 & 7201 Algorithm and Data Structure Analysis Semester 1, 2021
    Exercise 3 We define the following program: Does program Q, given input y, print either
    ”Hello world”or”Goodbye world”as its first output?
    Use reduction to prove that the above program is undecidable.
    Exercise 4 On https://turingmachine.io/, implement the Turing machine that tests
    whether the input is a UoA ID. That is, whether the input starts with a, and is then
    followed by 7 digits.
    Tutorial 5: Hashtables and Topological Sorting
    General Instructions
    You do not need to submit your solution. We will discuss the questions during the
    workshop sessions in week 10.
    Exercise 1 Hash Tables
  4. Insert the key sequence 7, 18, 2, 3, 14, 25, 1, 11, 12, 1332 with hashing by chaining
    in a hash table with size 11. Please show the final table by using the hash function
    h(k) = k mod 11.
  5. Please show the final table if we use linear probing instead.
  6. Investigate by yourself what is“quadratic probing”and“double hashing”. Both
    can be considered improved versions of linear probing. Please find out where they
    improve upon linear probing.
    Exercise 2 Single-source-shortest path problem in acyclic graphs
    We consider the single-source-shortest path problem of a given directed graph G = (V,E)
    with non-negative edge weights and a source node s. Furthermore, we assume that the
    given graph G is acyclic, i. e. it does not contain a cycle.
    ? Give an algorithm (in pseudo-code) that solves the single-source-shortest path prob-
    lem for a given acyclic graph in time O(m + n).
    ? Prove the correctness of your algorithm.
    ? Explain why your algorithm runs in time O(m + n).
    End of Questions

    WX:codehelp

退出移动版