![](https://img-blog.csdnimg.cn/20201014180756724.png?x-oss-process=image/resize,m_fixed,h_64,w_64)
算法
小小毛毛虫~
这个作者很懒,什么都没留下…
展开
-
C++ 多线程 生产者消费者(1)
生产者消费者问题原创 2022-05-11 16:10:01 · 427 阅读 · 0 评论 -
XGBoost tree
1. python有已经封装好的XGboost库,直接pip install就可以调用, 抄的源代码如下:from xgboost import XGBClassifierfrom numpy import loadtxtimport numpy as npfrom sklearn.model_selection import train_test_splitfrom sklearn.metrics import accuracy_scorefrom xgboost import plo..原创 2021-08-31 19:11:40 · 215 阅读 · 0 评论 -
BP神经网络(python)
import mathimport randomdef rand(a, b): return (b - a) * random.random() + adef make_matrix(m, n, fill=0.0): # 创造一个指定大小的矩阵 mat = [] for i in range(m): mat.append([fill] * n) return matdef sigmoid(x): return 1.0 / (1.0 + .原创 2021-07-07 15:09:36 · 602 阅读 · 1 评论 -
2021-03-08
单链表翻转# 单链表翻转class Node(): def __init__(self,value,next_=None): self.value=value self.next=next_def Reverse(head): if head==None or head.next==None: return head p1=head.next node=head head.next=None wh.原创 2021-03-08 14:47:24 · 73 阅读 · 0 评论 -
2021-03-08
对于旋转数组,先找到最大值点def find_max_index(A,i,j): if i>=j: return -1 mid_index = round((i+j)/2) if A[mid_index]>A[i]: if mid_index+1<=j and A[mid_index]>A[mid_index+1]: return mid_index return find_max_原创 2021-03-08 13:59:17 · 69 阅读 · 0 评论 -
快排和堆排序-python
平时拿着上班当幌子 混混沌沌混日子 出了紧急状况才临时抱佛脚有句话说的好 机会永远是留给那些时刻准备好的人感叹时光飞逝 感叹岁月催人 没办法 硬着头皮上吧 与70多岁的两位老人比起来 我还属于青少年准备吧 少年几年前 这些基本算法拿笔就能写的 现在半天蹦不出几个字母 补基本功吧记录今天的两个算法 只要理解了思想 实现起来 不算太难 --def Quick_sort(A,start, end): if start>=end: ret...原创 2020-11-10 18:43:11 · 92 阅读 · 0 评论 -
python - 八皇后 (2)
上一篇有两个问题:1)只能得到一个可能的解,不是所有的;2)虽然得到的解是正确的,但是逻辑上有个小bug,3)这次是给出了所有解,但还未做去重处理,下一篇将添加去重处理import sys,copy#Queens -- def checkPlaceOK(queens, curPlace,maxrow): if len(queens)<=0: return Tru...原创 2019-07-12 18:55:16 · 261 阅读 · 0 评论 -
八皇后问题--python代码
今天闲着无聊,正好用八皇后问题熟悉一下python的基本功。#Queens -- def checkPlaceOK(queens, curPlace,maxrow): if len(queens)<=0: return True if ( curPlace[0]>=maxrow or curPlace[1]>=maxrow): return False f...原创 2019-07-10 12:21:32 · 753 阅读 · 0 评论 -
八皇后 - 结果去重
去重后的结果,虽然显示两个,但是其实是等价的,主要就是对称性。如果继续去重,感觉可以将XY对调再去重。不再做调整了。def TwinsQuickSort(datalist): if len(datalist)<=1: return datalist pivot=datalist[0] left=[];right=[]; for i in range(len(datalis...原创 2019-07-15 17:39:32 · 442 阅读 · 1 评论