Algorithms, autumn 2013 Given name Assignment 1 Family name Contact person: Olof Mogren Personnummer e-mail By submitting, you agree to http://www.cse.chalmers.se/edu/course/TIN092_Algorithms_LP1/#assignments . Good luck! Problem 2: Brute Force. Consider http://www.cse.chalmers.se/edu/course/TIN092_Algorithms_LP1/a1/a12sup.pdf . a) [points:2] Explain briefly (1-2 sentences), in English, how you would solve this problem using the brute force problem solving method 1 . Then give an algorithm, in pseudocode, which solves the problem in the manner you described. b) [points:1] Justify the correctness of your algorithm. That is, that your algorithm produces a valid solution (a path), and that the solution produced is the optimal one amongst all valid solution proposals (all paths). c) [points:1] Give a function f of m and n which bounds above the running time of your algorithm. Explain2 why f does so. State which operations you regard as unit-time operations. The bound should be as low as possible (for n instance, don’t choose nn ). d) [points:4] Implement your algorithm from a) such that it conforms to the input-output specification given in the problem description. Submit your source code (1 (uncompressed) file) to the Fire system. You may assume that all inputted integers, and all path weights, fit into a 32-bit space. Five test inputs and corresponding outputs are provided alongside this assignment, stored in files i1, . . . , i3, o1, . . . , o3 (on is the expected result of running your program on the input contained in in). If working on the Chalmers machines, you can test your programs on, say, i1, as follows: • If your program has been compiled to a binary (named “program”), run cat i1 | ./program • If your program is interpreted (for instance, a Java class file Program.class), run something like cat i1 | java Program 1 2 See http://en.wikipedia.org/wiki/Brute-force_search or notes from Exercise Session 1 if you are in doubt what this means. Like the book does; see e.g. [KT p. 48, 51-53]
© Copyright 2026 Paperzz