CSCI 255 Fall 2024
Introduction to Algorithms and Discrete Structures
Charles Cusack
Computer Science
Hope College
Main
Schedule
Grading
Gradebook
Homework

Policies
College
    Policies
Advice

Notes
Programs
Tutorials
Handin

CSCI 125
CSCI 255
MATH 131 (01 and 02)
Others

Admin

Homework 10

General Comments

  • For full credit, provide context for each problem, show all calculations, and justify all answers by providing enough comments to explain your reasoning.
  • Homework assignments must be very neatly written or typeset (e.g. using Word or OpenOffice).
  • You can get up to 50% credit on a problem if you get significant outside assistance. Thus, if you are totally stuck on a problem it might be worth getting help. However, you must indicate any assistance/collaboration (See the Homework Assistance section on the Policies page). Failure to do so could result in a failing grade for the course! Note that getting help from the Help Center or me does not count as significant outside assistance, but talking with your classmates or searching on the Internet does!
  • If a problem asks for an algorithm, you should give the most efficient algorithm you can find to ensure full credit. You should also specify the complexity of the algorithm with justification, whether or not the problem asks for it.

Details

  1. (10) A magic square of order n is an n×n matrix with the numbers 1 through n2 arranged such that each number occurs exactly once and each row, column, and diagonal sum is the same.
    1. Prove that the row/column/diagonal sum has to be n(n2+1)/2.
    2. Design an exhaustive-search algorithm to generate all magic squares of order n. As always, do not forget to give the worst-case complexity of your algorithm!
      Note: Do not look up an algorithm. Come up with your own!
  2. (8) Let G be a graph with edge (a,b). Give an algorithm that will determine whether or not the edge (a,b) is on a cycle of the graph. As always, do not forget to give the worst-case complexity of your algorithm! (Hint: Modify an existing algorithm instead of starting from scratch.)