排序算法中平均時間復雜度_操作系統中的作業排序(算法,時間復雜度和示例)...

排序算法中平均時間復雜度

作業排序 (Job sequencing)

Job sequencing is the set of jobs, associated with the job i where deadline di >= 0 and profit pi > 0. For any job i the profit is earned if and only if the job is completed by its deadline. To complete a job, one has to process the job on a machine for one unit of time. Only one machine is available for processing the jobs.

作業排序是與作業i相關聯的一組作業,其中期限di> = 0且利潤pi> 0 。 對于任何工作, 我當且僅當作業被其限期完成利潤賺。 為了完成一項工作,必須在一臺機器上在一個單位時間內處理該工作。 僅一臺機器可用于處理作業。

Steps for performing job sequencing with deadline using greedy approach is as follows:

使用貪婪方法在截止日期之前執行作業排序的步驟如下:

  1. Sort all the jobs based on the profit in an increasing order.

    根據利潤按升序對所有作業進行排序。

  2. Let α be the maximum deadline that will define the size of array.

    令α為將定義數組大小的最大截止日期。

  3. Create a solution array S with d slots.

    創建具有d個插槽的解決方案數組S。

  4. Initialize the content of array S with zero.

    用零初始化數組S的內容。

  5. Check for all jobs.

    檢查所有作業。

    1. If scheduling is possible a lot ith slot of array s to job i.
    2. 如果調度是可能很多我陣列的時隙s到工作我 。
    3. Otherwise look for location (i-1), (i-2)...1.
    4. 否則尋找位置(i-1),(i-2)... 1 。
    5. Schedule the job if possible else reject.
  6. Return array S as the answer.

    返回數組S作為答案。

  7. End.

    結束。

作業排序算法 (Algorithm for job sequencing)

Input: A is the array of jobs with deadline and profit S array will be the output.

輸入: A是具有截止日期的職位數組,而利潤S數組將是輸出。

    1. Begin
2. Sort all the jobs based on profit Pi so
3. P1 > P2 > P3 …………………………….>=Pn
4. d = maximum deadline of job in A
5. Create array S[1,…………………,d]
6. For i=1 to n do
7. Find the largest job x
8. For j=i to 1
9. If ((S[j] = 0) and (x deadline<= d))
10. Then 
11. S[x] = i;
12. Break;
13. End if
14. End for
15. End for
16. End

時間復雜度 (Time complexity)

Job sequencing problems has the time complexity of O(n2).

作業排序問題的時間復雜度為O(n2)。

Example:

例:

Given a set of 9 jobs where each job has a deadline and profit associated to it .Each job takes 1 unit of time to complete and only one job can be scheduled at a time. We earn the profit if and only if the job is completed by its deadline. The task is to find the maximum profit and the number of jobs done.

給定一組9個工作,每個工作都有一個截止日期和與之相關的利潤。每個工作需要1個時間單位才能完成,并且一次只能安排一個工作。 當且僅當工作在截止日期之前完成時,我們才能賺取利潤。 任務是找到最大的利潤和完成的工作數量。

    Jobs	 Profit	  Deadline
J1	        85	        5
J2	        25	        4
J3	        16	        3
J4	        40	        3
J5	        55	        4
J6	        19	        5
J7	        92	        2
J8	        80	        3
J9	        15	        7

Step 1:

第1步:

job sequencing 1

Step 2:

第2步:

job sequencing 2

Step 3:

第三步:

job sequencing 3

Step 4:

第4步:

job sequencing 4

Step 5:

步驟5:

job sequencing 5

Step 6:

步驟6:

job sequencing 6

So, the maximum profit = 40 + 92 + 80 + 55 + 85 + 15 = 367

因此,最大利潤= 40 + 92 + 80 + 55 + 85 + 15 = 367

翻譯自: https://www.includehelp.com/operating-systems/job-sequencing.aspx

排序算法中平均時間復雜度

