Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

算法设计与分析期末复习 #53

Open
QiYongchuan opened this issue Dec 29, 2023 · 6 comments
Open

算法设计与分析期末复习 #53

QiYongchuan opened this issue Dec 29, 2023 · 6 comments
Labels
notes notes

Comments

@QiYongchuan
Copy link
Owner

QiYongchuan commented Dec 29, 2023

image

image

@QiYongchuan QiYongchuan added the notes notes label Dec 29, 2023
@QiYongchuan
Copy link
Owner Author

QiYongchuan commented Dec 31, 2023

0.基础知识补充部分

ps:不是针对具体哪个考试题,直接针对做题的,仅是用来学习一些基本的概念补充

0.1 时间复杂度计算

image
image
image

image

注:区别在于常数阶的size是输入确定好的值,而线性阶是可以一直增加的。

image
image
image
image
image
image
image
image

来源:hello 算法

@QiYongchuan
Copy link
Owner Author

QiYongchuan commented Jan 1, 2024

一、分治法

涉及到的算法:二分搜索、合并排序、快速排序

例子:把作业分成一个一个的小部分,一个人做一部分?然后再整合到一块。

思想: 分(Divide),治(Conquer),合(Combine)。

(1)分解成若干个规模较小、相互独立、类型相同的子问题
(2)子问题足够小时,直接分解
(3)子问题的解,组合成原问题

最大字段和问题

1. 枚举法解决问题

2. 分治法解决方案

3. 动态规划解决方案

问题描述:
当所有整数都是负数时,记为0
当(a1,a2,a3,a4,a5,a6)=(-2,11--4,13,-5,-2)时,最大字段和

1.枚举法(蛮力、暴力、穷举)

image
image
image

穷举法就是将n中所有的字段组合找出来,比较字段的和的大小,选出最大的来。
image

枚举法的优化:可将复杂度降为n²
image

2.分治法求最大字段和
image
image

代码部分:
image

来源:算法设计与分析MOOC-青岛大学-张公敬教授

注意:这里的left和right是数组的两个端点,区分lefts和rights数组的和

3.动态规划法求最大字段和

image

image

image

【北大公开课】 算法设计与分析 屈婉玲教授 (76p)
image

老师讲义:
image

蛮力、分治与动态规划求解最大字段和问题的比较:

image
image

@QiYongchuan
Copy link
Owner Author

0/1背包问题

image

条件约束:

小于总重量

核心:
最优子结构性质分析
image
当第i个物体的重量超过背包总重量时,此时第i个装不进去,此时背包的最大价值就是第[i-1]个物体装入时的最大价值;
当第i个物体的重量不超过背包的总重量,可以装入背包时,此时可装可不装。

@QiYongchuan
Copy link
Owner Author

学习通试题及答案

@QiYongchuan
Copy link
Owner Author

QiYongchuan commented Jan 7, 2024

考试前发疯belike:

五大算法,缺一不可!!!!!!
image

@QiYongchuan
Copy link
Owner Author

QiYongchuan commented Jan 7, 2024

后续:考完了,但是资料还没有整理完的,暂时先将用到的pdf传到这里吧:

笔记.pdf
复习2+重点回顾.pdf
以及最后的模拟题:
考试题.pdf

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
notes notes
Projects
None yet
Development

No branches or pull requests

1 participant