Programming Abstractions in C阅读笔记:p293-p302

《Programming Abstractions in C》学习第73天,p293-p302总结,总计10页。

一、技术总结

1.时间复杂度

(1)quadratic time(二次时间)

p293, Algorithms like selection sort that exhibit O(N^2) performance are said to run in quadratic time。

2.线性查找(linear search)

p293, Because the for loop in the implementation executes n time, you expect the performance of LinearSearch——as its name implies——to be O(N)。时间复杂度为O(N)的查找称为线性查找。

3.归并排序(merge sort)

书中并为对归并排序做严格的定义。p298, The merge operation, combined with recursive decomposition, gives rise to a new sorting algorithm called merge sort, which you can implement in straightforward way. The basic idea of the algorithm can be outlined as follows:

  1. Check to see if the array is empty or has only one element. If so, it must alread be sorted, and the function can return without doing any work. This condition defines the simple case for the recursion.
  2. Divide the array into two new subarrays, each of which is half the size of the original.
  3. Sort each of the subarrasy recursively.
  4. Merge the two subarrays back into the original one.
/** 伪代码*/
static void Merge(int array[], int arr1[], int n1, int arr2[], int n2);
static int *CopySubArray(int array[], int start, int n);
void SortIntegerArray(int array[], int n);
/** Function: SortIntegerArray* Usage: SortIntegerArray(array, n);* ----------------------------------* This function sorts the first n elements of array into* increasing numerical order using the merge sort algorithm,* which requires (1) dividing the array into two halves,* (2) sorting each half, and (3) merging the halves together.*/
void SortIntegerArray(int array[], int n) {int n1, n2, *arr1, *arr2;if (n <= 1) {return;}n1 = n / 2;n2 = n - n1;arr1 = CopySubArray(array, 0, n1);arr2 = CopySubArray(array, 0, n2);SortIntegerArray(arr1, n1);SortIntegerArray(arr1, n2);Merge(array, arr1, n1, arr2, n2);FreeBlock(arr1);FreeBlock(arr2);
}/** Function: Merge* Usage: Merge(array, arr1, n1, arr2, n2);* ----------------------------------------* This function merges two sorted arrays (arr1 and arr2) into a* single output array. Because the input arrays are sorted, the* implementation can always select the first unused element in* one of the input arrays to fill the next position in array.*/static void Merge(int array[], int arr1[], int n1, int arr2[], int n2) {int p, p1, p2;p = p1 = p2 = 0;while (p1 < n1 && p2 < n2) {if (arr1[p1] < arr2[p2]) {array[p++] = arr1[p1++];} else {array[p++] = arr2[p2++];}}while (p1 < n1) {array[p++] = arr1[p1++];}while (p2 < n2) {array[p++] = arr2[p2++];}
}/** Function: CopySubArray* Usage: CopySubArray(array, arr1, n1, arr2, n2);* -----------------------------------------------* This function makes a copy of a subset of an integer array* and returns a pointer to a new dynamic array containing the* new elements. The array begins at the indicated start* position in the original array and continues for n elemnts.*/static int *CopySubArray(int array[], int start, int n) {int i, *result;result = NewArray(n, int);for (i = 0; i < n; i++) {result[i] = array[start + i];}return result;
}

二、英语总结

1.quadratic是什么意思?

答:In mathematics by 1660s;the algebraic quadratic euqation(二次方程, 1680s) are so called because they involve the square(x^2) and no higher power of x。这里要注意quarter是四分之一,但是quadratic是二次(x^2)的意思。

2.sophistication是什么意思?

答:

(1)sophist > sophiticate > sophistication。

(2)sophist: one who makes use of fallacious arguments(诡辩者)。

(3)sophistication: u. the quality of being sophisticated(老练, 复杂度)。

p293, The problem, howerver is that average-case analysis is much more difficult to carry out and typically requires considerable mathematical sophistication。这里比较重要的一点是虽然这里用的是名词sophistication,但是因为翻译的时候需要转一下,mathematical sophistication(复杂的数学知识)。

3.average用法总结

答:

(1)vt. to reach a particular amount as an average。主语可以是物也可以是人。翻译的时候需要灵活转变。

主语是物:Inquires to our office average 1000 calls a month.

主语是人:p294, From a practical point of view, it is often useful to consider how well an algorithm performs if you average its behavior over all possible sets of input data

三、其它

