mirror of
				https://github.com/krahets/hello-algo.git
				synced 2025-11-04 14:18:20 +08:00 
			
		
		
		
	Update time_complexity.md
This commit is contained in:
		@ -1434,11 +1434,14 @@ $$
 | 
			
		||||
        for (int i = n - 1; i > 0; i--) {
 | 
			
		||||
            // 内循环:冒泡操作
 | 
			
		||||
            for (int j = 0; j < i; j++) {
 | 
			
		||||
                // 交换 nums[j] 与 nums[j + 1]
 | 
			
		||||
                int tmp = nums[j];
 | 
			
		||||
                nums[j] = nums[j + 1];
 | 
			
		||||
                nums[j + 1] = tmp;
 | 
			
		||||
                count += 3;  // 元素交换包含 3 个单元操作
 | 
			
		||||
                if (nums[j] > nums [j+1]) 
 | 
			
		||||
                {
 | 
			
		||||
                    // 交换 nums[j] 与 nums[j + 1]
 | 
			
		||||
                    int tmp = nums[j];
 | 
			
		||||
                    nums[j] = nums[j + 1];
 | 
			
		||||
                    nums[j + 1] = tmp;
 | 
			
		||||
                    count += 3;  // 元素交换包含 3 个单元操作
 | 
			
		||||
                }
 | 
			
		||||
            }
 | 
			
		||||
            
 | 
			
		||||
        }
 | 
			
		||||
 | 
			
		||||
		Reference in New Issue
	
	Block a user