Lecture 4 Quick Sort and Randomized Quick Sort

Quick Sort

--Divide and Conquer

--Sorts “in place”

--Very practical with tuning


Divide and Conquer:

1.Divide: Partition array into 2 sub-arrays around pivot x such that?elements in lower sub-array <= x <= elements in upper sub-array;

2.Conquer: Recursively sort 2 sub-arrays;

3.Combine: Trivial.





Randomized Quick sort:

--running time is independent of input ordering.

--no assumption about input distribution.

--no specific input elicit the worst-case behavior.

--the worst case determined only by random number generator.





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

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

相關文章

HDU 3966 樹鏈剖分后線段樹維護

題意: 一棵樹, 操作1.$path(a,b)$之間的點權$k$ 操作2.單點查詢 題解: 樹鏈剖分即可,注意代碼細節,雙向映射 主要是記錄一下板子 #include <string.h> #include <stdio.h> #include <algorithm> #define endl \n #define ll long long #define ull unsigned …

VUE config/index.js文件配置

&#xfeff;&#xfeff; 當我們需要和后臺分離部署的時候&#xff0c;必須配置config/index.js: 用vue-cli 自動構建的目錄里面 &#xff08;環境變量及其基本變量的配置&#xff09;123456789101112131415var path require(path)module.exports {build: {index: path.res…

數據規則列表加導入導出

1.進入bos&#xff0c;打開數據規則&#xff0c;進入列表菜單 2.點擊事件-新增操作 3.點擊新增 4.點擊操作類型&#xff0c;輸入%引入 5.點擊確定&#xff0c;保存后生效&#xff0c;導出 、引入模板設置同理轉載于:https://www.cnblogs.com/RogerLu/p/10643521.html

Lecture 6 Order Statistics

Given n elements in array, find kth smallest element (element of rank k) Worst-case linear time order statistics --by Blum, Floyd, Pratt, Rivest, Tarjan --idea: generate good pivot recursively. Not so hot, because the constant is pretty big.

C++ qsort() 函數調用時實參與形參不兼容的問題解決

《劍指OFFER》刷題筆記 —— 撲克牌順子 LL今天心情特別好,因為他去買了一副撲克牌,發現里面居然有2個大王,2個小王(一副牌原本是54張^_^)...他隨機從中抽出了5張牌,想測測自己的手氣,看看能不能抽到順子,如果抽到的話,他決定去買體育彩票,嘿嘿&#xff01;&#xff01;“紅心A…

linux jenkins部署之路之,ftp部署怎么匿名還好用咋解決思密達

怎么安裝就不說了&#xff0c;網上一堆 這噶搭是配置 目錄是/etc/vsftpd/vsftpd.conf # Example config file /etc/vsftpd/vsftpd.conf# # The default compiled in settings are fairly paranoid. This sample file # loosens things up a bit, to make the ftp daemon more u…

powerCat進行常規tcp端口轉發

實戰中&#xff0c;我們也會遇到需要我們進行端口轉發的情況&#xff0c;比如已經拿下的目標機1是在dmz區&#xff0c;而目標1所在內網的其他目標只能通過目標1去訪問&#xff0c;這時候我們就需要端口轉發或者代理來進行后滲透。這次就要介紹一個加強版的nc&#xff0c;基于po…

Lecture 7 Hashing Table I

Hash |---Hash function: Division, Multiplication |---Collision: Chaining, Open addressing(Linear,Double hasing) Symbol-table problem: Table S holding n records pointer --> key|satelite data (record) Hashing: Hash function h maps keys “randomly”…

SpringCloud 微服務

一微服務架構概述1.1 微服務特性以及優點每個服務可以獨立運行在自己的進程里一系列獨立運行的微服務(goods,order,pay,user,search…)共同構建了整個系統每個服務為獨立的業務開發&#xff0c;一個微服務只關注某個特定的功能&#xff0c;例如用戶管理&#xff0c;商品管理微服…

window起別名

http://www.bagualu.net/wordpress/archives/1714 轉載于:https://www.cnblogs.com/wei-huan/p/10654026.html

vue在ie9中的兼容問題

問題總結 https://github.com/vuejs-templates/webpack/issues/260 首先npm install --save babel-polyfill然后在main.js中的最前面引入babel-polyfillimport babel-polyfill在index.html 加入以下代碼&#xff08;非必須&#xff09;<meta http-equiv"X-UA-Compatib…

Lecture 9 Random built Binary Search Trees BSTs

Random built Binary Search Trees BSTs E[hight] near 3logn Quick Sort? Relation to Quick Sort: BST sort & Quick sort make same comparisons but in a different order. Randomized BST Sort: 1. Randomly permute A 2. BST sort(A)

spring boot 帶遠程調試啟動方式

比如啟動service-system-0.0.1-SNAPSHOT.jar和service-file-0.0.1-SNAPSHOT.jar nohup java -Xdebug -Xrunjdwp:servery,transportdt_socket,address7999,suspendn -jar service-system-0.0.1-SNAPSHOT.jar > /dev/null 2>&1 &nohup java -Xdebug -Xrunjdwp:se…

文件讀寫

讀寫文件通常都是IO操作&#xff0c;Python內置了讀文件的函數&#xff0c;用法和C是兼容的。 讀寫文件前&#xff0c;我們先必須了解一下&#xff0c;在磁盤上讀寫文件的功能都是有操作系統提供的&#xff0c;現代操作系統不允許普通的程序直接操作磁盤&#xff0c;所以&#…

Vue項目中遇到了大文件分片上傳的問題

Vue項目中遇到了大文件分片上傳的問題&#xff0c;之前用過webuploader&#xff0c;索性就把Vue2.0與webuploader結合起來使用&#xff0c;封裝了一個vue的上傳組件&#xff0c;使用起來也比較舒爽。 上傳就上傳吧&#xff0c;為什么搞得那么麻煩&#xff0c;用分片上傳&#x…

NDK學習筆記-使用現有so動態庫

前面將的都是如何使用C/C文件生成so動態庫&#xff0c;那么在使用別人的so動態庫的時候應該怎么做呢&#xff1f;這篇文章就是使用一個變聲功能的動態庫&#xff0c;完成對于以有so動態庫的說明。 動態庫來源 在互聯網中&#xff0c;有著許許多多動態庫&#xff0c;很多廠商也對…

Spring cloud系列十四 分布式鏈路監控Spring Cloud Sleuth

1. 概述 Spring Cloud Sleuth實現對Spring cloud 分布式鏈路監控 本文介紹了和Sleuth相關的內容&#xff0c;主要內容如下&#xff1a; Spring Cloud Sleuth中的重要術語和意義&#xff1a;Span、Trance、AnnotationZipkin中圖形化展示分布式鏈接監控數據并說明字段意義Spring …

Linux源碼編譯安裝程序

一、程序的組成部分 Linux下程序大都是由以下幾部分組成&#xff1a; 二進制文件&#xff1a;也就是可以運行的程序文件 庫文件&#xff1a;就是通常我們見到的lib目錄下的文件 配置文件&#xff1a;這個不必多說&#xff0c;都知道 幫助文檔&#xff1a;通常是我們在linux下用…