本书中作者讲解归并排序(merge sort)和其它书还是有些不同的,从选择排序算法展开,从而引出归并排序算法,可以和其它书进行对比阅读。

四、参考资料

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)

本文来自互联网用户投稿,该文观点仅代表作者本人,不代表本站立场。本站仅提供信息存储空间服务,不拥有所有权,不承担相关法律责任。如若转载,请注明出处:http://www.mzph.cn/news/701990.shtml

如若内容造成侵权/违法违规/事实不符,请联系多彩编程网进行投诉反馈email:809451989@qq.com,一经查实,立即删除!

相关文章

如何利用EXCEL批量插入图片

目录 1.excel打开目标表格&#xff1b; 2.点开视图-宏-录制宏&#xff0c;可以改宏的名字或者选择默认&#xff1b; 3.然后点开视图-宏-查看宏 4.点编辑进去 5.修改代码&#xff1a; &#xff08;1&#xff09;打开之后会显示有一堆代码 &#xff08;2&#xff09;将这个…

记录 | go与C/C++交互

Go语言是类C的语言&#xff0c;与C语言有着千丝万缕的联系&#xff0c;在Go语言的代码中可以直接调用C语言代码&#xff0c;但不支持直接调用 C。 Go 调用 C/C 的方式&#xff1a; C&#xff1a;直接调用 C API&#xff1b;C&#xff1a;通过实现一层封装的 C 接口来调用 C 接…

Django入门指南:从环境搭建到模型管理系统的完整教程

环境安装&#xff1a; ​ 由于我的C的Anaconda 是安装在C盘的&#xff0c;但是没内存了&#xff0c;所有我将环境转在e盘&#xff0c;下面的命令是创建环境到指定目录中. conda create --prefixE:\envs\dj42 python3.9进入环境中&#xff1a; conda activate E:\envs\dj42…

一周学会Django5 Python Web开发-Http请求HttpRequest请求类

锋哥原创的Python Web开发 Django5视频教程&#xff1a; 2024版 Django5 Python web开发 视频教程(无废话版) 玩命更新中~_哔哩哔哩_bilibili2024版 Django5 Python web开发 视频教程(无废话版) 玩命更新中~共计25条视频&#xff0c;包括&#xff1a;2024版 Django5 Python we…

lxml库和Xpath提取网页数据的基础与实战:完整指南与实战【第92篇—提取网页】

使用lxml库和Xpath提取网页数据的基础与实战 在网络爬虫和数据抓取中&#xff0c;从网页中提取所需信息是一项常见的任务。lxml库和Xpath是Python中用于解析和提取HTML/XML数据的强大工具。本文将介绍lxml库的基础知识&#xff0c;以及如何使用Xpath表达式来准确地提取网页数据…

[HTML]Web前端开发技术30(HTML5、CSS3、JavaScript )JavaScript基础——喵喵画网页

希望你开心,希望你健康,希望你幸福,希望你点赞! 最后的最后,关注喵,关注喵,关注喵,佬佬会看到更多有趣的博客哦!!! 喵喵喵,你对我真的很重要! 目录 前言 网页标题:手机批发业务-商品备选区<

Swift Combine 使用 handleEvents 操作符调试管道 从入门到精通二十五

Combine 系列 Swift Combine 从入门到精通一Swift Combine 发布者订阅者操作者 从入门到精通二Swift Combine 管道 从入门到精通三Swift Combine 发布者publisher的生命周期 从入门到精通四Swift Combine 操作符operations和Subjects发布者的生命周期 从入门到精通五Swift Com…

【GO语言卵细胞级别教程】07.捕获异常和自定义错误

【GO语言卵细胞级别教程】07.捕获异常和自定义错误 &#x1f970;博主&#xff1a;GokuCode &#x1f970;微信公众号&#xff1a;【给点知识】分享小知识&#xff0c;快速成长,欢迎关注呀&#xff01;&#xff08;底部点击二维码&#xff09; &#x1f970;本项目演示代码仓库…

Windows Server 2012 IIS中发布ASP.NET CORE项目

服务器安装IIS&#xff1a; 微软官网下载SDK&#xff1a; 下载Runtime官网&#xff1a;https://dotnet.microsoft.com/download/dotnet-core 安装成功重启IIS&#xff1a; VS发布项目&#xff1a;

分享:如何做好Temu跨境电商项目的几点方法

