![](https://img-blog.csdnimg.cn/20201014180756930.png?x-oss-process=image/resize,m_fixed,h_64,w_64)
算法第四版
文章平均质量分 76
于老师的父亲王老爷子
这个作者很懒,什么都没留下…
展开
-
《算法》第四版algs4:union-find并查集C++实现
QuickFindUF实现(在文件"quick_find_uf"中) #pragma once #include <vector> #include <string> #include <stdexcept> #原创 2018-11-01 19:59:23 · 276 阅读 · 0 评论 -
LeetCode:200. Number of Islands
在看这篇文章前,你也许想要先看看并查集是如何实现的:https://blog.csdn.net/weixin_43462819/article/details/83626022 这一题是在复习完并查集之后的练手的题目。 题目是这样的: Given a 2d grid map of '1’s (land) and '0’s (water), count the number of islands....原创 2018-11-01 22:11:42 · 134 阅读 · 0 评论 -
LeetCode:128. Longest Consecutive Sequence
在看这篇文章前,你也许想要先看看并查集是如何实现的:https://blog.csdn.net/weixin_43462819/article/details/83626022 这一题是实现完并查集之后练手的第二题,可以先看看第一题: https://blog.csdn.net/weixin_43462819/article/details/83628052 题目是这样的: Given an u...原创 2018-11-02 10:49:30 · 107 阅读 · 0 评论 -
《算法》第四版algs4:sort排序算法C++实现
具体代码: https://github.com/Nwpuer/algs4-in-cpp/blob/master/sort.h 这一章的实现,相比于书上我做了轻微的改变,主要目的是把代码写的更加简洁易懂,更加关注算法是如何实现的,换言之,更关注算法的本质,而不是如何去设计一个C++类。 做出的改动如下: 1.没有再将每个排序算法分别写成一个类,而是将每个排序算法都写成一个函数,放在"sort.h"...原创 2018-11-12 20:14:36 · 461 阅读 · 0 评论 -
《算法》第四版algs4:字符串排序算法C++实现
1.键索引计数法 适用于小整数键的简单排序。 具有稳定性(稳定性:一个排序算法能够保留数组中相同元素的相对位置,则它是稳定的) 突破了NlogN的排序算法时间下限:因为它这里不需要比较键,只需要访问数据即可。 #include <vector> #include <string> #include <iostream> struct info { in...原创 2018-12-10 10:15:06 · 313 阅读 · 0 评论