《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. C++ STL快速入门方法

    在数月之前的机试中第一次体验到STL的威力,因为自己本来一直在用C语言做开发,很多数据结构都是自己造的,比如链表.队列等,第一次接触C++ STL后发现这些数据结构都已经给我提供好了,我直接拿去调用就 ...

  2. tmai

    天猫精灵技能应用平台合作协议 发布日期:2020年03月18日 更新日期:2021年02月01日 鉴于您(语音技能.小程序或应用程序APP等的制作.提供或开发者)希望入驻或与天猫精灵技能应用平台(又称 ...

  3. 关于fdisk -l

    摘取:https://blog.csdn.net/digitalkee/article/details/104226846 # fdisk -l Disk /dev/hda: 160.0 GB, 16 ...

  4. Pandas 读取Eexcel - 间隔N行,读取某列数据

    间隔N行,读取某列数据 import pandas as pd def read_vertical(sheet_name, col_idx, gap): """ 竖着读数 ...

  5. 21.1 Python 使用PEfile分析PE文件

    PeFile模块是Python中一个强大的便携式第三方PE格式分析工具,用于解析和处理Windows可执行文件.该模块提供了一系列的API接口,使得用户可以通过Python脚本来读取和分析PE文件的结 ...

  6. ant design TreeSelect支持搜索,切换value和title属性

    测试人员测试我form里面一个select的时候,发现只能搜索英文和数字,不能搜中文 后来找到原因,treeNodeFilterProp字段默认是velue,我value里面是id,当然搜不到中文啦 ...

  7. html-0

    选择器 (一):first-child和:first-of-type :first-child第一个元素 <!DOCTYPE html> <html> <head> ...

  8. 7/10 luoguRound 10 庆典 div3T1

    #include<bits/stdc++.h> using namespace std; int m,n,x; int arr[100005]; int maxi = -1,maxn = ...

  9. Error running 'TestAlterNickname.test': Command line is too long. Shorten command line for TestAlterNickname.test or also for JUnit default configuration

    问题描述 如图IDEA报错问题,发生在我用JUnit进行测试时. 解决方法 1. 直接点击 default 2. Modify options -> Shorten command line 3 ...

  10. Wampserver搭建DVWA和sqli-labs问题总结

    Wampserver 搭建 DVWA 和 sqli-labs 问题总结 遇到问题解决的思路方法 百度,博客去搜索相关的问题,人工智能 chatgpt 查看官方文档,查看注释. 本次解决方法就是在文档的 ...