Temu跨境电商项目作为中国电商巨头拼多多旗下的新兴跨境电商平台&#xff0c;近年来发展迅速&#xff0c;吸引了大量国内卖家参与。然而&#xff0c;由于跨境电商的复杂性和竞争激烈&#xff0c;如何在Temu平台上成功运营&#xff0c;实现良好的销售业绩&#xff0c;成为许多卖…

Chiplet技术与汽车芯片(二)

目录 1.回顾 2.Chiplet的优势 2.1 提升芯片良率、降本增效 2.2 设计灵活&#xff0c;降低设计成本 2.3 标准实行&#xff0c;构建生态 3.Chiplet如何上车 1.回顾 上一篇&#xff0c;我们将来芯粒到底是什么东西&#xff0c;本篇我们来看芯粒技术的优势&#xff0c;以及它…

软考39-上午题-【数据库】-关系代数运算1-传统的集合运算

一、笛卡尔积 二、关系代数 关系代数是施加于关系之上的集合代数运算。 关系代数包含&#xff1a; 传统的集合运算专门的关系运算 2-1、传统的集合运算 1、关系的并 示例&#xff1a; 2、关系的差 示例&#xff1a; 3、关系的交 示例&#xff1a; 关系的并、差、交&#xf…

一 . java语言概述——Java基础篇

一 . java语言概述——Java基础 发展阶段&#xff1a; 发行版本发行时间备注Java 1.01996.01.23Sun公司发布了Java的第一个开发工具包Java 1.11997.02.19JavaOne会议召开&#xff0c;创当时全球同类会议规模之最。Java 1.21998.12.08Java拆分成&#xff1a;J2SE&#xff08;标…

用户头像(图片文件)上传(Vue + nodejs 前后端)

文件上传&#xff08;图片上传&#xff09; 前端&#xff1a;Vue3 element-plus 后端&#xff1a;express 前端 封装一个 Upload 组件和一个 upload 方法。 Upload 组件 <!-- auto-upload 选择好图片后立刻自动上传后端还是手动点击某按钮上传后端 --><el-upload…

jax可微分编程的笔记(3)

jax可微分编程的笔记&#xff08;3&#xff09; 第3章 初识JAX JAX是Google开发的高性能数值计算和自动微分库&#xff0c;提供自动微分 即时编译和矢量并行化三大功能。JAX选择将函数编程的思想贯穿 始终。 简单来说&#xff0c;JAX库是GPU加速&#xff0c;支持自动微分的Nu…

android pdf框架-4,分析barteksc/PdfiumAndroid源码1

关于barteksc/PdfiumAndroid barteksc/PdfiumAndroid 这个源码被,引用的次数是比较高的,flutter的几个pdf库也是引用它.它使用福昕的开源sdk.福昕阅读器我早期的时候用,交互一般,渲染也不如mupdf,有些pdf中文显示不了,体积小点. barteksc/PdfiumAndroid已经是一个完善的sdk了,…

微信小程序开发(实战案例):本地生活 - 列表页面开发(动态渲染处理)、节流防抖(节流阀应用)

文章目录 本地生活 - 列表页面开发一、将九宫格分类换成navigator组件二、动态设置商品列表页的 title三、动态渲染商品列表页面四、上拉触底加载数据五、添加Loading加载效果六、数据加载节流防抖处理 本地生活 - 列表页面开发 导入我们上次写的 本地生活 - 首页开发的项目 运…

leetcode 50. Pow(x, n)

目录 函数定义&#xff1a; 2. 处理特殊情况&#xff1a; 3. 处理负指数&#xff1a; 4. 处理偶数指数&#xff1a; 5. 处理奇数指数&#xff1a; 时间复杂度 空间复杂度 class Solution { public:double myPow(double x, int n) {if(n 0){return 1;}if(n 1) return x…

C#设计模式---工厂方法模式

24种常用设计模式 创建型模式&#xff1a;抽象工厂、生成器、工厂方法、原型、单例&#xff1b; 结构型模式&#xff1a;适配器、桥接、组合、装饰、外观、享元、代理&#xff1b; 行为模式&#xff1a;责任链、命令、迭代器、中介者、备忘录、观察者、状态、策略、模板方法…

二分算法(c++版)

二分的本质是什么&#xff1f; 很多人会认为单调性是二分的本质&#xff0c;但其实其本质并非单调性&#xff0c;只是说&#xff0c;有单调性的可以进行二分&#xff0c;但是有些题目没有单调性我们也可以进行二分。其本质其实是一个边界问题&#xff0c;给定一个条件&#xf…