1 / 4

Lab11

Lab11. Heap. Goal . Manage a set of "tasks" using a " Heap " data structure implemented as a Min -Priority Queue. The Heap is used to simulate a task manager. The task manger will be responsible for executing the next task and accept a new task.

Download Presentation

Lab11

An Image/Link below is provided (as is) to download presentation Download Policy: Content on the Website is provided to you AS IS for your information and personal use and may not be sold / licensed / shared on other websites without getting consent from its author. Content is provided to you AS IS for your information and personal use only. Download presentation by click this link. While downloading, if for some reason you are not able to download a presentation, the publisher may have deleted the file from their server. During download, if you can't get a presentation, the file might be deleted by the publisher.

E N D

Presentation Transcript


  1. Lab11 Heap

  2. Goal • Manage a set of "tasks" using a "Heap" data structure implemented as a Min-Priority Queue. The Heap is used to simulate a task manager. The task manger will be responsible for executing the next task and accept a new task. • Each task has a name and priority number. (e.g., eclipse: 4). The number represents the priority of the task. The smaller the number, the higher the priority of the task. For example, one task with number 1 has higher priority than the one with number 6. • Assume that each task is completed when it is removed from the heap. • Sometimes tasks are added into a heap with very high priority number (low priority). If the priority number remains unchanged while the task is in the heap, it is possible that it will never get executed due to newer tasks being added with a lower priority number (higher priority). Thus, when a task is removed from the heap for execution, all other tasks in the heap have their priority number decremented by 1. There is a restriction that the priority number will never be negative. • when a task is added to the heap, all other tasks currently in the heap remained unmodified.

  3. Example of how the priority number changes. • Task Manager: eclipse:4, javac: 5, notepad: 7 • After executing a task, eclipse:4. (It has minimum priority number). The task manager has the following task: • javac: 4, notepad: 6 • After a new task is accepted into the task manager. Assume the new one is mysql:7. The task manager has the following task. • javac: 4, notepad: 6, mysql:7

  4. You are going to program the TaskManager.java

More Related