《Programming Abstractions In C》学习第61天,p181-p183总结。

一、技术总结

1.linear search algorithm

2.lexicographic order(字典顺序)

3.binary search algorithm(二分查找算法)

/*
* 1.二分查找也应用了递归的思想。
* 2.这里的代码只是demo
*/
#include <stdio.h>
#include "strlib.h" int FindStringInSortedArray(string key, string array[], int n); static int BinarySearch(string key, string array[], int low, int high); /*
* Function: FindStringInSortedArray
* Usage: index = FindStringInSortedArray(key, array, n);
* ------------------------------------------------------
* This function searches the array looking for the specified
* key. The argument n specifies the effective size of the
* array, which must be sorted according to the lexicographic
* order imposed by StringCompare. If the key is found, the
* function returns the index in the array at which that key
* appears. (If the key appears more that once in the array,
* any of the matching indices may be return). If the key
* does not exist in the array, the function returns -1. In
* this implementation, FindStringInSortedArray is simply a
* wrapper; all the work is done by the recursive function
* BinarySearch.
*/
int FindStringInSortedArray(string key, string array[], int n) {
return BinarySearch(key, array, 0, n - 1);
} /*
* Function: BinarySearch
* Usage: index = BinarySearch(key, array, low, high);
* ---------------------------------------------------
* This function does the work for FindStringInSortedArray.
* The only difference is that BinarySearch takes both the
* upper and lower limit of the search.
*/
static int BinarySearch(string key, string array[], int low, int high) {
int mid, cmp; if (low > high) {
return -1;
}
mid = (low + high) / 2;
cmp = StringCompare(key, array[mid]);
if (cmp == 0) {
return mid;
}
if (cmp < 0) {
return BinarySearch(key, array, low, mid - 1);
} else {
return BinarySearch(key, array, mid + 1, high);
}
} int main() {
int index;
char *arr[] = {"Programming Abstractions in C", "Hello World", "C"};
index = FindStringInSortedArray("C", arr, 3);
printf("index is: %d", index);
return 0;
}

二、英语总结

1.lecicographic是什么意思?

答:

(1)lexicographic < lexicography: adj. of or relating lexicography(字典的)。

(2)lexicography: lexico-("wordbook",字典) + -graphy("to write")

2.adhere是什么意思?

答:p182,Although most of the recursive functions you encounter are likely to adhere to this style, the definition of the recursion is actually somewhat broader。ad-("to") + haerere("to stick")。vi. to stick firmely(附着,遵循)。后面常接介词to。

三、参考资料

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阅读笔记:p181-p183的更多相关文章

  1. 《Java编程思想》阅读笔记二

    Java编程思想 这是一个通过对<Java编程思想>(Think in java)进行阅读同时对java内容查漏补缺的系列.一些基础的知识不会被罗列出来,这里只会列出一些程序员经常会忽略或 ...

  2. Mongodb Manual阅读笔记:CH3 数据模型(Data Models)

    3数据模型(Data Models) Mongodb Manual阅读笔记:CH2 Mongodb CRUD 操作Mongodb Manual阅读笔记:CH3 数据模型(Data Models)Mon ...

  3. Introduction to 3D Game Programming with DirectX 12 学习笔记之 --- 第二十三章:角色动画

    原文:Introduction to 3D Game Programming with DirectX 12 学习笔记之 --- 第二十三章:角色动画 学习目标 熟悉蒙皮动画的术语: 学习网格层级变换 ...

  4. Introduction to 3D Game Programming with DirectX 12 学习笔记之 --- 第十一章:模板测试

    原文:Introduction to 3D Game Programming with DirectX 12 学习笔记之 --- 第十一章:模板测试 代码工程地址: https://github.co ...

  5. Introduction to 3D Game Programming with DirectX 12 学习笔记之 --- 第六章:在Direct3D中绘制

    原文:Introduction to 3D Game Programming with DirectX 12 学习笔记之 --- 第六章:在Direct3D中绘制 代码工程地址: https://gi ...

  6. Introduction to 3D Game Programming with DirectX 12 学习笔记之 --- 第四章:Direct 3D初始化

    原文:Introduction to 3D Game Programming with DirectX 12 学习笔记之 --- 第四章:Direct 3D初始化 学习目标 对Direct 3D编程在 ...

  7. Introduction to 3D Game Programming with DirectX 12 学习笔记之 --- 第二章:矩阵代数

    原文:Introduction to 3D Game Programming with DirectX 12 学习笔记之 --- 第二章:矩阵代数 学习目标: 理解矩阵和与它相关的运算: 理解矩阵的乘 ...

  8. Introduction to 3D Game Programming with DirectX 12 学习笔记之 --- 第一章:向量代数

    原文:Introduction to 3D Game Programming with DirectX 12 学习笔记之 --- 第一章:向量代数 学习目标: 学习如何使用几何学和数字描述 Vecto ...

  9. 阅读笔记 1 火球 UML大战需求分析

    伴随着七天国庆的结束,紧张的学习生活也开始了,首先声明,阅读笔记随着我不断地阅读进度会慢慢更新,而不是一次性的写完,所以会重复的编辑.对于我选的这本   <火球 UML大战需求分析>,首先 ...

  10. [阅读笔记]Software optimization resources

    http://www.agner.org/optimize/#manuals 阅读笔记Optimizing software in C++   7. The efficiency of differe ...

