- 博客(34)
- 收藏
- 关注
原创 无线局域网的CSMA/CA协议
因此在无线局域网中,我们对CSMA/CD协议进行修改,将冲突检测改为冲突避免(Collision Avoidance,CA),协议的设计是要尽量减少碰撞发生的概率。源站在RTS帧中填写的所需占用信道的持续时间:SIFS+CTS+SIFS+数据帧+SIFS+ACK。AP在CTS帧中填写的所需信道占用时间:SIFS+数据帧+SIFS+ACK。当多个设备竞争信道时,退避算法通过随机等待时间分散发送时机,避免冲突。:信道由忙转空闲后,需等待DIFS时间再启动退避计时器。CSMA/CA通过。
2025-04-16 14:27:02
797
原创 数据链路层的可靠传输机制
可靠传输通常采用和两种机制来实现。用这两种机制的可靠传输协议称为。。1.发送方(主机A)向接收方(主机B)发送带有序号的数据帧(如DATA 0)。2.接收方收到数据帧后,进行差错检测。若无误码,返回确认帧ACK 0。3.发送方收到ACK 0后,删除DATA 0的副本,发送下一帧DATA 1。4.重复上述步骤,每次仅发送一个数据帧并等待确认 B → A: ACK 1。
2025-04-10 16:16:38
1135
原创 408内部排序大盘点
排序算法时间复杂度 (最好)时间复杂度 (平均)时间复杂度 (最坏)空间复杂度稳定性适用性(存储结构)直接插入排序O(n)O(n²)O(n²)O(1)稳定顺序存储、链式存储折半插入排序O(n log n)O(n²)O(n²)O(1)稳定顺序存储希尔排序O(n log n)O(n^1.3)O(n²)O(1)不稳定顺序存储冒泡排序O(n)O(n²)O(n²)O(1)稳定顺序存储、链式存储快速排序O(n log n)O(n log n)
2025-04-03 15:27:30
972
原创 PAT甲级(Advanced Level) Practice 1029 Median
给定两个升序数组,找到他们合并后的中位数,中位数是数组中第(len+1)/2大的数。二分算法详见力扣官方题解。
2025-03-26 16:06:58
316
原创 PAT甲级(Advanced Level) Practice 1028 List Sorting
输入n个学生的id、姓名、分数,再输入C表示对C列进行排序。姓名:姓名不同时从小到大排,相同时id从小到大排。分数:不同时从小到大排,相同时id从小到大排。调用自带的sort函数,自定义比较函数。
2025-03-25 16:18:40
373
原创 PAT甲级(Advanced Level) Practice 1027 Colors in Mars
一道进制转换题,不过本题由于数据转13进制后最多输出两位且必须输出两位,可以直接用数组输出。十进制转十三进制,十三进制下不满两位的补前导0。
2025-03-25 16:00:02
236
原创 PAT甲级(Advanced Level) Practice 1025 PAT Ranking
先对每组学生数据进行处理,然后全部存入数组中进行总的处理。
2025-03-18 19:10:15
280
原创 PAT甲级(Advanced Level) Practice 1024 Palindromic Number
级别,因此选择用大数加法。用vector<int>数组倒序储存n,每次进行运算时相加reverse(n)和n。此外,输入的n有可能直接是回文数,此时应输出0(测试点2,3)。,并记录找到这个回文数所需的步骤数。如果在规定的最大步骤数 K 内没有找到回文数,则输出第 K 步的结果和 K。题目要求为一个给定的正整数 N 找到一个对应的。
2025-03-18 14:33:12
266
原创 PAT甲级(Advanced Level) Practice 1023 Have Fun with Numbers
因为这个数最大可能达到20位,超出了long long的范围,因此我们考虑大数乘法,用vector数组倒序存储该数。用数组digit[]统计每个数字出现的次数,最后将乘2的结果中每个数字统计一遍即可。输入一个不大于20位的数,判断该数乘2后所用的每个数字数量和原数是否一样。
2025-03-17 20:54:55
270
原创 PAT甲级(Advanced Level) Practice 1022 Digital Library
给定一本书的id、书名、作者、(多个)关键词、出版社、出版年份,根据输入的书名、作者、(其中一个)关键词、出版社、出版年份按大小顺序返回id。利用哈希表来储存元素,由于可能多本书有相同的关键字,因此用vector<string>来储存答案的id。另外,对于keywords,我们要额外进行空格分割,再分别将每一个关键词存入哈希表。
2025-03-17 15:38:02
422
原创 PAT甲级(Advanced Level) Practice 1021 Deepest Root
若为树,利用两次bfs和无序集合unordered_set来保存使树深度最大的点,只用一次bfs有可能遇到如图情况:假设我们从G点开始遍历,M点就不会进入答案,因此我们先遍历一次,找到最远的为B,再从B开始遍历,找到M。给定一个连通且无环的图(即树),树的高度取决于根节点的选择。请找出能使树的高度最大的所有根节点(称为“最深根”)。若给定的图不是树(即不连通),需输出连通分量的数量。先找连通分量的数量,利用bfs遍历所有点,标记已经遍历的点,调用函数bfs的次数就是连通分量的个数。
2025-03-15 20:07:09
414
原创 PAT甲级(Advanced Level) Practice 1020 Tree Traversals
本题先将后序中序遍历转化为二叉树,再层序遍历二叉树。想了很久也没想出来怎么直接把后序中序转化为层序,大家如果有直接转化的方法欢迎讨论交流!输入n表示二叉树的元素数量,再分别输入该树的后序和中序遍历,输出该树的层序遍历。
2025-03-15 18:58:46
373
原创 PAT甲级(Advanced Level) Practice 1019 General Palindromic Number
判断数N的b进制是否为回文数,若是,则返回Yes,否则返回No。最后输出N的b进制表示。非常简单的一道进制转换题,直接套模板就行。
2025-03-15 18:26:50
298
原创 PAT甲级(Advanced Level) Practice 1018 Public Bike Management
最后,在另一个空格后,输出 Sp 条件调整为完美后,我们必须送回 PBMC 的自行车数量。我的方法是记录 dfs到的点(u)身边带着的车的数量 和 带出来的车的数量。到达新的点时,计算该点需要增加车的数量(可以是负数),如果是正数,则手上的车减少(不够就减则增加带出来的车数量);if(dist[i] == dist[j] + distance(i, j)), 则i在j的最短路路径上,并且i是j的前一个点。注意,如果该路径不是唯一的,则输出我们必须带回 PBMC 的自行车数量最少的路径。
2024-03-20 15:33:23
1026
1
原创 PAT甲级(Advanced Level) Practice 1017 Queueing at Bank
Suppose a bank has K windows open for service. There is a yellow line in front of the windows which devides the waiting area into two parts. All the customers have to wait in line behind the yellow line, until it is his/her turn to be served and there is a
2024-03-19 14:45:32
708
1
原创 PAT甲级(Advanced Level) Practice 1016 Phone Bills
A long-distance telephone company charges its customers by the following rules:Making a long-distance call costs a certain amount per minute, depending on the time of day when the call is made. When a customer starts connecting a long-distance call, the ti
2024-03-18 14:54:49
945
原创 PAT甲级(Advanced Level) Practice 1015 Reversible Primes
A reversible prime in any number system is a prime whose "reverse" in that number system is also a prime. For example in the decimal system 73 is a reversible prime because its reverse 37 is also a prime.Now given any two positive integers N (<105) and D (
2024-03-16 13:08:34
428
1
原创 PAT甲级(Advanced Level) Practice 1014 Waiting in Line
Suppose a bank has N windows open for service. There is a yellow line in front of the windows which devides the waiting area into two parts. The rules for the customers to wait in line are:Now given the processing time of each customer, you are supposed to
2024-03-16 12:32:25
874
1
原创 PAT甲级(Advanced Level) Practice 1012 The Best Rank
To evaluate the performance of our first year CS majored students, we consider their grades of three courses only: - C Programming Language, - Mathematics (Calculus or Linear Algrbra), and - English. At the mean time, we encourage students by emphasizin
2024-03-15 08:30:00
1222
1
原创 PAT甲级(Advanced Level) Practice 1011 World Cup Betting
With the 2010 FIFA World Cup running, football fans the world over were becoming increasingly excited as the best players from the best teams doing battles for the World Cup trophy in South Africa. Similarly, football betting fans were putting their money
2024-03-15 08:00:00
1278
1
原创 PAT甲级(Advanced Level) Practice 1010 Radix
Given a pair of positive integers, for example, 6 and 110, can this equation 6 = 110 be true? The answer is , if 6 is a decimal number and 110 is a binary number.Now for any pair of positive integers N1 and N2, your task is to find the radix of one numbe
2024-03-14 18:12:52
850
原创 PAT甲级(Advanced Level) Practice 1006 Sign In and Sign Out
At the beginning of every day, the first person who signs in the computer room will unlock the door, and the last one who signs out will lock the door. Given the records of signing in's and out's, you are supposed to find the ones who have unlocked and loc
2024-03-14 11:03:44
510
原创 PAT甲级(Advanced Level) Practice 1005 Spell It Right
Given a non-negative integer N, your task is to compute the sum of all the digits of N, and output every digit of the sum in English.Input Specification:Each input file contains one test case. Each case occupies one line which contains an N (≤).Output Spec
2024-03-14 10:56:44
536
原创 PAT甲级(Advanced Level) Practice 1004 Counting Leaves
10 1in a line.家族等级通常由一棵血统树来呈现。您的任务是统计那些没有子女的家庭成员。每个输入文件包含一个测试用例。每个案例以一行开始,其中包含 0
2024-03-14 10:46:35
976
原创 PAT甲级(Advanced Level) Practice 1003 Emergency
每个输入文件包含一个测试用例。每个测试用例的第一行包含 4 个正整数: N (≤ 500) - 城市数量(城市编号从 0 到 N-1),M - 道路数量,C1和C2 - 分别是您当前所在的城市和必须拯救的城市。接着是 M 行,每行描述一条道路,包含三个整数 C1, C2 和 L,它们分别是由一条道路连接的一对城市和该道路的长度。地图上标明了每个城市的救援队数量以及任何一对城市之间每条道路的长度。当其他城市向您发出紧急求救信号时,您的任务是带领您的队员以最快的速度赶赴现场,同时在途中召集尽可能多的救援人员。
2024-03-13 21:09:35
1032
原创 PAT甲级(Advanced Level) Practice 1001 A+B Format
≤ a, b ≤计算 a+b 并以标准格式输出总和,即数字必须以三个为一组用逗号分隔(除非数字少于四位)。输入规范:每个输入文件包含一个测试用例。每个案例包含一对整数 a 和 b,其中≤ a, b ≤, 数字之间用空格隔开。输出规范:对于每个测试用例,应在一行中输出 a 和 b 的总和,和必须以标准格式书写。
2024-03-13 19:52:28
474
空空如也
空空如也
TA创建的收藏夹 TA关注的收藏夹
TA关注的人
RSS订阅