一、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. Angular 例子

    前提 angular-cli 是过时的 @angular/cli  用是主流 通讯录  Angular 从零到一 别人是在安装包的时候全程FQ,用蓝灯,每月700M的免费流量 nice fish  A ...

  2. JS及Dom练习 | 页面滚动文字

    <!DOCTYPE html> <html lang="en"> <head> <meta charset="UTF-8&quo ...

  3. 012-MD5Utils工具类模板

    package ${enclosing_package}; import java.math.BigInteger; import java.security.MessageDigest; impor ...

  4. datepicker97切换年月日再连续点击下拉中日期的bug出现问题

    解决办法: function wdateOption(fmt){ if(fmt===undefined){fmt="yyyy-MM-dd"} return{ dateFmt:fmt ...

  5. DateTime.Now与DateTime.Today的区别

    区别如下图: DateTime.Now: 不仅显示日期 还显示当前时间: DateTime.Today: 只显示当前日期,没有时间

  6. OOP_由C到C++

    由C到C++ OOP第一课 C语言的局限 C++的特点 C++的程序特征 C++程序的结构特性 C++程序的编辑.编译和运行 ⭐C++对C的补充 C语言的局限 类型检查机制相对较弱,使得程序中的一些错 ...

  7. SP16580 QTREE7 - Query on a tree VII

    Description 一棵树,每个点初始有个点权和颜色(0/1) 0 u :询问所有u,v 路径上的最大点权,要满足u,v 路径上所有点的颜色都相同 1 u :反转u 的颜色 2 u w :把u 的 ...

  8. mysql-elastic search canal

    背景 早期,阿里巴巴B2B公司因为存在杭州和美国双机房部署,存在跨机房同步的业务需求.不过早期的数据库同步业务,主要是基于trigger的方式获取增量变更,不过从2010年开始,阿里系公司开始逐步的尝 ...

  9. String.Compare 方法 (String, Int32, String, Int32, Int32)

    String.Compare 方法 (String, Int32, String, Int32, Int32) 对两个指定的 String 对象的子字符串进行比较,并返回一个指示二者在排序顺序中的相对 ...

  10. 个人多年经典收藏集合(SQL) 推荐大家收藏

    1.SQL经典问题 查找连续日期 2.sqlserver 中charindex/patindex/like 的比较 3.SQL Server 跨服务器查询 4.SQLserver中字符串查找功能pat ...