当前位置: 首页 > news >正文

Programming Abstractions in C阅读笔记:p308-p311

《Programming Abstractions in C》学习第76天,p308-p311总结,总计4页。

一、技术总结

1.快速排序伪代码

#include <stdbool.h>static int Partition(int array[], int n);/** Implementation notes: SortIntegerArray* --------------------------------------* This implementation of SortIntegerArray uses the Quicksort* algorithm, which begins by "partitioning" the array so that* all elements smaller than a designated pivot element appear* to the left of a boundary and all equal or larger values* appear to the right. Sorting the subarrays to the left and* right of boundary ensures that the entire array is sorted.*/void SortIntegerArray(int array[], int n) {int boundary;if (n < 2) {return;}boundary = Partition(array, n);SortIntegerArray(array, boundary);SortIntegerArray(array + boundary + 1, n - boundary - 1);
}/** Function: Partition* Usage: boundary = Partition(array, n);* --------------------------------------* This function rearranges the elements of array relative to* a pivot value, which is taken from array[0]. The partition* function returns a boundary index such that array[i] < pivot* for all i < boundary, array[i] == pivot for i == boundary,* and array[i] >= pivot for all i > boundary.*/static int Partition(int array[], int n) {int lh, rh, pivot, temp;pivot = array[0];lh = 1;rh = n - 1;while (true) {while (lh < rh && array[rh] >= pivot) {rh--;}while (lh < rh && array[lh] < pivot) {lh--;}if (lh == rh) {break;}temp = array[lh];array[lh] = array[rh];array[rh] = temp;}if (array[lh] >= pivot) {return 0;}array[0] = array[lh];array[lh] = pivot;return lh;
}

2.快速排序时间复杂度

平均时间复杂度:O(NlogN), 最坏时间复杂度:O(N^2)。

二、英语总结

1.fairly是什么意思?

p308, Tony Hoare’s approach to partioning is fairly easy to explain in English。

答:

(1)fair: adj. fair比较常用的意思是:treating someone in a way that is right or reasonable(公正的,公平的);但也有一个用得比较少的意思: quite large。

(2)fairly: fair + ly。adv. more than average, but less than very(相当地)。

2.coincide是什么意思?

p308, Move the rh index to the left until it either coincides with lh or points to an element containing a value that is small with respect to the pivot。

答:com-(together) + incidere(to fall upon)。vi. to come together in position / to happen at or near the same time。

3.roughly是什么意思?

答:

(1)rough: adj. a. not even(均匀) or smooth(光滑), often because of being in bad condistion。b. not exact or detailed(大致)。

p311, Moreover the running times for both algorithms appear to grow in roughly the same way。

4.appear to 是什么意思?

答:vi. to seem(看起来,似乎)

三、其它

英语阅读要想快速理解,就得尽可能把每个单词的所有意思都记录,如上面的:fairly——最常用的意思就是“公平地”,但书中明显不是这个意思,而是“quite large(相当地)”,平时用得少,没有在意,导致整个句子无法理解。还有rough也是,常用意思是"not smooth(粗糙的)",但也有“not exact or detailed(大致的)”之意。

四、参考资料

1. 编程

(1)Eric S.Roberts,《Programming Abstractions in C》:https://book.douban.com/subject/2003414

2. 英语

(1)Etymology Dictionary:https://www.etymonline.com

(2) Cambridage Dictionary:https://dictionary.cambridge.org

在这里插入图片描述

欢迎搜索及关注:编程人(a_codists)

相关文章:

  • 暗九之凶险,更甚于明九
  • K8S部署postgresql
  • Node.js_基础知识(CommonJS模块化)
  • Hololens 2应用开发系列(1)——使用MRTK在Unity中设置混合现实场景并进行程序模拟
  • 23端口登录的Telnet命令+传输协议FTP命令
  • Django 表单
  • 【Git】深入理解 Git 分支合并操作:git merge dev 命令详解
  • 2024年,智慧文旅领航新时代,重塑旅行体验的未来篇章!
  • oppo手机备忘录记录怎么转移到华为手机?
  • wordpress 开源主题
  • Linux 开发工具vim、gcc/g++、makefile
  • TypeScript08:在TS中使用模块化
  • AGI概念与实现
  • 【接口测试】常见HTTP面试题
  • esp32 C3和S3 开发板电流对比
  • 【刷算法】从上往下打印二叉树
  • Cookie 在前端中的实践
  • input的行数自动增减
  • rabbitmq延迟消息示例
  • Service Worker
  • STAR法则
  • Three.js 再探 - 写一个跳一跳极简版游戏
  • UEditor初始化失败(实例已存在,但视图未渲染出来,单页化)
  • 分类模型——Logistics Regression
  • 官方解决所有 npm 全局安装权限问题
  • 马上搞懂 GeoJSON
  • 前端_面试
  • 在Docker Swarm上部署Apache Storm:第1部分
  • 【运维趟坑回忆录 开篇】初入初创, 一脸懵
  • 大数据全解:定义、价值及挑战
  • 扩展资源服务器解决oauth2 性能瓶颈
  • ​​​​​​​​​​​​​​Γ函数
  • ​configparser --- 配置文件解析器​
  • ​secrets --- 生成管理密码的安全随机数​
  • (13):Silverlight 2 数据与通信之WebRequest
  • (C#)Windows Shell 外壳编程系列4 - 上下文菜单(iContextMenu)(二)嵌入菜单和执行命令...
  • (附源码)ssm经济信息门户网站 毕业设计 141634
  • (接口自动化)Python3操作MySQL数据库
  • (已解决)报错:Could not load the Qt platform plugin “xcb“
  • (转)AS3正则:元子符,元序列,标志,数量表达符
  • (转)JVM内存分配 -Xms128m -Xmx512m -XX:PermSize=128m -XX:MaxPermSize=512m
  • (转)一些感悟
  • ****** 二 ******、软设笔记【数据结构】-KMP算法、树、二叉树
  • **CI中自动类加载的用法总结
  • *setTimeout实现text输入在用户停顿时才调用事件!*
  • .NET Core 成都线下面基会拉开序幕
  • .net 中viewstate的原理和使用
  • .NET 自定义中间件 判断是否存在 AllowAnonymousAttribute 特性 来判断是否需要身份验证
  • .Net转前端开发-启航篇,如何定制博客园主题
  • /etc/X11/xorg.conf 文件被误改后进不了图形化界面
  • @Builder用法
  • @Transactional 详解
  • [ CTF ]【天格】战队WriteUp- 2022年第三届“网鼎杯”网络安全大赛(青龙组)
  • [1159]adb判断手机屏幕状态并点亮屏幕
  • [2016.7 test.5] T1