# Is this still a Greedy Algorithm

As a preface I will state this is for a homework assignment. I have already discussed this with the professor and will not be using this design. This purpose of this question is whether or not the defined algorithm is greedy. Also if this is in the wrong section I apologize and please let me know where it should be asked.

I would like to know if the following algorithm would be considered as a greedy algorithm. There are two stages for the algorithm but I am interested in the algorithm as a whole.

First stage: Run a series of pre-defined greedy algorithms. Each algorithm would come up with a solution for the overall problem. For example, given the scheduling problem, if I had the following alogorithms:

1. Pick the longest request of all choices.
2. Pick the shortest request of all choices.
3. Pick the latest ending request of all choices.

Second stage: I would now have three "solutions" to choose from. I now pick the "best" solution from some criteria, say maximum number of requests scheduled.

Is this two stage algorithm considered to be a greedy algorithm since all of the parts themselves are greedy?

• For the second stage, what would separate a greedy choice from an optimal choice? Usually greedy algorithms don't pick the "best" choice, they pick the choice that brings the most gain in the present state. Commented Nov 26, 2014 at 22:57
• @afuzzyllama: Greedy algorithms can be optimal. And yes, I still consider it greedy, even though it combines other greedy algorithms by picking the best result found. Commented Nov 26, 2014 at 23:05
• @afuzzyllama The way that I see this is that the second stage would pick the option according to its design. In the example above I mentioned maximum number of requests, so the second stage would pick from the three options which ever one scheduled the most number of requests. In this design the second stage would only have one iteration of choices to make. Commented Nov 26, 2014 at 23:06
• @Deduplicator I wasn't saying it cannot be optimal, but usually it isn't designed with that in mind. Commented Nov 27, 2014 at 2:30