本文來自互聯網用戶投稿,該文觀點僅代表作者本人,不代表本站立場。本站僅提供信息存儲空間服務,不擁有所有權,不承擔相關法律責任。
如若轉載,請注明出處:http://www.pswp.cn/news/379898.shtml
繁體地址,請注明出處:http://hk.pswp.cn/news/379898.shtml
英文地址,請注明出處:http://en.pswp.cn/news/379898.shtml

如若內容造成侵權/違法違規/事實不符,請聯系多彩編程網進行投訴反饋email:809451989@qq.com,一經查實,立即刪除!

相關文章

python---文件處理

0x01 打開一個文件 python中內置了文件對象&#xff0c;通過open()函數就可以制定模式打開指定文件&#xff0c;并創建文件對象。該函數的格式如下&#xff1a; open(file[,moder[,buffering-1]])file&#xff1a;指定要打開或創建的文件名稱&#xff0c;如果該文件不存在當前…

簡易而又靈活的Javascript拖拽框架(四)

一、開篇 似乎拖拽已經被寫爛了&#xff0c;沒得寫的了&#xff0c;可是我這次又來了&#xff5e; 上一次寫的是跨列拖放&#xff0c;這次我要帶給大家的是跨頁拖放。 可以到這里來看看效果&#xff1a;示例效果 說明&#xff1a;1、如果將方框拖動到頁簽上立刻釋放掉的話&…

Java——集合的基本功能測試

* 1,boolean add<E,e> 添加* 確保此 collection 包含指定的元素&#xff08;可選操作&#xff09;。* 參數&#xff1a;e - 確定此 collection 中是否存在的元素。E - 代表Object類&#xff0c;說明該add可以添加任何對象&#xff0c;任意對象都是Object的子類對象&…

《那些年啊,那些事——一個程序員的奮斗史》——78

招人風波之后&#xff0c;就很少見武總往18樓跑了&#xff0c;大部分時間都是坐在22樓的隔間。而武總對段伏櫪的抱怨&#xff0c;也僅僅只有那次&#xff0c;后來就再也沒有提過。對于段伏櫪而言&#xff0c;還要不要招新人&#xff0c;后續如何去招新人&#xff0c;已經不是自…

python---異常處理結構

python中提供了很多不同形式的異常處理結構&#xff0c;其基本思路都是先嘗試執行代碼&#xff0c;再處理可能發生的錯誤。 try…except… 在python異常處理結構中&#xff0c;try…except…使用最為頻繁&#xff0c;其中try子句中的代碼塊為可能引發異常的語句&#xff0c;e…

用css網站布局之十步實錄 (轉載)

第一步&#xff1a;規劃網站http://www.52css.com/article.asp?id175 第二步&#xff1a;創建html模板及文件目錄等http://www.52css.com/article.asp?id176 第三步&#xff1a;將網站分為五個div 網頁基本布局http://www.52css.com/article.asp?id177 第四步&#xff1a;網…

Java——集合轉數組并對其進行遍歷

* A&#xff1a;集合的遍歷* 其實就是以此獲取集合中的每一個元素* B&#xff1a;案例* 把集合轉成數組&#xff0c;可以實現集合的遍歷* public Object[] toArray() 按適當順序&#xff08;從第一個到最后一個元素&#xff09;返回包含此列表中所有元素的數組。…

魚油賬號記錄程序(續) - 零基礎入門學習Delphi39

魚油賬號記錄程序&#xff08;續&#xff09; 讓編程改變世界 Change the world by program 課件同上一講&#xff0c;這一講主要演示編程操作和修改程序&#xff01; [buy] 獲得所有教學視頻、課件、源代碼等資源打包 [/buy] [Downlink hrefhttp://kuai.xunlei.com/d/LDKX…

python---Socket編程

Sockte是計算機之間進行網絡通信的一套程序接口&#xff0c;相當于在發送端和接收端之間建立一個通信管道。在實際應用中&#xff0c;一些遠程管理軟件和網絡安全軟件大多數依賴于Socket來實現特定功能&#xff0c;由于TCP方式在網絡編程中應用非常頻繁&#xff0c;此處將對TCP…

