-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathindex.html
4125 lines (3435 loc) · 166 KB
/
index.html
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
179
180
181
182
183
184
185
186
187
188
189
190
191
192
193
194
195
196
197
198
199
200
201
202
203
204
205
206
207
208
209
210
211
212
213
214
215
216
217
218
219
220
221
222
223
224
225
226
227
228
229
230
231
232
233
234
235
236
237
238
239
240
241
242
243
244
245
246
247
248
249
250
251
252
253
254
255
256
257
258
259
260
261
262
263
264
265
266
267
268
269
270
271
272
273
274
275
276
277
278
279
280
281
282
283
284
285
286
287
288
289
290
291
292
293
294
295
296
297
298
299
300
301
302
303
304
305
306
307
308
309
310
311
312
313
314
315
316
317
318
319
320
321
322
323
324
325
326
327
328
329
330
331
332
333
334
335
336
337
338
339
340
341
342
343
344
345
346
347
348
349
350
351
352
353
354
355
356
357
358
359
360
361
362
363
364
365
366
367
368
369
370
371
372
373
374
375
376
377
378
379
380
381
382
383
384
385
386
387
388
389
390
391
392
393
394
395
396
397
398
399
400
401
402
403
404
405
406
407
408
409
410
411
412
413
414
415
416
417
418
419
420
421
422
423
424
425
426
427
428
429
430
431
432
433
434
435
436
437
438
439
440
441
442
443
444
445
446
447
448
449
450
451
452
453
454
455
456
457
458
459
460
461
462
463
464
465
466
467
468
469
470
471
472
473
474
475
476
477
478
479
480
481
482
483
484
485
486
487
488
489
490
491
492
493
494
495
496
497
498
499
500
501
502
503
504
505
506
507
508
509
510
511
512
513
514
515
516
517
518
519
520
521
522
523
524
525
526
527
528
529
530
531
532
533
534
535
536
537
538
539
540
541
542
543
544
545
546
547
548
549
550
551
552
553
554
555
556
557
558
559
560
561
562
563
564
565
566
567
568
569
570
571
572
573
574
575
576
577
578
579
580
581
582
583
584
585
586
587
588
589
590
591
592
593
594
595
596
597
598
599
600
601
602
603
604
605
606
607
608
609
610
611
612
613
614
615
616
617
618
619
620
621
622
623
624
625
626
627
628
629
630
631
632
633
634
635
636
637
638
639
640
641
642
643
644
645
646
647
648
649
650
651
652
653
654
655
656
657
658
659
660
661
662
663
664
665
666
667
668
669
670
671
672
673
674
675
676
677
678
679
680
681
682
683
684
685
686
687
688
689
690
691
692
693
694
695
696
697
698
699
700
701
702
703
704
705
706
707
708
709
710
711
712
713
714
715
716
717
718
719
720
721
722
723
724
725
726
727
728
729
730
731
732
733
734
735
736
737
738
739
740
741
742
743
744
745
746
747
748
749
750
751
752
753
754
755
756
757
758
759
760
761
762
763
764
765
766
767
768
769
770
771
772
773
774
775
776
777
778
779
780
781
782
783
784
785
786
787
788
789
790
791
792
793
794
795
796
797
798
799
800
801
802
803
804
805
806
807
808
809
810
811
812
813
814
815
816
817
818
819
820
821
822
823
824
825
826
827
828
829
830
831
832
833
834
835
836
837
838
839
840
841
842
843
844
845
846
847
848
849
850
851
852
853
854
855
856
857
858
859
860
861
862
863
864
865
866
867
868
869
870
871
872
873
874
875
876
877
878
879
880
881
882
883
884
885
886
887
888
889
890
891
892
893
894
895
896
897
898
899
900
901
902
903
904
905
906
907
908
909
910
911
912
913
914
915
916
917
918
919
920
921
922
923
924
925
926
927
928
929
930
931
932
933
934
935
936
937
938
939
940
941
942
943
944
945
946
947
948
949
950
951
952
953
954
955
956
957
958
959
960
961
962
963
964
965
966
967
968
969
970
971
972
973
974
975
976
977
978
979
980
981
982
983
984
985
986
987
988
989
990
991
992
993
994
995
996
997
998
999
1000
<!DOCTYPE html>
<html>
<head>
<meta charset="UTF-8" />
<meta name="viewport" content="width=device-width, initial-scale=1.0, user-scalable=no">
<meta name="keywords" content="Gridea静态个人博客">
<meta name="description" content="混沌猫猫の个人站点">
<meta name="theme-color" content="#000">
<title>永不止息</title>
<link rel="shortcut icon" href="/favicon.ico?v=1621934546418">
<link rel="stylesheet" href="/media/css/pisces.css">
<link rel="stylesheet" href="/media/fonts/font-awesome.css">
<link
href="//fonts.googleapis.com/css?family=Monda:300,300italic,400,400italic,700,700italic|Roboto Slab:300,300italic,400,400italic,700,700italic|Rosario:300,300italic,400,400italic,700,700italic|PT Mono:300,300italic,400,400italic,700,700italic&subset=latin,latin-ext"
rel="stylesheet" type="text/css">
<link href="/media/hljs/styles/default.css"
rel="stylesheet">
<link rel="stylesheet" href="/styles/main.css">
<script src="/media/hljs/highlight.js"></script>
<script src="https://cdn.jsdelivr.net/npm/[email protected]/velocity.min.js"></script>
<script src="https://cdn.jsdelivr.net/npm/[email protected]/velocity.ui.min.js"></script>
<link rel="stylesheet" href="https://cdn.jsdelivr.net/npm/[email protected]/dist/katex.min.css"
integrity="sha384-zB1R0rpPzHqg7Kpt0Aljp8JPLqbXI3bhnPWROx27a9N0Ll6ZP/+DiW/UqRcLbRjq" crossorigin="anonymous">
<script defer src="https://cdn.jsdelivr.net/npm/[email protected]/dist/katex.min.js"
integrity="sha384-y23I5Q6l+B6vatafAwxRu/0oK/79VlbSz7Q9aiSZUvyWYIYsd+qj+o24G5ZU2zJz" crossorigin="anonymous"></script>
<script defer src="https://cdn.jsdelivr.net/npm/[email protected]/dist/contrib/auto-render.min.js"
integrity="sha384-kWPLUVMOks5AQFrykwIup5lo0m3iMkkHrD0uJ4H5cjeGihAutqP0yW0J6dpFiVkI" crossorigin="anonymous"
onload="renderMathInElement(document.body);"></script>
</head>
<body>
<div class="head-top-line"></div>
<div class="header-box">
<div class="pisces">
<header class="header ">
<div class="blog-header box-shadow-wrapper bg-color " id="header">
<div class="nav-toggle" id="nav_toggle">
<div class="toggle-box">
<div class="line line-top"></div>
<div class="line line-center"></div>
<div class="line line-bottom"></div>
</div>
</div>
<div class="site-meta">
<div class="site-title">
<a href="/" class="brand">
<span>永不止息</span>
</a>
</div>
<p class="subtitle">奥洛斯特小镇</p>
</div>
<nav class="site-nav" id="site_nav">
<ul id="nav_ul">
<li class="nav-item nav-item-active">
<a href="/" target="_self">
<i class="fa fa-home"></i> 首页
</a>
</li>
<li class="nav-item ">
<a href="/archives/" target="_self">
<i class="fa fa-archive"></i> 归档
</a>
</li>
<li class="nav-item ">
<a href="/tags/" target="_self">
<i class="fa fa-tags"></i> 标签
</a>
</li>
<li class="nav-item ">
<a href="https://liu821218213.github.io/post/guan-yu-onandon/" target="_self">
<i class="fa fa-globe"></i> 关于
</a>
</li>
<li class="nav-item ">
<a href="/friends/" target="_self">
<i class="fa fa-address-book"></i> 友情链接
</a>
</li>
<li id="fa_search" class="nav-item">
<a href="javascript:void(0);">
<i class="fa fa-search"></i> <span class="language" data-lan="search">搜索</span>
</a>
</li>
</ul>
</nav>
</div>
</header>
</div>
<script type="text/javascript">
let showNav = true;
let navToggle = document.querySelector('#nav_toggle'),
siteNav = document.querySelector('#site_nav');
function navClick() {
let sideBar = document.querySelector('.sidebar');
let navUl = document.querySelector('#nav_ul');
navToggle.classList.toggle('nav-toggle-active');
siteNav.classList.toggle('nav-menu-active');
if (siteNav.classList.contains('nav-menu-active')) {
siteNav.style = "height: " + (navUl.children.length * 42) +"px !important";
} else {
siteNav.style = "";
}
}
navToggle.addEventListener('click',navClick);
</script>
</div>
<div class="main-continer">
<div
class="section-layout pisces ">
<div class="section-layout-wrapper">
<div id="sidebarMeta" class="sidebar">
<div class="sidebar-wrapper box-shadow-wrapper bg-color">
<div class="sidebar-item">
<img class="site-author-image right-motion" src="/images/avatar.png"/>
<p class="site-author-name">Orust</p>
<div class="site-description right-motion">
<p id="binft">Chang、Tiao、Rap</p>
</div>
</div>
<div class="sidebar-item side-item-stat right-motion">
<div class="sidebar-item-box">
<a href="/archives/">
<span class="site-item-stat-count">12</span>
<span class="site-item-stat-name language" data-lan="article">文章</span>
</a>
</div>
<div class="sidebar-item-box">
<a href="">
<span class="site-item-stat-count">8</span>
<span class="site-item-stat-name language" data-lan="category">分类</span>
</a>
</div>
<div class="sidebar-item-box">
<a href="/tags/">
<span class="site-item-stat-count">8</span>
<span class="site-item-stat-name language" data-lan="tag">标签</span>
</a>
</div>
</div>
<div class="sidebar-item">
<span class="site-item-rss">
<i class="fa fa-rss"></i>
<a href="https://liu821218213.github.io/atom.xml" target="_blank">RSS</a>
</span>
</div>
<div style="width: 100%; position: relative;">
<canvas id="canvasDiyBlock" style="width:100%;">当前浏览器不支持canvas,请更换浏览器后再试</canvas>
<script src="/media/js/magic/clock.js"></script>
</div>
</div>
</div>
<script>
let sidebarMeta = document.querySelector('#sidebarMeta');
let scheme = 'pisces';
let sidebarWrapper = document.querySelector('.sidebar-wrapper');
if (sidebarMeta && (scheme === 'pisces' || scheme === 'gemini')) {
document.addEventListener('scroll', function(e) {
if (document.scrollingElement.scrollTop > parseInt(sidebarMeta.style.marginTop) + 10) {
sidebarWrapper.classList.add('home-sidebar-fixed')
} else {
sidebarWrapper.classList.remove('home-sidebar-fixed')
}
});
}
</script>
<div class="section-box pisces">
<section class="section bg-color posts-expand slide-down-in">
<article class="post-list-box post box-shadow-wrapper">
<div class="article-wrapper bg-color">
<section class="post-header">
<h1 class="post-title">
<a class="post-title-link" href="https://liu821218213.github.io/post/lru-huan-cun-ji-zhi/">
LRU缓存机制
</a>
</h1>
<div class="post-meta">
<span class="meta-item pc-show">
<i class="fa fa-calendar-o"></i>
<span class="language" data-lan="publish">发布于</span>
<span class="publish-time" data-t="2021-05-25 17:19:43">2021-05-25</span>
<span class="post-meta-divider pc-show">|</span>
</span>
<span class="meta-item">
<i class="fa fa-folder-o"></i>
<span class="pc-show language" data-lan="category-in">分类于</span>
<a href="https://liu821218213.github.io/tag/YTzKvL6lP/">
<span>LRU</span>
</a>
</span>
<span class="post-meta-divider">|</span>
<span class="meta-item">
<i class="fa fa-clock-o"></i>
<span>13<span class="language" data-lan="minute">分钟</span></span>
</span>
<span class="meta-item">
<span class="post-meta-divider">|</span>
<i class="fa fa-file-word-o"></i>
<span>2305<span class="pc-show language" data-lan="words">字数</span></span>
</span>
</div>
</section>
<div class="post-body">
<h2 id="lru缓存机制">LRU缓存机制</h2>
<h3 id="前言">前言</h3>
<p>LRU(Least Recently Used)即最近最少使用、最近最久未使用,是一种缓存解决方案。</p>
<p>缓存思想在计算机科学中应用广泛,其核心是以空间换时间,实现方式主要采用特定的数据结构,在计算机存储层次结构中,低一层的存储器都可以看做是高一层的缓存。比如Cache是内存的缓存,内存是硬盘的缓存,硬盘是网络的缓存等等。</p>
<p>第一次接触到LRU是在操作系统的课程上,在提到OS页面调度算法的时候提到的LRU页面置换算法,页面置换是基于时间和空间局部性原理的基础上,而缓存类似于LRU这样的缓存技术在这样的场景下得到应用。</p>
<p>LRU在数据库缓存中也有广泛应用,例如Redis缓存淘汰策略。在使用next.js的时候,访问页面时,为了加快访问速度也会用到。</p>
<p>LRU:如果一个数据最近没有被访问到,那么它将来被访问的几率也很小,也就是说当限定的内存空间已没有其他空间可用时,应该把最久没有访问到的数据去除掉。</p>
<figure data-type="image" tabindex="1"><img src="https://raw.githubusercontent.com/Liu821218213/Typora-PicGo/master/img/20210525165748.png" alt="img" loading="lazy"></figure>
<p>LRU为了实现时间复杂度O(1),采用HashMap+双向链表的数据结构,实get和put操作,如下图所示。</p>
<figure data-type="image" tabindex="2"><img src="https://raw.githubusercontent.com/Liu821218213/Typora-PicGo/master/img/20210525170310.png" alt="LRU数据结构" loading="lazy"></figure>
<p>Java中可以采用LinkedHashMap源实现LRU,Python中可以调用OrderedDict()实现。</p>
<h3 id="例题-leetcode146-lru-缓存机制">例题 <a href="https://leetcode-cn.com/problems/lru-cache/">LeetCode146. LRU 缓存机制</a></h3>
<h3 id="java实现">Java实现</h3>
<p>下面用是用Java实现的几种方式,分别是</p>
<h4 id="调用java的linkedhashmap实现lru">调用Java的LinkedHashMap实现LRU</h4>
<pre><code class="language-java">package LRU;
import java.util.*;
/**
* @author Orust
* @create 2021/5/24 16:07
*/
// 146. LRU 缓存机制: https://leetcode-cn.com/problems/lru-cache/
// LinkedHashMap源码中写道: This kind of map is well-suited to building LRU caches.
// put和get的时间复杂度均为O(1)
// 空间复杂度为O(capacity) capacity为LRU缓存大小
// 广泛应用与OS内存页面调度,Redis缓存淘汰策略
// 样例输入
// ["LRUCache_4","put","put","put","get","put","put","get","put","put","get","put","get","get","get","put","put","get","put","get"]
// [[10],[7,28],[7,1],[8,15],[6],[10,27],[8,10],[8],[6,29],[1,9],[6],[10,7],[1],[2],[13],[8,30],[1,5],[1],[13,2],[12]]
// 预期结果
// [null,null,null,null,-1,null,null,10,null,null,29,null,9,-1,-1,null,null,5,null,-1]
// 调用Java的LinkedHashMap实现LRU
public class LRUCache {
int capacity;
LinkedHashMap<Integer, Integer> cache;
public LRUCache(int capacity) {
this.capacity = capacity;
cache = new LinkedHashMap<>();
}
public int get(int key) {
if (cache.containsKey(key)) {
int num = cache.remove(key);
cache.put(key, num);
return num;
} else return -1; // 未找到当前元素
}
public void put(int key, int value) {
if (cache.containsKey(key)) {
cache.remove(key);
} else if (cache.size() == capacity) {
// cache.remove(cache.entrySet().iterator().next().getKey());
cache.remove(cache.keySet().iterator().next());
}
cache.put(key, value);
}
public static void main(String[] args) {
LRUCache obj = new LRUCache(10);
obj.put(7, 28);
obj.put(7, 1);
obj.put(8, 15);
System.out.println(obj.get(6));
obj.put(10, 27);
obj.put(8, 10);
System.out.println(obj.get(8));
obj.put(6, 29);
obj.put(1, 9);
System.out.println(obj.get(6));
obj.put(10, 7);
System.out.println(obj.get(1));
System.out.println(obj.get(2));
System.out.println(obj.get(13));
obj.put(8, 30);
obj.put(1, 5);
System.out.println(obj.get(1));
obj.put(13, 2);
System.out.println(obj.get(12));
}
}
</code></pre>
<h4 id="hashmap-定义双向链表-实现lru">HashMap + 定义双向链表 实现LRU</h4>
<pre><code class="language-java">package LRU;
import java.util.*;
/**
* @author Orust
* @create 2021/5/24 16:18
*/
// HashMap + 定义双向链表 实现LRU
public class LRUCache_2 {
int capacity;
HashMap<Integer, Node> map;
Node head;
Node tail;
private static class Node {
int key;
int value;
Node prev;
Node next;
public Node(int key, int value) {
this.key = key;
this.value = value;
}
}
public LRUCache_2(int capacity) {
this.capacity = capacity;
map = new HashMap<>();
}
public int get(int key) {
if (map.containsKey(key)) {
Node node = map.get(key);
moveToHead(node);
return node.value;
} else return -1;
}
public void put(int key, int value) {
if (map.containsKey(key)) {
Node node = map.get(key);
node.value = value;
map.put(key, node);
moveToHead(node);
} else {
if (map.size() == capacity)
map.remove(popTail());
Node node = new Node(key, value);
map.put(key, node);
addToHead(node);
}
}
private void addToHead(Node node) {
if (tail == null) { // 当前链表为空
head = node;
tail = node;
} else {
head.prev = node;
node.next = head;
node.prev = null;
head = node;
}
}
private void moveToHead(Node node) {
if (node == head) return; // 判断是否是头尾节点并删除节点
node.prev.next = node.next;
if (node == tail) tail = tail.prev;
else node.next.prev = node.prev;
addToHead(node);
}
private int popTail() {
if (tail == null) throw new NullPointerException("NullPointerException!");
int key = tail.key;
if (tail == head) {
head = null;
tail = null;
} else {
tail = tail.prev;
tail.next = null;
}
return key;
}
public static void main(String[] args) {
LRUCache_2 obj = new LRUCache_2(10);
obj.put(7, 28);
obj.put(7, 1);
obj.put(8, 15);
System.out.println(obj.get(6));
obj.put(10, 27);
obj.put(8, 10);
System.out.println(obj.get(8));
obj.put(6, 29);
obj.put(1, 9);
System.out.println(obj.get(6));
obj.put(10, 7);
System.out.println(obj.get(1));
System.out.println(obj.get(2));
System.out.println(obj.get(13));
obj.put(8, 30);
obj.put(1, 5);
System.out.println(obj.get(1));
obj.put(13, 2);
System.out.println(obj.get(12));
}
}
</code></pre>
<h4 id="hashmap-定义静态内部类-mylinkedlist-泛型-实现lru">HashMap + 定义静态内部类 MyLinkedList + 泛型 实现LRU</h4>
<pre><code class="language-java">package LRU;
import java.util.*;
/**
* @author Orust
* @create 2021/5/24 17:03
*/
// HashMap + 定义静态内部类MyLinkedList + 泛型 实现LRU
public class LRUCache_3<K, V> {
int capacity;
Map<K, Node<K, V>> map = new HashMap<>();
MyLinkedList<K, V> cache = new MyLinkedList<>();
public LRUCache_3(int capacity) {
this.capacity = capacity;
}
public V get(K key) {
if (map.containsKey(key)) {
Node<K, V> node = map.get(key);
cache.moveToHead(node);
return node.value;
} else return null;
}
public void put(K key, V value) {
if (map.containsKey(key)) {
Node<K, V> node = map.get(key);
node.value = value;
map.put(key, node);
cache.moveToHead(node);
} else {
if (map.size() == capacity)
map.remove(cache.popTail());
Node<K, V> node = new Node<>(key, value);
map.put(key, node);
cache.addToHead(node);
}
}
private static class Node<K, V> {
K key;
V value;
Node<K, V> prev;
Node<K, V> next;
Node(K key, V value) {
this.key = key;
this.value = value;
}
}
private static class MyLinkedList<K, V> {
Node<K, V> head; // head是最近使用的数据
Node<K, V> tail;
private void addToHead(Node<K, V> node) {
if (tail == null) { // 当前链表为空
head = node;
tail = node;
} else {
head.prev = node;
node.next = head;
node.prev = null;
head = node;
}
}
private void moveToHead(Node<K, V> node) {
if (node == head) return; // 判断是否是头尾节点并删除节点
node.prev.next = node.next;
if (node == tail) tail = tail.prev;
else node.next.prev = node.prev;
addToHead(node);
}
private K popTail() {
if (tail == null) throw new NullPointerException("NullPointerException!");
K key = tail.key;
if (tail == head) {
head = null;
tail = null;
} else {
tail = tail.prev;
tail.next = null;
}
return key;
}
}
public static void main(String[] args) {
LRUCache_3<String, Integer> obj = new LRUCache_3<>(10);
obj.put("7", 28);
obj.put("7", 1);
obj.put("8", 15);
System.out.println(obj.get("6"));
obj.put("10", 27);
obj.put("8", 10);
System.out.println(obj.get("8"));
obj.put("6", 29);
obj.put("1", 9);
System.out.println(obj.get("6"));
obj.put("10", 7);
System.out.println(obj.get("1"));
System.out.println(obj.get("2"));
System.out.println(obj.get("13"));
obj.put("8", 30);
obj.put("1", 5);
System.out.println(obj.get("1"));
obj.put("13", 2);
System.out.println(obj.get("12"));
}
}
</code></pre>
<h4 id="在tomcat6x版本中被使用的lru实现方式">在tomcat6.x版本中被使用的LRU实现方式</h4>
<pre><code class="language-java">package LRU;
import java.util.*;
/**
* @author Orust
* @create 2021/5/25 10:53
*/
// 文章链接 https://www.iteye.com/blog/flychao88-1977653
// 在tomcat6.x版本中被使用的LRU实现方式
public class LRUCache_4 {
</code></pre>
<div class="post-button text-center">
<a class="btn language" data-lan="read-more" href="https://liu821218213.github.io/post/lru-huan-cun-ji-zhi/" rel="contents">
阅读全文 »
</a>
</div>
</div>
<footer class="post-footer">
<div class="post-eof"></div>
</footer>
</div>
</article>
<article class="post-list-box post box-shadow-wrapper">
<div class="article-wrapper bg-color">
<section class="post-header">
<h1 class="post-title">
<a class="post-title-link" href="https://liu821218213.github.io/post/python3lambda-biao-da-shi-zi-ding-yi-pai-xu/">
Python3lambda表达式、自定义排序
</a>
</h1>
<div class="post-meta">
<span class="meta-item pc-show">
<i class="fa fa-calendar-o"></i>
<span class="language" data-lan="publish">发布于</span>
<span class="publish-time" data-t="2020-11-17 12:14:33">2020-11-17</span>
<span class="post-meta-divider pc-show">|</span>
</span>
<span class="meta-item">
<i class="fa fa-clock-o"></i>
<span>2<span class="language" data-lan="minute">分钟</span></span>
</span>
<span class="meta-item">
<span class="post-meta-divider">|</span>
<i class="fa fa-file-word-o"></i>
<span>302<span class="pc-show language" data-lan="words">字数</span></span>
</span>
</div>
</section>
<div class="post-body">
<!-- 没有手动摘要切开启了自动摘要,则根据配置筛除摘要内容 -->
<p><p><strong><a href="https://leetcode-cn.com/problems/matrix-cells-in-distance-order/">1030. 距离顺序排列矩阵单元格</a></strong></p>
<h3 id="解题思路">解题思路</h3>
<p>sorted的lambda表达式排序</p>
<p>
<div class="post-button text-center">
<a class="btn language" data-lan="read-more" href="https://liu821218213.github.io/post/python3lambda-biao-da-shi-zi-ding-yi-pai-xu/" rel="contents">
阅读全文 »
</a>
</div>
</div>
<footer class="post-footer">
<div class="post-eof"></div>
</footer>
</div>
</article>
<article class="post-list-box post box-shadow-wrapper">
<div class="article-wrapper bg-color">
<section class="post-header">
<h1 class="post-title">
<a class="post-title-link" href="https://liu821218213.github.io/post/mo-hu-ju-lei-yu-wrsn/">
模糊聚类与WRSN
</a>
</h1>
<div class="post-meta">
<span class="meta-item pc-show">
<i class="fa fa-calendar-o"></i>
<span class="language" data-lan="publish">发布于</span>
<span class="publish-time" data-t="2020-10-13 11:25:08">2020-10-13</span>
<span class="post-meta-divider pc-show">|</span>
</span>
<span class="meta-item">
<i class="fa fa-folder-o"></i>
<span class="pc-show language" data-lan="category-in">分类于</span>
<a href="https://liu821218213.github.io/tag/8xhB6KLWs/">
<span>模糊聚类</span>
</a>
</span>
<span class="post-meta-divider">|</span>
<span class="meta-item">
<i class="fa fa-clock-o"></i>
<span>10<span class="language" data-lan="minute">分钟</span></span>
</span>
<span class="meta-item">
<span class="post-meta-divider">|</span>
<i class="fa fa-file-word-o"></i>
<span>2599<span class="pc-show language" data-lan="words">字数</span></span>
</span>
</div>
</section>
<div class="post-body">
<!-- 没有手动摘要切开启了自动摘要,则根据配置筛除摘要内容 -->
<p><h1 id="模糊聚类与wrsn">模糊聚类与WRSN</h1>
<h2 id="模糊关系">模糊关系</h2>
<p> 现实世界中,事物之间存在着这样或那样的关系.一些是界限非常明确的关系,如“父子关系”、“大小关系”等等,可以简单地用“是”与“否”或者“1”与“0”来刻画.而更多的则是界限不明显的关系,如“朋友关系”、“相近关系”、“相像关系”等.对于这类关系再用简单的“是”与“否”或者“1”与“0”来刻画显然是不合适的,必须用模糊集理论来进行描述,这就是模糊关系.<br>
<p>
<div class="post-button text-center">
<a class="btn language" data-lan="read-more" href="https://liu821218213.github.io/post/mo-hu-ju-lei-yu-wrsn/" rel="contents">
阅读全文 »
</a>
</div>
</div>
<footer class="post-footer">
<div class="post-eof"></div>
</footer>
</div>
</article>
<article class="post-list-box post box-shadow-wrapper">
<div class="article-wrapper bg-color">
<section class="post-header">
<h1 class="post-title">
<a class="post-title-link" href="https://liu821218213.github.io/post/er-cha-shu-bian-li-xi-lie-zong-jie/">
二叉树遍历系列总结
</a>
</h1>
<div class="post-meta">
<span class="meta-item pc-show">
<i class="fa fa-calendar-o"></i>
<span class="language" data-lan="publish">发布于</span>
<span class="publish-time" data-t="2020-10-12 19:29:23">2020-10-12</span>
<span class="post-meta-divider pc-show">|</span>
</span>
<span class="meta-item">
<i class="fa fa-folder-o"></i>
<span class="pc-show language" data-lan="category-in">分类于</span>
<a href="https://liu821218213.github.io/tag/HB_X97gz-/">
<span>Leetcode</span>
</a>
</span>
<span class="post-meta-divider">|</span>
<span class="meta-item">
<i class="fa fa-clock-o"></i>
<span>9<span class="language" data-lan="minute">分钟</span></span>
</span>
<span class="meta-item">
<span class="post-meta-divider">|</span>
<i class="fa fa-file-word-o"></i>
<span>1942<span class="pc-show language" data-lan="words">字数</span></span>
</span>
</div>
</section>
<div class="post-body">
<!-- 没有手动摘要切开启了自动摘要,则根据配置筛除摘要内容 -->
<p><p>这里分别给出了三种二叉树的遍历方法与N叉树的前序遍历,及其时空复杂度</p>
<p>1:递归:直接递归版本、针对不同题目通用递归版本(包括前序、中序、后序)</p>
<p>2:迭代:最常用版本(常用主要包括前序和层序,即【DFS和BFS】)、【前中后】序遍历通用版本(一个栈的空间)、【前中后层】序通用版本(双倍栈(队列)的空间)</p>
<p>
<div class="post-button text-center">
<a class="btn language" data-lan="read-more" href="https://liu821218213.github.io/post/er-cha-shu-bian-li-xi-lie-zong-jie/" rel="contents">
阅读全文 »
</a>
</div>
</div>
<footer class="post-footer">
<div class="post-eof"></div>
</footer>
</div>
</article>
<article class="post-list-box post box-shadow-wrapper">
<div class="article-wrapper bg-color">
<section class="post-header">
<h1 class="post-title">
<a class="post-title-link" href="https://liu821218213.github.io/post/bing-cha-ji-de-xue-xi-yu-zong-jie/">
并查集的学习与总结
</a>
</h1>
<div class="post-meta">
<span class="meta-item pc-show">
<i class="fa fa-calendar-o"></i>
<span class="language" data-lan="publish">发布于</span>
<span class="publish-time" data-t="2020-06-10 18:39:09">2020-06-10</span>
<span class="post-meta-divider pc-show">|</span>
</span>
<span class="meta-item">
<i class="fa fa-folder-o"></i>
<span class="pc-show language" data-lan="category-in">分类于</span>
<a href="https://liu821218213.github.io/tag/Y04Jy1l6q/">
<span>并查集</span>
</a>
</span>
<span class="post-meta-divider">|</span>
<span class="meta-item">
<i class="fa fa-clock-o"></i>
<span>7<span class="language" data-lan="minute">分钟</span></span>
</span>
<span class="meta-item">
<span class="post-meta-divider">|</span>
<i class="fa fa-file-word-o"></i>
<span>1725<span class="pc-show language" data-lan="words">字数</span></span>
</span>
</div>
</section>
<div class="post-body">
<!-- 没有手动摘要切开启了自动摘要,则根据配置筛除摘要内容 -->
<p><h3 id="前言">前言</h3>
<p>前两天在刷LeetCode每日一题的时候连续遇到了两天有并查集标签的题目,从来没有学过这个算法的我只能硬着头皮去看题,看评论区和题解区大家用并查集都很容易的解决了题目,群里也在讨论一些类似于并查集的优化呀什么的,而我都不知道这是个什么。于是下定决心要学一下这个“神秘的并查集”。</p>
<h3 id="查找资料">查找资料</h3>
<p>
<div class="post-button text-center">
<a class="btn language" data-lan="read-more" href="https://liu821218213.github.io/post/bing-cha-ji-de-xue-xi-yu-zong-jie/" rel="contents">
阅读全文 »
</a>
</div>
</div>
<footer class="post-footer">
<div class="post-eof"></div>
</footer>
</div>
</article>
<article class="post-list-box post box-shadow-wrapper">
<div class="article-wrapper bg-color">
<section class="post-header">
<h1 class="post-title">
<a class="post-title-link" href="https://liu821218213.github.io/post/1431-yong-you-zui-duo-tang-guo-de-hai-zi/">
Leetcode-1431.拥有最多糖果的孩子
</a>
</h1>
<div class="post-meta">
<span class="meta-item pc-show">
<i class="fa fa-calendar-o"></i>
<span class="language" data-lan="publish">发布于</span>