Download - บทที่ 2 การวิเคราะห์อัลกอริทึม
![Page 1: บทที่ 2 การวิเคราะห์อัลกอริทึม](https://reader030.vdocuments.pub/reader030/viewer/2022012905/56813590550346895d9cff2c/html5/thumbnails/1.jpg)
บทท�� 2 การวิเคราะห์�อั�ลกอัรท�ม
![Page 2: บทที่ 2 การวิเคราะห์อัลกอริทึม](https://reader030.vdocuments.pub/reader030/viewer/2022012905/56813590550346895d9cff2c/html5/thumbnails/2.jpg)
2 ห์�วิข้�อั
การวิเคราะห์�อั�ลกอัรท�ม แบบทดลอัง และแบบคณิตวิเคราะห์�
การนั�บจำ�านัวินัการท�างานัข้อังค�าสั่��งพื้ !นัฐานั อั�ตราการเตบโตข้อังฟั%งก�ชั�นั สั่�ญกรณิ�เชังเสั่�นัก�าก�บ การวิเคราะห์�การท�างานั
แบบล�าด�บ, แบบเล อักท�า, แบบวิงวินั, แบบเร�ยกซ้ำ�!า
![Page 3: บทที่ 2 การวิเคราะห์อัลกอริทึม](https://reader030.vdocuments.pub/reader030/viewer/2022012905/56813590550346895d9cff2c/html5/thumbnails/3.jpg)
3 ข้�!นัตอันัการอัอักแบบอั�ลกอัรท�ม
![Page 4: บทที่ 2 การวิเคราะห์อัลกอริทึม](https://reader030.vdocuments.pub/reader030/viewer/2022012905/56813590550346895d9cff2c/html5/thumbnails/4.jpg)
4 จำ*ดประสั่งค�ข้อังการวิเคราะห์�อั�ลกอัรท�ม
เพื้ �อัศึ�กษาประสั่ทธิภาพื้ข้อังอั�ลกอัรท�ม เวิลาการท�างานั ปรมาณิห์นั0วิยควิามจำ�าท��ใชั�ในัการท�างานั
![Page 5: บทที่ 2 การวิเคราะห์อัลกอริทึม](https://reader030.vdocuments.pub/reader030/viewer/2022012905/56813590550346895d9cff2c/html5/thumbnails/5.jpg)
5 ประเภทการวิเคราะห์�อั�ลกอัรท�ม
Mathematical Analysis Experimental Analysis
แปลงเป2นัโค�ด สั่��งท�างานัก�บข้�อัม3ลทดสั่อับ จำ�บเวิลาการท�างานั บ�นัท�กผล วิเคราะห์�ควิามสั่�มพื้�นัธิ�ระห์วิ0างเวิลาการท�างานัก�บ
ปรมาณิข้�อัม3ล ม�กเป2นัร3ปแบบฟั%งก�ชั�นัทางคณิตศึาสั่ตร�
![Page 6: บทที่ 2 การวิเคราะห์อัลกอริทึม](https://reader030.vdocuments.pub/reader030/viewer/2022012905/56813590550346895d9cff2c/html5/thumbnails/6.jpg)
6 SelectionSort
selectionSort(d[1..n]){
for (k = n; k > 1; k--) {
maxI=1
for (i = 2; i <= k; i++)
if (d[i] > d[maxI]) maxI = i
d[k]d[maxI]
}
}
![Page 7: บทที่ 2 การวิเคราะห์อัลกอริทึม](https://reader030.vdocuments.pub/reader030/viewer/2022012905/56813590550346895d9cff2c/html5/thumbnails/7.jpg)
7 Selection Sort ( ภาษา C)
void selectionSort(int d[], int n) {
int k, i;
for (k = n - 1; k > 0; k--) {
int maxI =1;
for (i = 0; i <= k; i++)
if (d[i]> d[maxI]) maxI = i;
int t = d[k];
d[k] = d[maxI];
d[maxI] = t;
}
}
![Page 8: บทที่ 2 การวิเคราะห์อัลกอริทึม](https://reader030.vdocuments.pub/reader030/viewer/2022012905/56813590550346895d9cff2c/html5/thumbnails/8.jpg)
8
#include <stdio.h>
#include <stdlib.h>
#include <windows.h>
int main(int argc, char *argv[]) {
int i, k, n, repeat = 10;
for( n = 0; n<=20000; n+=2000) {
int *d = malloc( n * sizeof(int) );
long sum = 0;
for (k=0; k<repeat; k++) {
for (i=0; i<n; i++) d[i] = i;
long start = GetTickCount();
selectionSort(d, n);
sum += GetTickCount() - start;
}
printf("%d \t %f \n", n, (float)sum/repeat);
}
system("PAUSE"); return 0;
}
![Page 9: บทที่ 2 การวิเคราะห์อัลกอริทึม](https://reader030.vdocuments.pub/reader030/viewer/2022012905/56813590550346895d9cff2c/html5/thumbnails/9.jpg)
9 Selection Sort ( ภาษาJava)
![Page 10: บทที่ 2 การวิเคราะห์อัลกอริทึม](https://reader030.vdocuments.pub/reader030/viewer/2022012905/56813590550346895d9cff2c/html5/thumbnails/10.jpg)
10
public class TestSelectionSort {
public static void main(String[] args) {
int repeat = 10;
for (int n = 0; n <= 20000; n += 2000) {
int[]d = new int[n];
long sum = 0;
for (int k = 0; k < repeat; k++) {
for (int i = 0; i <n;i++) d[i] = i; {
long start = System.currentTimeMillis();
selectionSort(d);
sum += System currentTimeMillis() - start;
}
System.out.printf("%d \t %f \n", (double)sum/repeat);
}
}
![Page 11: บทที่ 2 การวิเคราะห์อัลกอริทึม](https://reader030.vdocuments.pub/reader030/viewer/2022012905/56813590550346895d9cff2c/html5/thumbnails/11.jpg)
11
public class TestSelectionSort {
public static void main(String[] args) {
int repeat = 10;
for (int n = 0; n <= 20000; n += 2000) {
int[]d = new int[n];
long sum = 0;
for (int k = 0; k < repeat; k++) {
for (int i = 0; i <n;i++) d[i] = i; {
long start = System.currentTimeMillis();
selectionSort(d);
sum += System currentTimeMillis() - start;
}
System.out.printf("%d \t %f \n", (double)sum/repeat);
}
}
for (int i = 0; i < 10000; i++)selectionSort(new int[1]);
![Page 12: บทที่ 2 การวิเคราะห์อัลกอริทึม](https://reader030.vdocuments.pub/reader030/viewer/2022012905/56813590550346895d9cff2c/html5/thumbnails/12.jpg)
12 สั่��งท�างานั พื้ร�อัมบ�นัท�กผล ภาษา C : ใชั�GNU-C Compiler (3.4.2) ภาษา Java : ใชั� Java 6 (build 1.6.0_14-b08)
Interpreted-only mode (option –Xint ตอันัท�างานั)
Compilation to native code ( บ�งค�บ compile
ด�วิยการเร�ยกเมท5อัดวิ�!า ๆ สั่�ก 10 000 คร�!ง) Intel Core 2 Duo
P8400 2.26GhzRam 3GBWindows XP
![Page 13: บทที่ 2 การวิเคราะห์อัลกอริทึม](https://reader030.vdocuments.pub/reader030/viewer/2022012905/56813590550346895d9cff2c/html5/thumbnails/13.jpg)
13 เปร�ยบเท�ยบเวิลาการท�างานั
22.1×10−6 𝑛
2
2 .38×10− 6 𝑛
2
1 .54×10− 6𝑛
2
![Page 14: บทที่ 2 การวิเคราะห์อัลกอริทึม](https://reader030.vdocuments.pub/reader030/viewer/2022012905/56813590550346895d9cff2c/html5/thumbnails/14.jpg)
14 ใชั�จำ�านัวินัการท�างานัข้อังค�าสั่��งแทนัเวิลาstatic int counter= 0;
static void selectionSort(int[] d) {
counter = 1+d.length +d.length-1;
for (int k = d.length-1; k > 0; k--) {
int maxI =1;
counter += 2 + k+2 + k+1;
for (int i = 0; i <= k; i++) {
counter += 1;
if (d[i] > d[maxI]) {
maxI=i; counter+=1;
}
}
counter += 3;
int t = d[k]; d[k] = d[maxI]; d[maxI] = t;
}
}
![Page 15: บทที่ 2 การวิเคราะห์อัลกอริทึม](https://reader030.vdocuments.pub/reader030/viewer/2022012905/56813590550346895d9cff2c/html5/thumbnails/15.jpg)
15 เข้�ยนัโปรแกรมทดลอังนั�บค�าสั่��งpublic class TestSelectionSort {
public static void main(String[] args) {
int repeat = 10;
for (int n = 0; n <= 20000; n += 2000) {
int[]d = new int[n];
long sum = 0;
for (int k = 0; k < repeat; k++) {
for (int i = 0; i <n;i++) d[i] = i;;
counter = 0;
selectionSort(d);
sum += counter;
}
System.out.printf("%d \t %f \n", n, (double)sum/repeat);
}
}
![Page 16: บทที่ 2 การวิเคราะห์อัลกอริทึม](https://reader030.vdocuments.pub/reader030/viewer/2022012905/56813590550346895d9cff2c/html5/thumbnails/16.jpg)
16 นั�บจำ�านัวินัการท�างานัข้อังค�าสั่��ง
![Page 17: บทที่ 2 การวิเคราะห์อัลกอริทึม](https://reader030.vdocuments.pub/reader030/viewer/2022012905/56813590550346895d9cff2c/html5/thumbnails/17.jpg)
17 นั�บเฉพื้าะค�าสั่��งต�วิแทนัstatic intcounter= 0;
static voidselectionSort(int[] d) {
for (int k = d.length-1; k > 0; k--) {
int maxI =1;
for (int i = 0; i <= k; i++) {
counter += 1;
if (d[i] > d[maxI]) {
maxI = i;
}
}
int t d[k]; d[k] = d[maxI]; d[maxI]=t;
}
}
![Page 18: บทที่ 2 การวิเคราะห์อัลกอริทึม](https://reader030.vdocuments.pub/reader030/viewer/2022012905/56813590550346895d9cff2c/html5/thumbnails/18.jpg)
18 นั�บท*กค�าสั่��ง VS. นั�บค�าสั่��งต�วิแทนั
![Page 19: บทที่ 2 การวิเคราะห์อัลกอริทึม](https://reader030.vdocuments.pub/reader030/viewer/2022012905/56813590550346895d9cff2c/html5/thumbnails/19.jpg)
19 Mathematical Analysis
ไม0ต�อังเข้�ยนัเป2นัโปรแกรม ไม0ต�อังสั่��งท�างานัจำรง ไม0ต�อังวิาดกราฟั วิเคราะห์�จำากอั�ลกอัรท�ม จำะได�
เป2นัฟั%งก�ชั��นั
1∑𝑖=2
𝑘
❑
![Page 20: บทที่ 2 การวิเคราะห์อัลกอริทึม](https://reader030.vdocuments.pub/reader030/viewer/2022012905/56813590550346895d9cff2c/html5/thumbnails/20.jpg)
20 นั�บท*กค�าสั่��ง VS. นั�บค�าสั่��งต�วิแทนั
![Page 21: บทที่ 2 การวิเคราะห์อัลกอริทึม](https://reader030.vdocuments.pub/reader030/viewer/2022012905/56813590550346895d9cff2c/html5/thumbnails/21.jpg)
21 ค�าสั่��งต�วิแทนัต�อังเป2นัค�าสั่��งพื้ !นัฐานั ค�าสั่��งพื้ !นัฐานั ค อัค�าสั่��งท��
ใชั�เวิลาการท�างานัไม0เกนัค0าคงท��ค0าห์นั��ง ใชั�เวิลาการท�างานัไม0แปรตามข้นัาดข้อัง
input เชั0นั + - * / if เปร�ยบเท�ยบ return
break …
![Page 22: บทที่ 2 การวิเคราะห์อัลกอริทึม](https://reader030.vdocuments.pub/reader030/viewer/2022012905/56813590550346895d9cff2c/html5/thumbnails/22.jpg)
22 การวิเคราะห์�อั�ลกอัรท�ม เวิลาการท�างานั แปรตามจำ�านัวินัการท�างานัข้อังค�าสั่��ง
จำ�านัวินัการท�างานัข้อังค�าสั่��ง แปรตามจำ�านัวินัการท�างานัข้อังค�าสั่��งต�วิแทนั
เพื้ �อัควิามง0าย เราวิเคราะห์�อั�ลกอัรท�มเชังเวิลาด�วิยการห์าควิามสั่�มพื้�นัธิ�ข้อัง จำ�านัวินัการท�างานัข้อังค�าสั่��งต�วิแทนั ปรมาณิข้�อัม3ล
![Page 23: บทที่ 2 การวิเคราะห์อัลกอริทึม](https://reader030.vdocuments.pub/reader030/viewer/2022012905/56813590550346895d9cff2c/html5/thumbnails/23.jpg)
23 วิ�ดปรมาณิข้�อัม3ลข้าเข้�า พื้จำารณิาวิ0า ข้นัาดข้อัง input แปรตามค0าอัะไรข้อัง
input ต�วิอัย0าง: sort(d[1…n])
Input เป2นัอัาเรย�จำ�านัวินั n ชั0อัง แต0ละจำ�านัวินัม�ค0าจำ�าก�ด ด�งนั�!นั n แทนัปรมาณิข้�อัม3ล
ต�วิอัย0าง:shortestPath( V, E, w, s ) Input เป2นักราฟัถ่0วิงนั�!าห์นั�ก ข้นัาดข้อังกราฟั แปรตามจำ�านัวินัปมและจำ�านัวินัเสั่�นัเชั �อัม ด�!งนั�!นั |V|+|E| แทนัปรมาณิข้อังข้�อัม3ล
![Page 24: บทที่ 2 การวิเคราะห์อัลกอริทึม](https://reader030.vdocuments.pub/reader030/viewer/2022012905/56813590550346895d9cff2c/html5/thumbnails/24.jpg)
24 เปร�ยบเท�ยบผลการวิเคราะห์�
![Page 25: บทที่ 2 การวิเคราะห์อัลกอริทึม](https://reader030.vdocuments.pub/reader030/viewer/2022012905/56813590550346895d9cff2c/html5/thumbnails/25.jpg)
25 เปร�ยบเท�ยบเวิลาการท�างานั
![Page 26: บทที่ 2 การวิเคราะห์อัลกอริทึม](https://reader030.vdocuments.pub/reader030/viewer/2022012905/56813590550346895d9cff2c/html5/thumbnails/26.jpg)
26 เปร�ยบเท�ยบอั�ตราการเตบโต
![Page 27: บทที่ 2 การวิเคราะห์อัลกอริทึม](https://reader030.vdocuments.pub/reader030/viewer/2022012905/56813590550346895d9cff2c/html5/thumbnails/27.jpg)
27
![Page 28: บทที่ 2 การวิเคราะห์อัลกอริทึม](https://reader030.vdocuments.pub/reader030/viewer/2022012905/56813590550346895d9cff2c/html5/thumbnails/28.jpg)
28 อั�ตราการเตบโต
![Page 29: บทที่ 2 การวิเคราะห์อัลกอริทึม](https://reader030.vdocuments.pub/reader030/viewer/2022012905/56813590550346895d9cff2c/html5/thumbnails/29.jpg)
29
![Page 30: บทที่ 2 การวิเคราะห์อัลกอริทึม](https://reader030.vdocuments.pub/reader030/viewer/2022012905/56813590550346895d9cff2c/html5/thumbnails/30.jpg)
30
![Page 31: บทที่ 2 การวิเคราะห์อัลกอริทึม](https://reader030.vdocuments.pub/reader030/viewer/2022012905/56813590550346895d9cff2c/html5/thumbnails/31.jpg)
31
![Page 32: บทที่ 2 การวิเคราะห์อัลกอริทึม](https://reader030.vdocuments.pub/reader030/viewer/2022012905/56813590550346895d9cff2c/html5/thumbnails/32.jpg)
32
![Page 33: บทที่ 2 การวิเคราะห์อัลกอริทึม](https://reader030.vdocuments.pub/reader030/viewer/2022012905/56813590550346895d9cff2c/html5/thumbnails/33.jpg)
33
![Page 34: บทที่ 2 การวิเคราะห์อัลกอริทึม](https://reader030.vdocuments.pub/reader030/viewer/2022012905/56813590550346895d9cff2c/html5/thumbnails/34.jpg)
34 ทบทวินัสั่3ตรคณิตศึาสั่ตร�
![Page 35: บทที่ 2 การวิเคราะห์อัลกอริทึม](https://reader030.vdocuments.pub/reader030/viewer/2022012905/56813590550346895d9cff2c/html5/thumbnails/35.jpg)
35
![Page 36: บทที่ 2 การวิเคราะห์อัลกอริทึม](https://reader030.vdocuments.pub/reader030/viewer/2022012905/56813590550346895d9cff2c/html5/thumbnails/36.jpg)
36
![Page 37: บทที่ 2 การวิเคราะห์อัลกอริทึม](https://reader030.vdocuments.pub/reader030/viewer/2022012905/56813590550346895d9cff2c/html5/thumbnails/37.jpg)
37
![Page 38: บทที่ 2 การวิเคราะห์อัลกอริทึม](https://reader030.vdocuments.pub/reader030/viewer/2022012905/56813590550346895d9cff2c/html5/thumbnails/38.jpg)
38
![Page 39: บทที่ 2 การวิเคราะห์อัลกอริทึม](https://reader030.vdocuments.pub/reader030/viewer/2022012905/56813590550346895d9cff2c/html5/thumbnails/39.jpg)
39
![Page 40: บทที่ 2 การวิเคราะห์อัลกอริทึม](https://reader030.vdocuments.pub/reader030/viewer/2022012905/56813590550346895d9cff2c/html5/thumbnails/40.jpg)
40 อั�ตราการเต�บโตขอังฟั�งก�ชั�น
![Page 41: บทที่ 2 การวิเคราะห์อัลกอริทึม](https://reader030.vdocuments.pub/reader030/viewer/2022012905/56813590550346895d9cff2c/html5/thumbnails/41.jpg)
41 f(n) vs. g(n)
ใครโตเร5วิกวิ0าก�นั ให์�ด3ท��พื้ฤตกรรม ตอันัท��ค0า n เยอัะๆ วิ0าใครนั�าห์นั�า
ใคร
ค อั ค0าคงต�วิท��ไม0ใชั0 0
𝒇 (𝒏 )≺𝒈 (𝒏 )
𝒇 (𝒏 )≻𝒈 (𝒏 )𝒇 (𝒏 )≍𝒈 (𝒏 )
𝒇 (𝒏 ) โตไม่�เร�วกว�า𝒈 (𝒏)
𝒇 (𝒏 ) โตไม่�ชั�ากว�า𝒈 (𝒏 )
𝒇 (𝒏 )≼𝒈 (𝒏 )
𝒇 (𝒏 )≽𝒈 (𝒏 )
![Page 42: บทที่ 2 การวิเคราะห์อัลกอริทึม](https://reader030.vdocuments.pub/reader030/viewer/2022012905/56813590550346895d9cff2c/html5/thumbnails/42.jpg)
42 ต�วิอัย0าง
=
=
=
สั่ร*ปได�วิ0า
![Page 43: บทที่ 2 การวิเคราะห์อัลกอริทึม](https://reader030.vdocuments.pub/reader030/viewer/2022012905/56813590550346895d9cff2c/html5/thumbnails/43.jpg)
43
=
=
=
=
สั่ร*ปได�วิ0า โตเท0าก�บ
![Page 44: บทที่ 2 การวิเคราะห์อัลกอริทึม](https://reader030.vdocuments.pub/reader030/viewer/2022012905/56813590550346895d9cff2c/html5/thumbnails/44.jpg)
44 L'Hôpital's rule
ถ่�า และ เป2นัฟั%งก�ชั�นัท��ห์าอันั*พื้�นัธิ�ได� โดยท��
, และห์าค0าข้อัง
จำะได�วิ0า
![Page 45: บทที่ 2 การวิเคราะห์อัลกอริทึม](https://reader030.vdocuments.pub/reader030/viewer/2022012905/56813590550346895d9cff2c/html5/thumbnails/45.jpg)
45
![Page 46: บทที่ 2 การวิเคราะห์อัลกอริทึม](https://reader030.vdocuments.pub/reader030/viewer/2022012905/56813590550346895d9cff2c/html5/thumbnails/46.jpg)
46 เร�ยงล�าด�บฟั%งก�ชั�นัตามการเตบโต
𝑛 !
![Page 47: บทที่ 2 การวิเคราะห์อัลกอริทึม](https://reader030.vdocuments.pub/reader030/viewer/2022012905/56813590550346895d9cff2c/html5/thumbnails/47.jpg)
47
![Page 48: บทที่ 2 การวิเคราะห์อัลกอริทึม](https://reader030.vdocuments.pub/reader030/viewer/2022012905/56813590550346895d9cff2c/html5/thumbnails/48.jpg)
48 สั่�ญกรณิ�เชังเสั่�นัก�าก�บ
![Page 49: บทที่ 2 การวิเคราะห์อัลกอริทึม](https://reader030.vdocuments.pub/reader030/viewer/2022012905/56813590550346895d9cff2c/html5/thumbnails/49.jpg)
49 สั่�ญกรณิ�เชังเสั่�นัก�าก�บ(Asymptotic Notations)
• little-o
• little – omega
• Big – O
• Big – Omega
• Big - Theta
![Page 50: บทที่ 2 การวิเคราะห์อัลกอริทึม](https://reader030.vdocuments.pub/reader030/viewer/2022012905/56813590550346895d9cff2c/html5/thumbnails/50.jpg)
50 little-o
![Page 51: บทที่ 2 การวิเคราะห์อัลกอริทึม](https://reader030.vdocuments.pub/reader030/viewer/2022012905/56813590550346895d9cff2c/html5/thumbnails/51.jpg)
51 little – omega
![Page 52: บทที่ 2 การวิเคราะห์อัลกอริทึม](https://reader030.vdocuments.pub/reader030/viewer/2022012905/56813590550346895d9cff2c/html5/thumbnails/52.jpg)
52 Big - Theta
![Page 53: บทที่ 2 การวิเคราะห์อัลกอริทึม](https://reader030.vdocuments.pub/reader030/viewer/2022012905/56813590550346895d9cff2c/html5/thumbnails/53.jpg)
53 Big – O
![Page 54: บทที่ 2 การวิเคราะห์อัลกอริทึม](https://reader030.vdocuments.pub/reader030/viewer/2022012905/56813590550346895d9cff2c/html5/thumbnails/54.jpg)
54 Big – Omega
![Page 55: บทที่ 2 การวิเคราะห์อัลกอริทึม](https://reader030.vdocuments.pub/reader030/viewer/2022012905/56813590550346895d9cff2c/html5/thumbnails/55.jpg)
55 สั่ร*ป
![Page 56: บทที่ 2 การวิเคราะห์อัลกอริทึม](https://reader030.vdocuments.pub/reader030/viewer/2022012905/56813590550346895d9cff2c/html5/thumbnails/56.jpg)
56 Big – O : ข้อับเข้ตบนั
![Page 57: บทที่ 2 การวิเคราะห์อัลกอริทึม](https://reader030.vdocuments.pub/reader030/viewer/2022012905/56813590550346895d9cff2c/html5/thumbnails/57.jpg)
57 Big-Omega : ข้อับเข้ตล0าง
![Page 58: บทที่ 2 การวิเคราะห์อัลกอริทึม](https://reader030.vdocuments.pub/reader030/viewer/2022012905/56813590550346895d9cff2c/html5/thumbnails/58.jpg)
58 Big – Theta : ข้อับเข้ตกระชั�บ
![Page 59: บทที่ 2 การวิเคราะห์อัลกอริทึม](https://reader030.vdocuments.pub/reader030/viewer/2022012905/56813590550346895d9cff2c/html5/thumbnails/59.jpg)
59 จำ*ดประสั่งค�การใชั�สั่�ญกรณิ�เชังเสั่�นัก�าก�บ
เข้�าใจำพื้ฤตกรรมเม �อัพื้ารามเตอัร�ม�ค0ามาก
วิเคราะห์�ได�ง0าย
จำ�ดกล*0มฟั%งก�ชั�นัตาอั�ตราการเตบโต
![Page 60: บทที่ 2 การวิเคราะห์อัลกอริทึม](https://reader030.vdocuments.pub/reader030/viewer/2022012905/56813590550346895d9cff2c/html5/thumbnails/60.jpg)
60 วิเคราะห์�ด�วิย จำงแสั่ดงวิ0า
![Page 61: บทที่ 2 การวิเคราะห์อัลกอริทึม](https://reader030.vdocuments.pub/reader030/viewer/2022012905/56813590550346895d9cff2c/html5/thumbnails/61.jpg)
61
หาอัน�พั�นธ์�
![Page 62: บทที่ 2 การวิเคราะห์อัลกอริทึม](https://reader030.vdocuments.pub/reader030/viewer/2022012905/56813590550346895d9cff2c/html5/thumbnails/62.jpg)
62 ต�วิอัย0าง
![Page 63: บทที่ 2 การวิเคราะห์อัลกอริทึม](https://reader030.vdocuments.pub/reader030/viewer/2022012905/56813590550346895d9cff2c/html5/thumbnails/63.jpg)
63 การเข้�ยนัฟั%งก�ชั�นัในัร3ปข้อัง ผลบวิกข้อังพื้จำนั�ห์ลายพื้จำนั� เล อักพื้จำนั�ท��โตเร5วิสั่*ด ข้�อัสั่�งเกต
เชั0นั
![Page 64: บทที่ 2 การวิเคราะห์อัลกอริทึม](https://reader030.vdocuments.pub/reader030/viewer/2022012905/56813590550346895d9cff2c/html5/thumbnails/64.jpg)
64 อั�ตราการเตบโต
![Page 65: บทที่ 2 การวิเคราะห์อัลกอริทึม](https://reader030.vdocuments.pub/reader030/viewer/2022012905/56813590550346895d9cff2c/html5/thumbnails/65.jpg)
65 การวิเคราะห์�อั�ลกอัรท�ม
การท�างานัแบบล�าด�บ เล อักท�า ท�าซ้ำ�!าเป2นัวิงวินั ท�าซ้ำ�!าแบบเร�ยกซ้ำ�!า
![Page 66: บทที่ 2 การวิเคราะห์อัลกอริทึม](https://reader030.vdocuments.pub/reader030/viewer/2022012905/56813590550346895d9cff2c/html5/thumbnails/66.jpg)
66 การท�างานัแบบล�าด�บ
![Page 67: บทที่ 2 การวิเคราะห์อัลกอริทึม](https://reader030.vdocuments.pub/reader030/viewer/2022012905/56813590550346895d9cff2c/html5/thumbnails/67.jpg)
67
![Page 68: บทที่ 2 การวิเคราะห์อัลกอริทึม](https://reader030.vdocuments.pub/reader030/viewer/2022012905/56813590550346895d9cff2c/html5/thumbnails/68.jpg)
68
![Page 69: บทที่ 2 การวิเคราะห์อัลกอริทึม](https://reader030.vdocuments.pub/reader030/viewer/2022012905/56813590550346895d9cff2c/html5/thumbnails/69.jpg)
69
![Page 70: บทที่ 2 การวิเคราะห์อัลกอริทึม](https://reader030.vdocuments.pub/reader030/viewer/2022012905/56813590550346895d9cff2c/html5/thumbnails/70.jpg)
70 การเล อักท�า
![Page 71: บทที่ 2 การวิเคราะห์อัลกอริทึม](https://reader030.vdocuments.pub/reader030/viewer/2022012905/56813590550346895d9cff2c/html5/thumbnails/71.jpg)
71 การท�างานัแบบวิงวินั
![Page 72: บทที่ 2 การวิเคราะห์อัลกอริทึม](https://reader030.vdocuments.pub/reader030/viewer/2022012905/56813590550346895d9cff2c/html5/thumbnails/72.jpg)
72
![Page 73: บทที่ 2 การวิเคราะห์อัลกอริทึม](https://reader030.vdocuments.pub/reader030/viewer/2022012905/56813590550346895d9cff2c/html5/thumbnails/73.jpg)
73
![Page 74: บทที่ 2 การวิเคราะห์อัลกอริทึม](https://reader030.vdocuments.pub/reader030/viewer/2022012905/56813590550346895d9cff2c/html5/thumbnails/74.jpg)
74
![Page 75: บทที่ 2 การวิเคราะห์อัลกอริทึม](https://reader030.vdocuments.pub/reader030/viewer/2022012905/56813590550346895d9cff2c/html5/thumbnails/75.jpg)
75
![Page 76: บทที่ 2 การวิเคราะห์อัลกอริทึม](https://reader030.vdocuments.pub/reader030/viewer/2022012905/56813590550346895d9cff2c/html5/thumbnails/76.jpg)
76 ต�วิอัย0าง Insertion Sort
![Page 77: บทที่ 2 การวิเคราะห์อัลกอริทึม](https://reader030.vdocuments.pub/reader030/viewer/2022012905/56813590550346895d9cff2c/html5/thumbnails/77.jpg)
77 ต�วิอัย0าง while
![Page 78: บทที่ 2 การวิเคราะห์อัลกอริทึม](https://reader030.vdocuments.pub/reader030/viewer/2022012905/56813590550346895d9cff2c/html5/thumbnails/78.jpg)
78
![Page 79: บทที่ 2 การวิเคราะห์อัลกอริทึม](https://reader030.vdocuments.pub/reader030/viewer/2022012905/56813590550346895d9cff2c/html5/thumbnails/79.jpg)
79 การท�างานัแบบเร�ยกซ้ำ�!า
![Page 80: บทที่ 2 การวิเคราะห์อัลกอริทึม](https://reader030.vdocuments.pub/reader030/viewer/2022012905/56813590550346895d9cff2c/html5/thumbnails/80.jpg)
80 ต�วิอัย0าง การค�นัห์าแบบทวิภาค
![Page 81: บทที่ 2 การวิเคราะห์อัลกอริทึม](https://reader030.vdocuments.pub/reader030/viewer/2022012905/56813590550346895d9cff2c/html5/thumbnails/81.jpg)
81 t(m) = t(n/2) +
![Page 82: บทที่ 2 การวิเคราะห์อัลกอริทึม](https://reader030.vdocuments.pub/reader030/viewer/2022012905/56813590550346895d9cff2c/html5/thumbnails/82.jpg)
82 ต�วิอัย0าง: Tower of Hanoi
![Page 83: บทที่ 2 การวิเคราะห์อัลกอริทึม](https://reader030.vdocuments.pub/reader030/viewer/2022012905/56813590550346895d9cff2c/html5/thumbnails/83.jpg)
83 dki
![Page 84: บทที่ 2 การวิเคราะห์อัลกอริทึม](https://reader030.vdocuments.pub/reader030/viewer/2022012905/56813590550346895d9cff2c/html5/thumbnails/84.jpg)
84 ต�นัไม�แทนัภาระจำรงข้อังการเร�ยกซ้ำ�!า
![Page 85: บทที่ 2 การวิเคราะห์อัลกอริทึม](https://reader030.vdocuments.pub/reader030/viewer/2022012905/56813590550346895d9cff2c/html5/thumbnails/85.jpg)
85 ข้นัาดข้�อัม3ล ก�บ ภาระจำรง
![Page 86: บทที่ 2 การวิเคราะห์อัลกอริทึม](https://reader030.vdocuments.pub/reader030/viewer/2022012905/56813590550346895d9cff2c/html5/thumbnails/86.jpg)
86
![Page 87: บทที่ 2 การวิเคราะห์อัลกอริทึม](https://reader030.vdocuments.pub/reader030/viewer/2022012905/56813590550346895d9cff2c/html5/thumbnails/87.jpg)
87
![Page 88: บทที่ 2 การวิเคราะห์อัลกอริทึม](https://reader030.vdocuments.pub/reader030/viewer/2022012905/56813590550346895d9cff2c/html5/thumbnails/88.jpg)
88
![Page 89: บทที่ 2 การวิเคราะห์อัลกอริทึม](https://reader030.vdocuments.pub/reader030/viewer/2022012905/56813590550346895d9cff2c/html5/thumbnails/89.jpg)
89
![Page 90: บทที่ 2 การวิเคราะห์อัลกอริทึม](https://reader030.vdocuments.pub/reader030/viewer/2022012905/56813590550346895d9cff2c/html5/thumbnails/90.jpg)
90
![Page 91: บทที่ 2 การวิเคราะห์อัลกอริทึม](https://reader030.vdocuments.pub/reader030/viewer/2022012905/56813590550346895d9cff2c/html5/thumbnails/91.jpg)
91
![Page 92: บทที่ 2 การวิเคราะห์อัลกอริทึม](https://reader030.vdocuments.pub/reader030/viewer/2022012905/56813590550346895d9cff2c/html5/thumbnails/92.jpg)
92
![Page 93: บทที่ 2 การวิเคราะห์อัลกอริทึม](https://reader030.vdocuments.pub/reader030/viewer/2022012905/56813590550346895d9cff2c/html5/thumbnails/93.jpg)
93
![Page 94: บทที่ 2 การวิเคราะห์อัลกอริทึม](https://reader030.vdocuments.pub/reader030/viewer/2022012905/56813590550346895d9cff2c/html5/thumbnails/94.jpg)
94
![Page 95: บทที่ 2 การวิเคราะห์อัลกอริทึม](https://reader030.vdocuments.pub/reader030/viewer/2022012905/56813590550346895d9cff2c/html5/thumbnails/95.jpg)
95
![Page 96: บทที่ 2 การวิเคราะห์อัลกอริทึม](https://reader030.vdocuments.pub/reader030/viewer/2022012905/56813590550346895d9cff2c/html5/thumbnails/96.jpg)
96
![Page 97: บทที่ 2 การวิเคราะห์อัลกอริทึม](https://reader030.vdocuments.pub/reader030/viewer/2022012905/56813590550346895d9cff2c/html5/thumbnails/97.jpg)
97
![Page 98: บทที่ 2 การวิเคราะห์อัลกอริทึม](https://reader030.vdocuments.pub/reader030/viewer/2022012905/56813590550346895d9cff2c/html5/thumbnails/98.jpg)
98
![Page 99: บทที่ 2 การวิเคราะห์อัลกอริทึม](https://reader030.vdocuments.pub/reader030/viewer/2022012905/56813590550346895d9cff2c/html5/thumbnails/99.jpg)
99
![Page 100: บทที่ 2 การวิเคราะห์อัลกอริทึม](https://reader030.vdocuments.pub/reader030/viewer/2022012905/56813590550346895d9cff2c/html5/thumbnails/100.jpg)
100
![Page 101: บทที่ 2 การวิเคราะห์อัลกอริทึม](https://reader030.vdocuments.pub/reader030/viewer/2022012905/56813590550346895d9cff2c/html5/thumbnails/101.jpg)
101
![Page 102: บทที่ 2 การวิเคราะห์อัลกอริทึม](https://reader030.vdocuments.pub/reader030/viewer/2022012905/56813590550346895d9cff2c/html5/thumbnails/102.jpg)
102
![Page 103: บทที่ 2 การวิเคราะห์อัลกอริทึม](https://reader030.vdocuments.pub/reader030/viewer/2022012905/56813590550346895d9cff2c/html5/thumbnails/103.jpg)
103
![Page 104: บทที่ 2 การวิเคราะห์อัลกอริทึม](https://reader030.vdocuments.pub/reader030/viewer/2022012905/56813590550346895d9cff2c/html5/thumbnails/104.jpg)
104
![Page 105: บทที่ 2 การวิเคราะห์อัลกอริทึม](https://reader030.vdocuments.pub/reader030/viewer/2022012905/56813590550346895d9cff2c/html5/thumbnails/105.jpg)
105
![Page 106: บทที่ 2 การวิเคราะห์อัลกอริทึม](https://reader030.vdocuments.pub/reader030/viewer/2022012905/56813590550346895d9cff2c/html5/thumbnails/106.jpg)
106
![Page 107: บทที่ 2 การวิเคราะห์อัลกอริทึม](https://reader030.vdocuments.pub/reader030/viewer/2022012905/56813590550346895d9cff2c/html5/thumbnails/107.jpg)
107
![Page 108: บทที่ 2 การวิเคราะห์อัลกอริทึม](https://reader030.vdocuments.pub/reader030/viewer/2022012905/56813590550346895d9cff2c/html5/thumbnails/108.jpg)
108