GithubHelp home page GithubHelp logo

algorithm008-class02's People

Stargazers

 avatar  avatar  avatar  avatar

Watchers

 avatar  avatar

algorithm008-class02's Issues

算法训练营(第8期)第二周作业

要求

  1. 每周从覃超老师布置的题目中,至少完成并提交两道算法题
  2. 围绕每周重点学习的算法知识点,撰写一篇有观点和思考的技术文章或总结,切忌流水账。
  3. 每周需要 review 并点评至少 5 位同学的代码作业或学习总结

作业提交 Deadline

2020年4月26日 23:59 (以当地时间为准)
未按时提交作业,会在个人作业总分中 -2 分

本周作业概述

本周需要完成学习的视频内容:

  • 第 5 课 | 哈希表、映射、集合
  • 第 6 课 | 树、二叉树、二叉搜索树
  • 第 6 课 | 堆和二叉堆、图

其中,第 5 课的课后作业(第2节视频后)还包括:

  • 写一个关于HashMap的小总结
    说明:对于不熟悉Java语言的同学,此项作业可选做。

请大家将此部分作业,放在本周学习总结中一并提交

本周算法习题库:

简单
写一个关于 HashMap 的小总结。
说明:对于不熟悉 Java 语言的同学,此项作业可选做。
https://leetcode-cn.com/problems/valid-anagram/description/
https://leetcode-cn.com/problems/two-sum/description/
https://leetcode-cn.com/problems/n-ary-tree-preorder-traversal/description/
HeapSort :自学 https://www.geeksforgeeks.org/heap-sort/

中等
https://leetcode-cn.com/problems/group-anagrams/
https://leetcode-cn.com/problems/binary-tree-inorder-traversal/
https://leetcode-cn.com/problems/binary-tree-preorder-traversal/
https://leetcode-cn.com/problems/n-ary-tree-level-order-traversal/
https://leetcode-cn.com/problems/chou-shu-lcof/
https://leetcode-cn.com/problems/top-k-frequent-elements/

【问题Q&A】收集

Q: 这里的时间复杂度是 n 还是 n^2

func moveZeroes(nums []int)  {
    j:=0
    for i:=0; i<len(nums); i++{
        if nums[j] == 0 {
            // nums = append(nums[:j], append(nums[j+1:], nums[j])...)
            nums = append(nums[:j], nums[j+1:]...)
			nums = append(nums, 0)
            j--
        }
        j++
    }
}

A: 这里值得注意的是 nums = append(nums[:j], nums[j+1:]...) 这条语句, 它的作用不是 添加而是删除 下标为 j 的元素,在数组中,插入和删除元素的时间复杂度是 O(n), 由于外层 for 循环 的关系,这里的整体时间复杂度是 O(n^2)

Q: 检测环的时候使用快慢指针,走2步和走多步哪个效率高,怎么证明?

https://code-examples.net/zh-CN/q/4e4806

Q: 网上说链表和数组的插入性能都是o(n) ,这块是什么情况?

A: 数组的插入 O(n) 的复杂度毫无疑问,但是链表的插入为 O(n) 是有问题的,在这里,链表在某个点插入新的结点的时间复杂度是 O(1), 但是在找到这个位置的过程时间复杂度是 O(n), 注意把握概念。

算法训练营(第8期)第四周作业

要求

  1. 每周从覃超老师布置的题目中,至少完成并提交两道算法题
  2. 围绕每周重点学习的算法知识点,撰写一篇有观点和思考的技术文章或总结,切忌流水账。

作业提交 Deadline

2020年5月17日 23:59 (以当地时间为准)
未按时提交作业,会在个人作业总分中 -2 分

本周作业概述

本周需要完成学习的视频内容:

  • 第 9 课 | 深度优先搜索和广度优先搜索
  • 第10课 | 贪心算法
  • 第11课 | 二分查找

以上三课视频后,覃超老师都给出了大家可以练手的算法题。

本周算法习题库:

简单:
https://leetcode-cn.com/problems/lemonade-change/description/
https://leetcode-cn.com/problems/best-time-to-buy-and-sell-stock-ii/description/
https://leetcode-cn.com/problems/assign-cookies/description/
https://leetcode-cn.com/problems/walking-robot-simulation/description/
使用二分查找,寻找一个半有序数组 [4, 5, 6, 7, 0, 1, 2] 中间无序的地方
说明:同学们可以将自己的思路、代码写在第 4 周的学习总结中
中等:
https://leetcode-cn.com/problems/word-ladder/description/
https://leetcode-cn.com/problems/number-of-islands/
https://leetcode-cn.com/problems/minesweeper/description/
https://leetcode-cn.com/problems/jump-game/
https://leetcode-cn.com/problems/search-in-rotated-sorted-array/
https://leetcode-cn.com/problems/search-a-2d-matrix/
https://leetcode-cn.com/problems/find-minimum-in-rotated-sorted-array/
困难
https://leetcode-cn.com/problems/word-ladder-ii/description/
https://leetcode-cn.com/problems/jump-game-ii/