随机推荐

  1. Python的23种设计模式

    文章目录 Python与设计模式--前言 一 什么是设计模式 二 为什么要有设计模式 三 有那些设计模式 创建类设计模式(5种) 结构类设计模式(7种) 行为类设计模式(11种) 四 设计模式与架构, ...

  2. 高效数据管理:Java助力实现Excel数据验证

    摘要:本文由葡萄城技术团队原创并首发.转载请注明出处:葡萄城官网,葡萄城为开发者提供专业的开发工具.解决方案和服务,赋能开发者. 前言 在Java中,开发者可以使用一些开源的库(如Apache POI ...

  3. 【matplotlib 实战】--直方图

    直方图,又称质量分布图,用于表示数据的分布情况,是一种常见的统计图表. 一般用横轴表示数据区间,纵轴表示分布情况,柱子越高,则落在该区间的数量越大.构建直方图时,首先首先就是对数据划分区间,通俗的说即 ...

  4. SQL还是NoSQL?架构师必备选型技能

    很多时候我们都会有这样的疑问. 如果这时候直接去看MySQL.Mongo.HBase.Redis等数据库的用法.特点.区别,其实有点太着急了. 这时候,最好从「数据模型」开始讨论. 1.SQL vs ...

  5. Nginx惊群现象的两种解决办法

    惊群现象: 惊群现象是指由多个worker进程监听同一个Socket事件时,当事件发生时,相关的所有进程被惊醒,但最终只能有一个进程对该事件进行处理,其他进程会重新休眠,从而导致系统资源的浪费和系统性 ...

  6. 16.2 ARP 主机探测技术

    ARP (Address Resolution Protocol,地址解析协议),是一种用于将 IP 地址转换为物理地址(MAC地址)的协议.它在 TCP/IP 协议栈中处于链路层,为了在局域网中能够 ...

  7. kubernetes组件介绍-service概念

    kubernetes组件介绍 MESOS APACHE 分布式资源管理框架 2019-5 Twitter > Kuberneets Dcocker Swarm 2019-07 阿里云宣布 Doc ...

  8. 实战|如何低成本训练一个可以超越 70B Llama2 的模型 Zephyr-7B

    每一周,我们的同事都会向社区的成员们发布一些关于 Hugging Face 相关的更新,包括我们的产品和平台更新.社区活动.学习资源和内容更新.开源库和模型更新等,我们将其称之为「Hugging Ne ...

  9. 实现MyBatisPlus自定义sql注入器

    目标:新增mysql下的 插入更新的语法 INSERT INTO %s %s VALUES %s ON DUPLICATE KEY UPDATE %s 新增方法类,新增的方法名称为insertOrUp ...

  10. MIT实验警示:人类或需要人工智能辅助才能理解复杂逻辑

    麻省理工实验揭示人类的天赋缺陷 麻省理工学院林肯实验室(MIT Lincoln Laboratory)的一项研究表明,尽管形式规范具有数学上的精确性,但人类并不一定能对其进行解释.换句话说就是,人类在 ...