2

I'm revising for an Algorithms exam and looking at a sample question it says :

A group of n teenagers $t_1, \dots, t_n$ are to sit in a single row of n chairs watching a particulary boring comedy movie. Some teenagers quarrel with each other all the time. The Problem is to devise a seating arrangement for the group in such a way that teenagers sat next to each other do not quarrel.

Propose a solution to this problem using the Greedy approach. Estimate the complexity of the resulting algorithm.

In lectures for greedy problems we've only covered Knapsack Problems so Next Fit/Best Fit for Bin Packing. I can't seem to understand how these methods have any relevance to coming up with a solution for the question.

Obviously I don't expect anyone to answer this, since I've not even made an attempt. But in honesty I don't know where to start. If you guys could give me some sort of hints or just general advice because I'm pretty stranded at the minute.

user26234
  • 29
  • 2

1 Answers1

0

I don't know if i understood your exercise. But pick a arrangement with n students in n positions is a permutation, so there are n! possible arrangements. So, it's look like a Hamiltonian path problem, where each student is a graph's vertex and there's an edge i,j if the student i can sit next to student j, with no quarrel. If you can find some Hamiltonian path, you have a arrangement. For greedy algorithm you can propose a heuristic that visit first the vertex with low degree (number of edges incident to the vertex), meaning that the most annoying student will be chosen to sit on the first place of the row.

robot_s
  • 49
  • 3