一、BubbleSort and XListview

1、BubbleSort
(1)analysis
traverse、compare、exchange、cycle、optimize strategy
loop outside times n-1
loop inside times n-i-1 it reduces 1 next cycle
(2)code:
void BubbleSort(int arr[],int n)
{
    int i,j,temp;
    for(i=0;i<n-1;i++)
    {
        for(j=0;j<n-i-1;j++)
        {
            if(arr[j]>arr[j+1])
            {
                temp=arr[j];
                arr[j]=arr[j+1];
                arr[j+1]=temp;
            }
        }
    }
}
(3)price:o(n*n)
(4)optimize strategy
no exchange,then break:
void BubbleSort2(int arr[],int n)
{
    int i,j,temp,flag;
    for(i=0;i<n-1;i++)
    {
        flag=0;
        for(j=0;j<n-i-1;j++)
        {
            if(arr[j]>arr[j+1])
            {
                temp=arr[j];
                arr[j]=arr[j+1];
                arr[j+1]=temp;
                flag=1;
            }
        }
        if(!flag)
        {
            break;
        }
    }
}
2、ChooseSort
(1)analysis
choose the min element every time,and exchange it with the first(move one by one) element。
(2)code
void ChooseSort(int arr[],int n)
{
    int i,j,temp,min;
    for(i=0;i<n-1;i++)
    {
        min=i;
        for(j=i+1;j<n;j++)
        {
            if(arr[j]<arr[min])
            {
                min=j;
            }
        }
        if(i!=min)
        {
            temp=arr[i];
            arr[i]=arr[min];
            arr[min]=temp;
        }
    }
}
(3)price:o(n*n)
(4)supplementary
Of course,you can also choose the max element to exchange。
 
3、InsertSort
analysis:
     Insert a number into a list which is already ordered。traverse the list from the tail to the head until  it is larger than current and find where to place the number。
code:
void InsertSort(int a[],int n)
{
    int i,j;
    for(i=0;i<n-1;i++)
    {
        int m=a[i+1];
        for(j=i+1;j>0;j--)
        {
            if(m<a[j-1])
            {
                a[j]=a[j-1];
            }
            else
            {
                break;//这一句非常关键
            }
        }
        a[j]=m;
    }
}
 
二、XListView
1、layout、arrow、textview,header and footer is different
2、three conditions,normal、ready、refreshing,different condition has different layout,vary from one to one.
3、event handle
when trigger the event and what to do.
4、XlistViewHeader XListViewFooter XListView XListViewActivity
related api:LinearLayout、ListView、activity、OnScrollListener

LearnHowToThink的更多相关文章

随机推荐

  1. [Java基础]-- Java GC 垃圾回收器的分类和优缺点

    https://blog.csdn.net/high2011/article/details/80177473?utm_source=blogxgwz2 参考:elasticsearch实战-使用G1 ...

  2. 2.6 Go 读取CSV

    Go读取CSV文件,其内容被转换成字符串数组 package main import ( "encoding/csv" "fmt" "io/iouti ...

  3. org.elasticsearch.script.Script使用

    org.elasticsearch.script.Script使用 public Map<String, Object> builderMapPackage(PageBean pageBe ...

  4. ocr 资源

    1. PIL 在图片上添加中文 https://blog.csdn.net/m0_37606112/article/details/78511381 2 .Chinese Text in the Wi ...

  5. OpenGL6-纹理动画

    代码下载 #include "CELLWinApp.hpp"#include <gl/GLU.h>#include <assert.h>#include & ...

  6. 【Javascript】 DOM节点

    HTML文档中一切都是节点! 整个文档是文档节点: 注释是注释节点: 每一个HTML元素都是一个元素节点: 元素内的文本内容是文本节点: 连元素的每一个属性都是一个属性节点. 看到这些是不是感觉很熟悉 ...

  7. hadoop包含哪些技术?

    1.Hadoop包含哪些技术?Common, Avro, MapReduce, HDFS, Pig, Hive, Hbase, ZooKeeper, Sqoop, Oozie. 2.简介Common: ...

  8. ES6学习准备

    ES6学习准备 选择运行环境 ES6的语法,nodeJs.浏览器不一定都支持,不同版本的支持情况不一样.在学习过程中,如何确定是自己写的代码有问题,还是运行环境不支持呢? 首先,浏览器端一般支持的特性 ...

  9. FocusBI: 数据仓库 (原创)

    关注微信公众号:FocusBI 查看更多文章:加QQ群:808774277 获取学习资料和一起探讨问题. <商业智能教程>pdf下载地址 链接:https://pan.baidu.com/ ...

  10. Java入门系列-22-IO流

    File类的使用 Java程序如何访问文件?通过 java.io.File 类 使用File类需要先创建文件对象 File file=new File(String pathname);,创建时在构造 ...