基本数据结构算法(排序:冒泡,选择)

iOS 面试之数据结构和算法分析(快排,希尔排序,堆排序,冒泡排序,选择排序) 常见的数据结构类型 1.集合结构 线性结构 树形结构 图形结构 1.1、集合结构 说白了就是一个数学意义上的集合,就是一个圆圈中有很多个元素,元素与元素之间没有任何关系 , 这个很简单 1.2、线性结构 说白了就是一个条线上站着很多个人。 这条线不一定是直的。也可以是弯的。也可以是值的 相当于一条线被分成了好几段的样子 (发挥你的想象力)。 线性结构是一对一的关系 1.3、树形结构 说白了就... 阅读详情

bubble sort method(冒泡排序)

public class Mp_sort{

public static void main(String[] args){

int[] array={3,2,99,33,22,441,234};

Mp_sort.mp_method(array);

}

public void mp_method(int[] arr){

int len=arr.length;

for(int i=0;i<len-1;i++){

for(int j=0;j<len-i-1;i++){

if(arr[j]>arr[j+1]){

int temp=arr[j];

arr[j]=arr[j+1];

arr[j+1]=temp;

}

for(int k=0;k<arr.length;k++){

System.out.print(arr[k]+" ");

}

System.out.println("sort complete");


选择排序---select sort method

public void  selectSort(int[] arr){

for(int i=0;i<arr.length-1;i++){

int min=i;

for(int j=i+1;j<arr.length;j++){

if(arr[min]>arr[j]){

min=j;

}

if(i!=min){

int tem=arr[i];

arr[i]=arr[min];

arr[min]=tem;

}

}

}

for(int k=0;k<arr.length;k++){

System.out.print(arr[k]+" ");

}

}

public void main(String[] args){

int[] arr1=[32,44,23,53,23,112,35];

selectSort(arr1);

}


Array自带的排序算法

public void arraySort(int[] ar){

int[] ar={232,443,432,11};

Arrays.sort(ar);

for(int i:ar){

System.out.print(i);

}

}

插入排序(insert_sort)

public int[] insert_sort(int[] arr){

int temp=0;

for(int i=1;i<arr.length;i++){

temp=arr[i];

int j=i-1;

for(;j>=0&&temp<arr[j];j--){

arr[j+1]=arr[j];

}

arr[j+1]=temp;

}

}

《数据结构》02-线性结构1 两个有序链表序列的合并 题目 本题要求实现一个函数,将两个链表表示的递增整数序列合并为一个非递减的整数序列。 函数接口定义: List Merge( List L1, List L2 ); 其中List结构定义如下: typedef struct Node *PtrToNode; struct Node { ElementType Data; /* 存储结点数据 */ PtrToNode Next;... 阅读详情

相关推荐

离线安装 nvidia-docker2(nvidia-container-toolkit)

很多时候大家都有用docker使用gpu的需求,但是因为网络等原因不是那么好用,这里留了一个给ubuntu的安装包,网络好的话也提供了在线安装方式。

father_yingying的博客 1181

常用sort算法比较

  Search和Sort是最基础的算法,基础但重要!   Search的话,binary search最简单实用。   Sort,上面是常用sort对比,看图,其实也没啥可说的了。   注:1、bubble、selection和insert sort统称为简单排序,优点是程序相对简单、好写,但时间复杂度较差O(N^2);       2、稳定排序(排序时,相同元素不调换位置):bub...

ScienceRecord 1330

X猫免费小说安卓逆向分析

七猫免费小说安卓逆向分析 难度(♥♥) 文章目录七猫免费小说安卓逆向分析 难度(♥♥)1. 查壳2. 抓包分析3. sign1. Frida-rpc2. Native函数分析快3点了. 睡觉~ 白天再继续写! 1. 查壳 我这边使用的是ApkTool, 拖进去显示未加壳。 2. 抓包分析 POST https://xiaoshuo.wtzw.com/api/v1/login/index HTTP/1.1 net-env: 1 channel: qm-cbcpa056_wm is-white: 0 platf

Qiled的博客 4368

Python数据结构(六):Python 基本排序算法:冒泡 选择 插入

冒泡排序,选择排序,插入排序

Mrliu__的博客 1782

别再硬编码了!Flowable工作流动态审批人配置全解析(Spring Boot集成版)

本文深入解析Flowable工作流在Spring Boot中的动态审批人配置技术,通过角色、部门等变量实现审批流程的灵活设计。文章详细介绍了架构原理、前端配置映射、动态候选组解析及查询优化方案,帮助企业提升审批流程的适应性和维护效率。

weixin_30919571的博客 136

Palabos User Guide中文解读 | 第五章 | Palabos编程 (跳过了第四章Palabos-Java接口)

作者的话:本人在学习palabos时,发现国内中文资料甚少,恰好网上可以直接搜到palabos user guide这种英文资料,加之时间充裕,便打算开始翻译,翻了一节后发现这可能算侵权,就比较伤脑筋,突然想到自己写中文解读即可,便有了下面的博客。 Palabos User Guide Release 1.0 r1 Copyright © 2019 University of Geneva Jul...

Yulan Fang's notes. 2298

【数据结构与算法】三种基本排序算法及Python实现:选择排序、冒泡排序与插入排序

三种基本排序算法的python实现:选择排序、冒泡排序以及插入排序 附上python代码: # 三种排序算法 '''选择排序法 搜索整个列表找到最小值的项,最小项如果不是第一项那么就与第一项交换; 然后,算法到第二个位置,重复这一过程,有必要的话再与第二项交换。以此类推。 ''' def selectsort(lyst): for i in range(len(lyst)-1): ...

weixin_43885654的博客 309

BAT031:按列表名单将路径a下的文件夹批量剪切到路径b

摘要:按列表名单将路径a下的文件夹批量剪切到路径b。

qq_31762031的博客 1220

(九)数据结构之简单排序算法实现:冒泡排序、插入排序和选择排序

1、冒泡排序 /* 冒泡排序,按照由小到大顺序进行排序 */ void Bubble_Sort( ElementType A[], int N ) { int P, i; int flag = 0; /* 定义一个flag来判断带排序序列是否有序或局部有序,提高算法效率 */ for ( P=N-1; P>=0; P-- ) { flag = 0; for( i=0; i<P;

TECH_PRO的博客 1409

全局注意机制 GAM | Global Attention Mechanism: Retain Information to Enhance Channel-Spatial Interactions

全局注意机制 GAM

Coding... 2577

药物代谢仿真软件:PKSim_(6).案例研究与实践应用

通过本章的案例研究和实践应用,我们展示了如何利用PKSim软件构建药物动力学模型、进行参数估计、仿真预测和结果分析。这些方法不仅有助于优化药物代谢研究过程,还可以在药物研发中提供重要的数据支持。通过模型的构建和验证,我们可以更好地理解药物在体内的动态变化过程,为临床试验和药物治疗提供科学依据。

kkchenjj的博客 655

C语言实现冒泡排序,选择排序和插入排序

C语言实现冒泡排序,选择排序和插入排序 #include<stdio.h> /*冒泡排序*/ int BubbleSort(int *array,int num) { int i=0,j=0,n=0; for(i=0;i<num;i++) for(j=0;j<num-1;j++) if(array[j]>array[j+1]) { array[j]=array[j]+array[j+1]; array[j+1]=array[j]-array[j+1]

msdn_yyhh的博客 501

【STM32Cube_14】使用硬件I2C读写环境光强度传感器(BH1750)

本篇详细的记录了如何使用STM32CubeMX配置STM32L431RCT6的硬件I2C外设读取环境光强度传感器数据(BH1750)

Mculover666的博客(嵌入式) 7243

冒泡排序、选择排序、插入排序的js实现

数据结构中的基础排序算法包括冒泡,选择和插入排序,它们的核心思想都是对一组数据按照一定的顺序重新排列,排列时用到的主要是一组嵌套的for循环,其中外循环遍历数组的每一项,内循环则用于比较元素。以下将按照升序排列为例。 1.冒泡排序 冒泡排序时数组的数据会像气泡一样从数组的一段漂浮到另一端,因此才有了冒泡这个命名。基本步骤如下: 1.依次两两比较相邻的元素,如果第一个比第二个大,则进行交换。

pngfilver的博客 2359

RU DOS版、EFI版32bit/64bit BIOS常用工具

DOS版、EFI版的RU工具,可用来查看IO、MEM、PCI、SMBIOS等资源。亲测在EFI SHELL下可用。

深度学习工具包 DeepLearningToolbox

深度学习工具包Deprecation notice.-----This toolbox is outdated and no longer maintained.There are much better tools available for deep learning than this toolbox, e.g. [Theano](http://deeplearning.net/software/theano/), [torch](http://torch.ch/) or [tensorflow](http://www.tensorflow.org/)I would suggest you use one of the tools mentioned above rather than use this toolbox.Best, Rasmus.DeepLearnToolbox================A Matlab toolbox for Deep Learning.Deep Learning is a new subfield of machine learning that focuses on learning deep hierarchical models of data.It is inspired by the human brain's apparent deep (layered, hierarchical) architecture.A good overview of the theory of Deep Learning theory is[Learning Deep Architectures for AI](http://www.iro.umontreal.ca/~bengioy/papers/ftml_book.pdf)For a more informal introduction, see the following videos by Geoffrey Hinton and Andrew Ng.* [The Next Generation of Neural Networks](http://www.youtube.com/watch?v=AyzOUbkUf3M) (Hinton, 2007)* [Recent Developments in Deep Learning](http://www.youtube.com/watch?v=VdIURAu1-aU) (Hinton, 2010)* [Unsupervised Feature Learning and Deep Learning](http://www.youtube.com/watch?v=ZmNOAtZIgIk) (Ng, 2011)If you use this toolbox in your research please cite [Prediction as a candidate for learning deep hierarchical models of data](http://www2.imm.dtu.dk/pubdb/views/publication_details.php?id=6284)```@MASTERSTHESIS\{IMM2012-06284, author = "R. B. Palm", title = "Prediction as a candidate for learning deep hierarchical models of data", year = "2012",}```Contact: rasmusbergpalm at gmail dot comDirectories included in the toolbox-----------------------------------`NN/` - A library for Feedforward Backpropagation Neural Networks`CNN/` - A library for Convolutional Neural Networks`DBN/` - A library for Deep Belief Networks`SAE/` - A library for Stacked Auto-Encoders`CAE/` - A library for Convolutional Auto-Encoders`util/` - Utility functions used by the libraries`data/` - Data used by the examples`tests/` - unit tests to verify toolbox is workingFor references on each library check REFS.mdSetup-----1. Download.2. addpath(genpath('DeepLearnToolbox'));Example: Deep Belief Network---------------------```matlabfunction test_example_DBNload mnist_uint8;train_x = double(train_x) / 255;test_x = double(test_x) / 255;train_y = double(train_y);test_y = double(test_y);%% ex1 train a 100 hidden unit RBM and visualize its weightsrand('state',0)dbn.sizes = [100];opts.numepochs = 1;opts.batchsize = 100;opts.momentum = 0;opts.alpha = 1;dbn = dbnsetup(dbn, train_x, opts);dbn = dbntrain(dbn, train_x, opts);figure; visualize(dbn.rbm{1}.W'); % Visualize the RBM weights%% ex2 train a 100-100 hidden unit DBN and use its weights to initialize a NNrand('state',0)%train dbndbn.sizes = [100 100];opts.numepochs = 1;opts.batchsize = 100;opts.momentum = 0;opts.alpha = 1;dbn = dbnsetup(dbn, train_x, opts);dbn = dbntrain(dbn, train_x, opts);%unfold dbn to nnnn = dbnunfoldtonn(dbn, 10);nn.activation_function = 'sigm';%train nnopts.numepochs = 1;opts.batchsize = 100;nn = nntrain(nn, train_x, train_y, opts);[er, bad] = nntest(nn, test_x, test_y);assert(er < 0.10, 'Too big error');```Example: Stacked Auto-Encoders---------------------```matlabfunction test_example_SAEload mnist_uint8;train_x = double(train_x)/255;test_x = double(test_x)/255;train_y = double(train_y);test_y = double(test_y);%% ex1 train a 100 hidden unit SDAE and use it to initialize a FFNN% Setup and train a stacked denoising autoencoder (SDAE)rand('state',0)sae = saesetup([784 100]);sae.ae{1}.activation_function = 'sigm';sae.ae{1}.learningRate = 1;sae.ae{1}.inputZeroMaskedFraction = 0.5;opts.numepochs = 1;opts.batchsize = 100;sae = saetrain(sae, train_x, opts);visualize(sae.ae{1}.W{1}(:,2:end)')% Use the SDAE to initialize a FFNNnn = nnsetup([784 100 10]);nn.activation_function = 'sigm';nn.learningRate = 1;nn.W{1} = sae.ae{1}.W{1};% Train the FFNNopts.numepochs = 1;opts.batchsize = 100;nn = nntrain(nn, train_x, train_y, opts);[er, bad] = nntest(nn, test_x, test_y);assert(er < 0.16, 'Too big error');```Example: Convolutional Neural Nets---------------------```matlabfunction test_example_CNNload mnist_uint8;train_x = double(reshape(train_x',28,28,60000))/255;test_x = double(reshape(test_x',28,28,10000))/255;train_y = double(train_y');test_y = double(test_y');%% ex1 Train a 6c-2s-12c-2s Convolutional neural network %will run 1 epoch in about 200 second and get around 11% error. %With 100 epochs you'll get around 1.2% errorrand('state',0)cnn.layers = { struct('type', 'i') %input layer struct('type', 'c', 'outputmaps', 6, 'kernelsize', 5) %convolution layer struct('type', 's', 'scale', 2) %sub sampling layer struct('type', 'c', 'outputmaps', 12, 'kernelsize', 5) %convolution layer struct('type', 's', 'scale', 2) %subsampling layer};cnn = cnnsetup(cnn, train_x, train_y);opts.alpha = 1;opts.batchsize = 50;opts.numepochs = 1;cnn = cnntrain(cnn, train_x, train_y, opts);[er, bad] = cnntest(cnn, test_x, test_y);%plot mean squared errorfigure; plot(cnn.rL);assert(er<0.12, 'Too big error');```Example: Neural Networks---------------------```matlabfunction test_example_NNload mnist_uint8;train_x = double(train_x) / 255;test_x = double(test_x) / 255;train_y = double(train_y);test_y = double(test_y);% normalize[train_x, mu, sigma] = zscore(train_x);test_x = normalize(test_x, mu, sigma);%% ex1 vanilla neural netrand('state',0)nn = nnsetup([784 100 10]);opts.numepochs = 1; % Number of full sweeps through dataopts.batchsize = 100; % Take a mean gradient step over this many samples[nn, L] = nntrain(nn, train_x, train_y, opts);[er, bad] = nntest(nn, test_x, test_y);assert(er < 0.08, 'Too big error');%% ex2 neural net with L2 weight decayrand('state',0)nn = nnsetup([784 100 10]);nn.weightPenaltyL2 = 1e-4; % L2 weight decayopts.numepochs = 1; % Number of full sweeps through dataopts.batchsize = 100; % Take a mean gradient step over this many samplesnn = nntrain(nn, train_x, train_y, opts);[er, bad] = nntest(nn, test_x, test_y);assert(er < 0.1, 'Too big error');%% ex3 neural net with dropoutrand('state',0)nn = nnsetup([784 100 10]);nn.dropoutFraction = 0.5; % Dropout fraction opts.numepochs = 1; % Number of full sweeps through dataopts.batchsize = 100; % Take a mean gradient step over this many samplesnn = nntrain(nn, train_x, train_y, opts);[er, bad] = nntest(nn, test_x, test_y);assert(er < 0.1, 'Too big error');%% ex4 neural net with sigmoid activation functionrand('state',0)nn = nnsetup([784 100 10]);nn.activation_function = 'sigm'; % Sigmoid activation functionnn.learningRate = 1; % Sigm require a lower learning rateopts.numepochs = 1; % Number of full sweeps through dataopts.batchsize = 100; % Take a mean gradient step over this many samplesnn = nntrain(nn, train_x, train_y, opts);[er, bad] = nntest(nn, test_x, test_y);assert(er < 0.1, 'Too big error');%% ex5 plotting functionalityrand('state',0)nn = nnsetup([784 20 10]);opts.numepochs = 5; % Number of full sweeps through datann.output = 'softmax'; % use softmax outputopts.batchsize = 1000; % Take a mean gradient step over this many samplesopts.plot = 1; % enable plottingnn = nntrain(nn, train_x, train_y, opts);[er, bad] = nntest(nn, test_x, test_y);assert(er < 0.1, 'Too big error');%% ex6 neural net with sigmoid activation and plotting of validation and training error% split training data into training and validation datavx = train_x(1:10000,:);tx = train_x(10001:end,:);vy = train_y(1:10000,:);ty = train_y(10001:end,:);rand('state',0)nn = nnsetup([784 20 10]); nn.output = 'softmax'; % use softmax outputopts.numepochs = 5; % Number of full sweeps through dataopts.batchsize = 1000; % Take a mean gradient step over this many samplesopts.plot = 1; % enable plottingnn = nntrain(nn, tx, ty, opts, vx, vy); % nntrain takes validation set as last two arguments (optionally)[er, bad] = nntest(nn, test_x, test_y);assert(er < 0.1, 'Too big error');```[![Bitdeli Badge](https://d2weczhvl823v0.cloudfront.net/rasmusbergpalm/deeplearntoolbox/trend.png)](https://bitdeli.com/free "Bitdeli Badge")

【算法篇】/*冒泡排序 选择排序 反转排序 三大排序算法*/

学完了编程语言……还不会排序算法?来读这篇博客,轻轻松松解决排序算法问题!!

冲击大厂之路!!! 588

NTscan扫描工具

ntscan是一个扫描器,可以扫描没有密码和弱密码的共享,先到配置文件中填写猜测的用户名和密码,扫描过程中右侧出现的是扫描日志。

七大排序算法:插入排序、希尔排序、选择排序、冒泡排序、堆排序、快速排序、归并排序

插入排序、希尔排序、选择排序、冒泡排序、堆排序、快速排序、归并排序

2301_82256131的博客 3671

蓝牙模块HM-10手册

蓝牙模块HM-10手册,该手册对蓝牙模块HM-10进行了详细的介绍和使用方法以及一些AT指令。

(c++)插入、选择、冒泡排序算法源码(含测试用例)

算法基础 冒泡排序 选择排序 插入排序 c++

执念斩长河 559

python简单选择排序_Python练习1 - 冒泡排序、直接排序、简单选择排序

1.冒泡排序冒泡排序是一种交换排序。什么是交换排序呢?交换排序:两两比较待排序的关键字,并交换不满足次序要求的那对数,直到整个表都满足次序要求为止。代码示例:def bubble_sort(demo:list):length = len(demo)for i in range(length):print("*"*30)for j in range(length-i-1):if demo[j] >...

weixin_39578899的博客 148

Java中的冒泡排序,选择排序,插入排序的原理及实现!!!

Java中的数组排序一、冒泡排序(1)冒泡排序的思想(2)冒泡排序的实现二、选择排序(1)选择排序的思想(2)选择排序的实现三、插入排序(1)插入排序的思想(2)插入排序的实现 一、冒泡排序 (1)冒泡排序的思想 比较相邻的元素。如果第一个比第二个大,就交换他们两个。 比较每一趟中的每两个相邻的元素。这样一趟下来最大的最大的数就在最后面 比较数组长度n减1趟,每趟比较相邻的元素。 持续每次对越来越少的元素重复上面的步骤,直到没有任何一对数字需要比较。 (2)冒泡排序的实现 /*

SSimeng的博客 198

数据结构之简单算法(冒泡排序、选择排序、插入排序)

排序算法在笔试中比较容易考到,其主要是考察一个人的思维水平 排序算法有 这里就简单介绍几个简单排序 冒泡排序、选择排序与插入排序

iloveCodingC的博客 474

位运算、算法概述、简单排序(选择冒泡插入)

Java的基本数据类型中,数值类型(byte、short、int、long、float、long)这几种都是1个字节代表8个bit位,即8位二进制数,byte、short、int、long,分别对应1、2、4、8个字节,8、16、32、64个bit位例如:int类型-->一共有2^32个数,表示的范围是( -2^31 ~ 2^31-1 ),,这么做的目的,是为了在例如:+5(0 000000.....101)

Du_xuan_qing的博客 318

排序算法(冒泡、选择、插入)

1、冒泡排序 int k1 = 0, i, j; double m,k2; double a[100],b[100]; for (i = 0; i < k1; i++) //冒泡排序 { for (j = k1 - 1; j >i; j--) { if (a[j] < a[j - 1]) { m = a[j - 1]; a[j - 1] = a[j]; a[j] = m; k2 = b[j - 1];

qq_51131331的博客 370

C++排序算法(上)冒泡排序、计数排序、选择排序、快速排序、堆排序

前言冒泡排序法。

u014136435的博客 377

四个排序:冒泡,选择,插入,希尔

package com.atzhanyuan.java; /** * @author hylstart * @create 2022-01-14 13:48 */ public class SortTest { public static void main(String[] args) { int[] arr = new int[]{2, 4, 7, 3, 6, 8, 23, 737, 7699, 116167, 0, -892689, -1}; .

m0_51304699的博客 145

java 三大排序_java冒泡_选择_插入三大排序

/ 冒泡排序(BubbleSort)的基本概念是:依次比较相邻的两个数,将小数放在前面,//大数放在后面, 由于在排序过程中总是小数往前放,大数往后放,相当于气泡往上升,//所以称作冒泡排序int a[]={1,4,6,8,2,3,0,34,12,99};for(int i=0;ifor(int j=0;jif(a[j+1]a[j+1]=a[j+1]^a[j];a[j]=a[j+1]^a[j];a...

weixin_39804603的博客 90

冒泡排序 快速排序 选择排序 插入排序

排序算法排序oc实现,冒泡排序,快速排序,选择排序,插入排序

yyc123yyc456yyc的博客 310
上一篇: springMvc+spring4+maybatis简单例子
下一篇: IO流和文件上传下载
Do_It_Possible
博客等级 码龄9年 0粉丝 21原创
评论
成就一亿技术人!
拼手气红包6.0元
还能输入1000个字符
 
 条评论被折叠 查看
添加红包

请填写红包祝福语或标题

个

红包个数最小为10个

元

红包金额最低5元

当前余额3.43元 前往充值 >
需支付:10.00元
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包
实付元
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

1.余额是钱包充值的虚拟货币,按照1:1的比例进行支付金额的抵扣。
2.余额无法直接购买下载,可以购买VIP、付费专栏及课程。

余额充值