算法训练营(第8期)第一周作业

要求

  1. 每周从覃超老师布置的题目中,至少完成并提交两道算法题
  2. 围绕每周重点学习的算法知识点,撰写一篇有观点和思考的技术文章或总结,切忌流水账。
  3. 每周需要 review 并点评至少 5 位同学的代码作业或学习总结

作业提交 Deadline

2020年4月19日 23:59 (以当地时间为准)
未按时提交作业,会在个人作业总分 -2 分

本周作业概述

本周需要完成学习的视频内容:

  • 第 3 课 | 数组、链表、跳表
  • 第 4 课 | 栈、队列、优先队列、双端队列

以上两课视频后,覃超老师都给出了大家可以练手的算法题。

其中,第 4 课的课后作业(第2节视频后)还包括:

  • 用add first或add last这套新的API改写Deque的代码
  • 分析Queue和Priority Queue的源码

请大家将此部分作业,放在本周学习总结中一并提交

本周算法习题库:

第三课课后习题:

https://leetcode-cn.com/problems/remove-duplicates-from-sorted-array/
https://leetcode-cn.com/problems/rotate-array/
https://leetcode-cn.com/problems/merge-two-sorted-lists/
https://leetcode-cn.com/problems/merge-sorted-array/
https://leetcode-cn.com/problems/two-sum/
https://leetcode-cn.com/problems/move-zeroes/
https://leetcode-cn.com/problems/plus-one/

第四课课后习题:

https://leetcode.com/problems/design-circular-deque
https://leetcode.com/problems/trapping-rain-water/
用add first或add last这套新的API改写Deque的代码
分析Queue和Priority Queue的源码

改写代码和分析源码这两项作业,需要在你的本周学习总结中一并提交。

算法训练营(第8期)第三周作业

要求

  1. 每周从覃超老师布置的题目中,至少完成并提交两道算法题
  2. 围绕每周重点学习的算法知识点,撰写一篇有观点和思考的技术文章或总结,切忌流水账。

作业提交 Deadline

2020年5月10日 23:59 (以当地时间为准)
未按时提交作业,会在个人作业总分中 -2 分

本周作业概述

本周需要完成学习的视频内容:

  • 第 7 课 | 泛型递归、树的递归
  • 第 8 课 | 分治、回溯

以上两课视频后,覃超老师都给出了大家可以练手的算法题。

本周算法习题库:

第七课课后习题:

https://leetcode-cn.com/problems/lowest-common-ancestor-of-a-binary-tree/
https://leetcode-cn.com/problems/construct-binary-tree-from-preorder-and-inorder-traversal
https://leetcode-cn.com/problems/combinations/
https://leetcode-cn.com/problems/permutations/
https://leetcode-cn.com/problems/permutations-ii/

第八课课后习题:

https://leetcode-cn.com/problems/majority-element/description/
https://leetcode-cn.com/problems/letter-combinations-of-a-phone-number/
https://leetcode-cn.com/problems/n-queens/

Week 01 作业链接合集

#学号:
#姓名:
#班级:
#小组:
#作业&总结链接:

请准确无误地复制上述格式,我们的作业通过工具抓取,格式不对无法被统计到。

查看学号请登录官网:https://u.geekbang.org/schedule 左侧头像下面就是你的学号

【问题Q&A】Week 02

时间复杂度分析

image-20200427084419819.png

​ 上述的时间复杂度是 O(n^2)

如何进行时间复杂度分析?

  • 只关注循环执行次数最多的一段代码
    • 加法法则:总复杂度等于量级最大的那段代码的复杂度(总的时间复杂度就等于量级最大的那段代码的时间复杂度)
    • 乘法法则:嵌套代码的复杂度等于嵌套内外代码复杂度的乘积

常见的时间复杂度

1. O(1)

O(1) 只是常量级时间复杂度的一种表示方法,并不是指只执行了一行代码

只要代码的执行时间不随 n 的增大而增长,这样代码的时间复杂度我们都记作 O(1)

只要算法中不存在循环语句、递归语句,即使有成千上万行的代码,其时间复杂度也是Ο(1)只要算法中不存在循环语句、递归语句,即使有成千上万行的代码,其时间复杂度也是Ο(1)

2. O(logn)、O(nlogn)

在采用大 O 标记复杂度的时候,可以忽略系数,即 O(Cf(n)) = O(f(n)), O(log2n)、O(log3n)统一表示为 O(logn)

3. O(m+n)、O(m*n)

代码的复杂度由两个数据 m 和 n 的规模来决定

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    🖖 Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. 📊📈🎉

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google ❤️ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.