算法业计与分折 空间复杂性 Char -128127 unsigned char 1 0255 short 3276832767 int -3276832767 unsigned int 2224 065535 long unsigned long 4 20 31931 232-1 float ±3.4E±38 double ong d ouble pointer 48124 土1.7E±308 103.4E-49321.1E+4932 (near,cs,ds,es,ss指针) pointer (far,huge指针) 注意:在32位 Borland c++程序中,int类型的长度为4 26 算法设计与分析
算法设计与分析 26 Char 1 - 128 ~ 127 unsigned char 1 0 ~ 255 short 2 -32768~32767 int 2 -32768~32767 unsigned int 2 0~65 535 long 4 - 2 31~ 2 31- 1 unsigned long 4 0 ~ 2 32- 1 float 4 ±3.4 E±38 double 8 ±1.7 E±308 long double 10 3. 4E-4932~1.1E+4932 pointer 2 ( near,_cs,_ds,_es,_ss指针) pointer 4 ( far, huge 指针) 注意:在32位Borland C++程序中,int类型的长度为4 空间复杂性
算法业计与分祈 空间复杂性 ◆ double a[100]; int mazerowslcols ◆Rsum(a,n) Rsum(a, n-1) Rsum(a, n-2) Rsum(a, 1) Rsum(a, 0) 27 算法设计与分析
算法设计与分析 27 空间复杂性 w double a[100]; int maze[rows][cols] w Rsum(a, n) Rsum(a, n-1) Rsum(a, n-2) . . . Rsum(a, 1) Rsum(a, 0)
算法业计与分祈 估算运行时间 ◆ count<-0 ◆ while n>1 ◆forj←1ton ◆ count←- count+1 end for n←n end while ◆ Return count 28 算法设计与分析
算法设计与分析 28 估算运行时间 w count←0 w while n≥1 w for j ←1 to n w count ←count+1 w end for w n ←n/2 w end while w Return count
算法业计与分祈 估算运行时间 ◆ count<-0 fori←1ton m<Ln/i」 forj←1tom count← count+1 end for ◆ end for ◆ Return count 29 算法设计与分析
算法设计与分析 29 估算运行时间 w count←0 w for i ←1 to n w m ←n/i w for j ←1 to m w count ←count+1 w end for w end for w Return count
算法业计与分祈 ◆ count←0 ◆fori←-1ton ◆ while isn count← count+1 ◆ end while ◆ end for ◆ return count 算法设计与分析
算法设计与分析 30 w count ←0 w for i←1 to n w j←2 w while j≤n w j←j2 w count ←count+1 w end while w end for w return count