一、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. npm 包管理工具

    能注册后看简单的功能 订单加信息 下单之前的判断要配合海潮的迁移数据 运行自定义的脚本 在 package.json 的 scripts 里添加自定义的结点 ( 比如 CSOR-serve ) &qu ...

  2. 移动工程后,打开ROM核无配置信息

    问题: 从他人处下载的ISE工程,打开dw51的ROM IP核,无配置信息,为block memory generator的初始配置,并显示无法找到coe文件 原因:ROM配置过程中的部分内容丢失导致 ...

  3. 1.5 js基础

    1.变量.参数.return可以装任何东西. 2.什么时候使用window.onload?         当操作元素时   3.日期对象:在创建日期对象的时候它的日期是不会改变的.         ...

  4. FLUSH TABLES WITH READ LOCK 和 LOCK TABLES 之种种

    1.FLUSH TABLES WITH READ LOCK 这个命令是全局读锁定,执行了命令之后所有库所有表都被锁定只读.一般都是用在数据库联机备份,这个时候数据库的写操作将被阻塞,读操作顺利进行. ...

  5. 九度oj 1464 Hello World for U 2012年浙江大学计算机及软件工程研究生机试真题

    题目1464:Hello World for U 时间限制:1 秒 内存限制:128 兆 特殊判题:否 提交:3872 解决:1082 题目描述: Given any string of N (> ...

  6. Ajax介绍及爬取哔哩哔哩番剧索引追番人数排行

    Ajax,是利用JavaScript在保证页面不被刷新,页面链接不改变的情况下与服务器交换数据并更新部分网页的技术.简单的说,Ajax使得网页无需刷新即可更新其内容.举个例子,我们用浏览器打开新浪微博 ...

  7. MySQL函数库

    MySQL函数库,这个函数库是一个外部函数库!这个函数提供了对于MySQL数据库进行操作的常用函数,如连接MySQL服务器.打开数据库.执行SQL语句等.所以这个函数库的功能对于我们来说是非常重要的! ...

  8. UML关系

    UML关系详解 1.关联关系(association) 连接模型元素及链接实例,用一条实线来表示 2.依赖关系(dependency) 表示一个元素以某种方式依赖于另一个元素,用一条虚线加箭头来表示 ...

  9. 实现easyui的combogrid模糊查询框

    这里用的方法是一个不可编辑的combogrid控件,覆盖上一个可输入的Input控件. 思路: 1.初始时取到后台查询出的列表,存储到全局变量 2.当输入框输入内容时,循环匹配列表,重新绑定到comb ...

  10. Hadoop实战之二~ hadoop作业调度详解(1)

    对Hadoop的最感兴趣的地方,也就在于Hadoop的作业调度了,在正式介绍如何搭建Hadoop之前,深入理解一下Hadoop的作业调度很有必要.我们不一定能用得上Hadoop,但是如果理通顺Hado ...