GithubHelp home page GithubHelp logo

baizg / data-structure-and-algorithm-notes-chinese- Goto Github PK

View Code? Open in Web Editor NEW

This project forked from littlebearsama/data-structure-and-algorithm-notes-chinese-

0.0 0.0 0.0 197 KB

数据结构与算法笔记

data-structure-and-algorithm-notes-chinese-'s Introduction

Data-structure-and-algorithm-notes-Chinese-


学习路线


资源

  • 0.剑指offer源码

《剑指Offer》第二版源代码

  • 1.数据结构和算法

数据结构和算法动态可视化

数据结构和算法目录表

十大经典排序算法(动图加代码)

浙大视频

1、算法分析与分析基础:这本比较简单,推荐新手看。

2、数据结构与算法分析—-C语言描述:代码用C写的,推荐看。

3、挑战程序设计竞赛(第二版):也是很不错的一本书,推荐看。


数据结构

  • 数组和字符串:它们用连续的内存分别存储数字和字符。
  • 链表和树是面试中出现频率最高的数据结构。

由于操作链表和树需要操作大连的指针,一定要留意代码的鲁棒性,防止崩溃。

  • 栈是一个紧密与递归相关的数据结构
  • 队列与广度优先遍历算法紧密相关。

1.二叉树

二叉排序树是一种比较有用的折衷方案。

  • 数组的搜索比较方便,可以直接用下标,但删除或者插入某些元素就比较麻烦。
  • 链表与之相反,删除和插入元素很快,但查找很慢。
  • 二叉排序树就既有链表的好处,也有数组的好处。在处理大批量的动态的数据是比较有用。
  • 文件系统和数据库系统一般都采用树(特别是B树)的数据结构数据,主要为排序和检索的效率。二叉树是一种最基本最典型的排序树,用于教学和研究树的特性,本身很少在实际中进行应用,因为缺点太明显了(看看教科书怎么说的)。就像冒泡排序一样,虽然因为效率问题并不实用,单不失一种教学例子的好手段。

算法

1.排序

稳定排序与不稳定排序

稳定排序

  • 冒泡排序、插入排序、归并排序、基数排序 不稳定排序
  • 选择排序、快速排序、希尔排序、堆排序

堆排序-建堆的时间复杂度 O(N)

2.Trick

时间复杂度

百度:ACM trick

  • 暴力枚举永远是第一个考虑的方法,但也有一些前提
    • 如果输入规模 < 1e4,那么可以尝试考虑 O(n^2) 的算法(两次循环暴力枚举);如果 ≥ 1e5,那么可能就需要考虑 O(nlogn) 的算法了——这不是绝对的,也可以通过剪枝等操作加速。
    • [C++] string 拼接的速度依次为:1)使用 stringstream;2)使用 append();3)使用 s += c;4)使用 s = s + c——如果有大量拼接操作,要避免使用最后一种方法。

3.敏感空间

ACM Trick点&&常用操作记录(持续更新)(敏感空间) - CSDN博客

  • long long 上界:2^63-1 = 9,223,372,036,854,775,807 ≈ 9.223372e+18

    • 阶乘:20! = 2432902008176640000 ≈ 2.432902e+18 OK,21!
    • Fibnacci 数列:fib[92] = 7540113804746346429 ≈ 7.540114e+18 OK,fib[93]
    • Catalan 数:
    • 整数划分:
  • 数组大小:如果内存限制为 2MB,那么最大可开辟的 int 数组为 2*1024*1024/4 = 524288 ≈ 50,0000,char 数组为 2*1024*1024 = 2,097,152 ≈ 200,0000

    • 实际单个数组是远开不了那么大,比如 windows 默认的栈好像只有 1MB

    • 在无法修改栈大小的情况下,可以使用 newmalloc上开辟内存

      int *pa = malloc(sizeof(int)*1024*1024);
      int *pb = new int[1024*1024];

data-structure-and-algorithm-notes-chinese-'s People

Contributors

littlebearsama avatar

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.