格式轉換-----PDF格式研究筆記(一)

格式轉換-----PDF格式研究筆記&#xff08;一&#xff09; 現在我的幾個計劃都需要我能夠對PDF格式進行解碼&#xff0c;所以找了一下資料&#xff0c;找到了一個PDF1.3的手冊&#xff0c;特放出下載&#xff0c;如果誰有更高版本的&#xff0c;請給我一份&#xff0c;謝謝。 …

(X)HTML嵌套規則

本文整理于互聯網~ 簡單認識了塊元素和內嵌元素以后&#xff0c;下面就可以羅列 XHTML 標簽的嵌套規則了&#xff1a; 1. 塊元素可以包含內聯元素或某些塊元素&#xff0c;但內聯元素卻不能包含塊元素&#xff0c;它只能包含其它的內聯元素&#xff1a;<div><h1>&…

Java——集合帶All的功能演示

package com.wsq.collection;import java.util.ArrayList; import java.util.Collection; public class Demo4_CollectionAll {public static void main(String[] args) {demo1(); //c1.addAll(c2);將c2整個集合給添加到c1中,即&#xff0c;c2集合中的每…

ASP.NET Web API 處理架構

這篇文章主要是介紹ASP.NET Web API的處理架構&#xff1a;當一個HTTP請求到達直到產生一個請求的過程。ASP.NET Web API 的處理架構圖如下&#xff0c;主要有三層組成&#xff1a;宿主&#xff08;hosting&#xff09;&#xff0c;消息處理管道&#xff08;message handler pi…

python---可執行文件的轉換

pyinstaller是常見的執行文件打包工具。該工具的安裝方式非常簡單&#xff0c;可運行在windows、MacOS X和GNU/Linux操作系統環境中&#xff0c;執行python2和python3。 用pyinstaller打包的執行文件&#xff0c;只能在于執行打包操作的系統類型相同的環境下運行。也就是說&…

Java——集合的遍歷之迭代遍歷

這些是下面的代碼中所涉及到的所有方法&#xff1a;* 迭代概述:* 集合是用來存儲元素&#xff0c;存儲的元素需要查看&#xff0c;那么就需要迭代(遍歷)* 也就是說&#xff0c;迭代就是遍歷* * public interface Iterator<E> 對 collection 進行迭代的迭代器* …

數組排序最小復雜度_進行排序的最小缺失數

數組排序最小復雜度Problem statement: 問題陳述&#xff1a; Given an array of n integers. Find the minimum number of elements from the array to remove or delete so that when the remaining elements are placed in the same sequence order form a sorted sequence…

輕松掌握Windows窗體間的數據交互(轉載)

輕松掌握Windows窗體間的數據交互作者&#xff1a;鄭佐日期&#xff1a;2004-04-05Windows 窗體是用于 Microsoft Windows 應用程序開發的、基于 .NET Framework 的新平臺。此框架提供一個有條理的、面向對象的、可擴展的類集&#xff0c;它使您得以開發豐富的 Windows 應用程序…

MATLAB安裝問題解決方案大集錦

我的安裝后的兩個問題 第一個&#xff1a;“Microsoft Visual C Runtime LibraryRuntime Error!Program:C:\Matlab7\Rin\Win32\Matlab.exeThis application has requested the runtime to terminate it in an unusual way.Please contact the applications support team for mo…

python免殺技術---shellcode的加載與執行

0x01 生成shellcode 首先通過下列命令生成一個shellcode&#xff0c;使用msfvenom -p選項來指定paylaod&#xff0c;這里選用windows/x64、exec模塊接收的參數。使用calc.exe執行彈出計算器的操作。-f選項用來執行生成的shellcdoe的編譯語言。 msfvenom -p windows/x64/exec …

成對的歌曲,其總持續時間可被60整除

Problem statement: 問題陳述&#xff1a; In a list of songs, the i-th song has duration of time[i] seconds. Return the number of pairs of songs for which their total duration in seconds is divisible by 60. Formally, we want the number of indices i < j w…