Class SomePlumbers

java.lang.Object
topics.greedy.SomePlumbers

public class SomePlumbers extends Object
GREEDY ALGORITHM PROBLEM: SOME DILIGENT PLUMBERS It has an optimal solution
Author:
vicegd
  • Constructor Details

    • SomePlumbers

      public SomePlumbers()
  • Method Details

    • getTotalTimeOfWait

      public int getTotalTimeOfWait(int[][] plumbers)
      Calculates the total waiting time of customers
      Parameters:
      plumbers - Information about the tasks that any plumber performs
      Returns:
      Total waiting time
    • orderInWhichTasksAreHandledBADWAY

      public void orderInWhichTasksAreHandledBADWAY(int[] tasks, int[] times)
      Sorts the tasks in a random order. In fact, it does not change anything O(n)
      Parameters:
      tasks - Final order in which the different tasks are going to be done
      times - Times for the different tasks to be done
    • assignTasksToPlumbersBADWAY

      public void assignTasksToPlumbersBADWAY(int[][] plumbers, int[] tasks)
      Assigns tasks to plumbers
      Parameters:
      plumbers - To save the tasks that any of the plumbers are going to perform
      tasks - Final order in which the different tasks are going to be done
    • orderInWhichTasksAreHandledBESTWAY

      public void orderInWhichTasksAreHandledBESTWAY(int[] tasks, int[] times)
      Sorts the tasks from smallest to biggest O(n) + O(nlogn) - O(nlogn)
      Parameters:
      tasks - Final order in which the different tasks are going to be done
      times - Times for the different tasks to be done
    • assignTasksToPlumbersBESTWAY

      public void assignTasksToPlumbersBESTWAY(int[][] plumbers, int[] tasks)
      Assigns tasks to the less busy plumber
      Parameters:
      plumbers - To save the tasks that any of the plumbers are going to perform
      tasks - Final order in which the different tasks are going to be done