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

2024-03-03 07:12

本文主要是介绍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)

这篇关于Programming Abstractions in C阅读笔记:p308-p311的文章就介绍到这儿,希望我们推荐的文章对编程师们有所帮助!



http://www.chinasem.cn/article/768870

相关文章

JAVA智听未来一站式有声阅读平台听书系统小程序源码

智听未来,一站式有声阅读平台听书系统 🌟&nbsp;开篇:遇见未来,从“智听”开始 在这个快节奏的时代,你是否渴望在忙碌的间隙,找到一片属于自己的宁静角落?是否梦想着能随时随地,沉浸在知识的海洋,或是故事的奇幻世界里?今天,就让我带你一起探索“智听未来”——这一站式有声阅读平台听书系统,它正悄悄改变着我们的阅读方式,让未来触手可及! 📚&nbsp;第一站:海量资源,应有尽有 走进“智听

【学习笔记】 陈强-机器学习-Python-Ch15 人工神经网络(1)sklearn

系列文章目录 监督学习:参数方法 【学习笔记】 陈强-机器学习-Python-Ch4 线性回归 【学习笔记】 陈强-机器学习-Python-Ch5 逻辑回归 【课后题练习】 陈强-机器学习-Python-Ch5 逻辑回归(SAheart.csv) 【学习笔记】 陈强-机器学习-Python-Ch6 多项逻辑回归 【学习笔记 及 课后题练习】 陈强-机器学习-Python-Ch7 判别分析 【学

系统架构师考试学习笔记第三篇——架构设计高级知识(20)通信系统架构设计理论与实践

本章知识考点:         第20课时主要学习通信系统架构设计的理论和工作中的实践。根据新版考试大纲,本课时知识点会涉及案例分析题(25分),而在历年考试中,案例题对该部分内容的考查并不多,虽在综合知识选择题目中经常考查,但分值也不高。本课时内容侧重于对知识点的记忆和理解,按照以往的出题规律,通信系统架构设计基础知识点多来源于教材内的基础网络设备、网络架构和教材外最新时事热点技术。本课时知识

论文阅读笔记: Segment Anything

文章目录 Segment Anything摘要引言任务模型数据引擎数据集负责任的人工智能 Segment Anything Model图像编码器提示编码器mask解码器解决歧义损失和训练 Segment Anything 论文地址: https://arxiv.org/abs/2304.02643 代码地址:https://github.com/facebookresear

数学建模笔记—— 非线性规划

数学建模笔记—— 非线性规划 非线性规划1. 模型原理1.1 非线性规划的标准型1.2 非线性规划求解的Matlab函数 2. 典型例题3. matlab代码求解3.1 例1 一个简单示例3.2 例2 选址问题1. 第一问 线性规划2. 第二问 非线性规划 非线性规划 非线性规划是一种求解目标函数或约束条件中有一个或几个非线性函数的最优化问题的方法。运筹学的一个重要分支。2

【C++学习笔记 20】C++中的智能指针

智能指针的功能 在上一篇笔记提到了在栈和堆上创建变量的区别,使用new关键字创建变量时,需要搭配delete关键字销毁变量。而智能指针的作用就是调用new分配内存时,不必自己去调用delete,甚至不用调用new。 智能指针实际上就是对原始指针的包装。 unique_ptr 最简单的智能指针,是一种作用域指针,意思是当指针超出该作用域时,会自动调用delete。它名为unique的原因是这个

查看提交历史 —— Git 学习笔记 11

查看提交历史 查看提交历史 不带任何选项的git log-p选项--stat 选项--pretty=oneline选项--pretty=format选项git log常用选项列表参考资料 在提交了若干更新,又或者克隆了某个项目之后,你也许想回顾下提交历史。 完成这个任务最简单而又有效的 工具是 git log 命令。 接下来的例子会用一个用于演示的 simplegit

记录每次更新到仓库 —— Git 学习笔记 10

记录每次更新到仓库 文章目录 文件的状态三个区域检查当前文件状态跟踪新文件取消跟踪(un-tracking)文件重新跟踪(re-tracking)文件暂存已修改文件忽略某些文件查看已暂存和未暂存的修改提交更新跳过暂存区删除文件移动文件参考资料 咱们接着很多天以前的 取得Git仓库 这篇文章继续说。 文件的状态 不管是通过哪种方法,现在我们已经有了一个仓库,并从这个仓

忽略某些文件 —— Git 学习笔记 05

忽略某些文件 忽略某些文件 通过.gitignore文件其他规则源如何选择规则源参考资料 对于某些文件,我们不希望把它们纳入 Git 的管理,也不希望它们总出现在未跟踪文件列表。通常它们都是些自动生成的文件,比如日志文件、编译过程中创建的临时文件等。 通过.gitignore文件 假设我们要忽略 lib.a 文件,那我们可以在 lib.a 所在目录下创建一个名为 .gi

取得 Git 仓库 —— Git 学习笔记 04

取得 Git 仓库 —— Git 学习笔记 04 我认为, Git 的学习分为两大块:一是工作区、索引、本地版本库之间的交互;二是本地版本库和远程版本库之间的交互。第一块是基础,第二块是难点。 下面,我们就围绕着第一部分内容来学习,先不考虑远程仓库,只考虑本地仓库。 怎样取得项目的 Git 仓库? 有两种取得 Git 项目仓库的方法。第一种是在本地创建一个新的仓库,第二种是把其他地方的某个