• <ins id="pjuwb"></ins>
    <blockquote id="pjuwb"><pre id="pjuwb"></pre></blockquote>
    <noscript id="pjuwb"></noscript>
          <sup id="pjuwb"><pre id="pjuwb"></pre></sup>
            <dd id="pjuwb"></dd>
            <abbr id="pjuwb"></abbr>

            堅(jiān)持到底就是勝利

            用心去做好這件事情

            統(tǒng)計(jì)

            留言簿(1)

            閱讀排行榜

            評(píng)論排行榜

            2006年11月21日 #

            other algorithm

            111

            posted @ 2006-11-21 22:11 ailab 閱讀(224) | 評(píng)論 (0)編輯 收藏

            tree algorithm

            1. ?travel tree without stack or recursive
            2. three travel using none recursive
            3. delete a element in binary search tree
            4. count words(using bst)
            5. level-travel(using queue)

            posted @ 2006-11-21 22:11 ailab 閱讀(257) | 評(píng)論 (0)編輯 收藏

            array algorithm

            1. insert a value into sorted array
            2. select nth element
            3. delete duplicate element
            4. find there exits two same items in a array
            5. find duplicate element a[0.N-1]. range from 1--N-1
            6. a+b = s
            7. find prim
            8. occurs odd
            9. findMidArray

            posted @ 2006-11-21 22:11 ailab 閱讀(215) | 評(píng)論 (0)編輯 收藏

            list algorithm

            1. reverse_list (none-recursive && recursive)
            2. merge list
            3. find middle element of a list
            4. find the nth element from the end of list
            5. insert a element to a sorted single linked list
            6. sort single linked list
            7. swap every two element in a single linked list
            8. circle && the start point
            9. meet together
            10. ploy multi

            ?

            posted @ 2006-11-21 22:09 ailab 閱讀(229) | 評(píng)論 (0)編輯 收藏

            string algorithm

            1. word_count
            2. reverse_string
            3. reverse_word in a sentence
            4. longest increasing subsequence
            5. longest common subsequence
            6. strstr
            7. trim {space}
            8. compress letter
            9. atoi
            10. atof
            11. find all increasing subsequence
            12. Find out if a string is a palindrome.
            13. Delete characters from string 1 which are present in string 2
            14. ?An array of pointers to (very long) strings. Find pointers to the (lexicographically) smallest and largest strings
            15. Given a sequence of characters. How will you convert the lower case characters to upper case characters.

            posted @ 2006-11-21 21:58 ailab 閱讀(274) | 評(píng)論 (0)編輯 收藏

            2006年11月20日 #

            dream come true

            兩個(gè)鏈表是否相交,如果相交,找出第一個(gè)開始相交的節(jié)點(diǎn)

            node? * list(node? * list1,node? * list2)
            {
            ?
            if (list1? == ? null ? || ?list2? == ? null )
            ???
            return ? null ;
            ?
            int ?len1? = ? 0 ,len2? = ? 0 ;
            ?node?
            * p? = ?list1, * q? = ?list2;
            ?
            while (p -> next? != ? null )
            ???
            {
            ????????len1?
            ++ ;
            ????????p?
            = ? -> next;
            ????????}

            ??
            while (q -> next? != ? null )
            ??
            {
            ??????len2?
            ++ ;
            ??????q?
            = ?q -> next;
            ????}

            ??
            if (p? != ?q)
            ????
            return ? null ;
            ??len1?
            ++ ;
            ??len2?
            ++ ;

            ??p?
            = ?list1;q? = ?list2;

            ??
            if (len1? > ?len2?)
            ??
            {
            ???????
            int ?diff? = ?len1? - ?len2;
            ???????p?
            = ?list1;
            ???????
            while (diff? > ? 0 ? && ?p != ? null ;)
            ????????
            {
            ?????????p?
            = ?p -> next;
            ?????????diff?
            -- ;
            ??????????}

            ????}

            ??
            else ?
            ?
            {
            ???????
            int ?diff? = ?len2? - ?len1;
            ???????q?
            = ?list2;
            ???????
            while (diff? > ? 0 ? && ?q? != ? null )
            ????????
            {diff? -- ;?q = ?q -> next;}
            ??}


            ?
            while (p? != ?q)
            ?
            {
            ???p?
            = ?p -> next;q = ?q -> next;
            ?}

            ??
            return ?p
            ????
            }

            posted @ 2006-11-20 23:32 ailab 閱讀(206) | 評(píng)論 (0)編輯 收藏

            dream come true 5!

            reverse list
            recursion and none-recursion

            node?*reverse_list(node?*head)
            {
            ??
            if(head?==?null?||?head->next?==?null)
            ??????
            return?head;
            ??node?
            *cur?=?head->next;
            ??node?
            *pre?=?head;
            ??node?
            *next?=?null;
            ??
            while(cur?!=?null)
            ??
            {
            ?????next?
            =?cur->next;
            ?????cur
            ->next?=?pre;
            ?????pre?
            =?cur;??
            ?????cur?
            =?next;
            ??}

            ??head
            ->next?=?null;
            ??head?
            =?pre;
            ??reurn?head;
            }


            node?*reverse_list(node?*head)
            {
            ??
            if(head?==?null?||?head->next?==?null)
            ????
            return?head;
            ??node?
            *cur?=?head->next;
            ??node?
            *next?=?null;
            ??head
            ->next?=?null;
            ??
            while(cur?!=?null)
            ?
            {
            ????next?
            =?cur->next;
            ????cur
            ->next?=?head;
            ????head?
            =?cur;
            ????cur?
            =?next;
            ?}

            ??
            return?head;
            ??
            }

            posted @ 2006-11-20 22:11 ailab 閱讀(201) | 評(píng)論 (0)編輯 收藏

            dream come true!

            node? * merge(node? * head1,node? * head2)
            {
            ??
            if (head1? == ? null )
            ?????
            return ?head2;
            ??
            if (head2? == ? null )
            ?????
            return ?head1;
            ??reverse_list(
            & head2);
            ??node?
            * head3? = ? null , * cur? = ? null ;
            ??node?
            * p? = ?head1, * q? = ?head2;
            ??
            while (p? != ? null ? && ?q? != ? null )
            ??
            {
            ????
            if (p -> value? < ?q -> value)
            ????
            {
            ???????
            if (head3? == ? null )
            ????????
            {
            ???????????head3?
            = ?p;
            ???????????cur?
            = ?p;
            ???????????p?
            = ?p -> next;
            ?????????}

            ????????
            else
            ????????
            {
            ??????????cur
            -> next? = ?p;
            ??????????cur?
            = ?p;
            ??????????p?
            = ?p -> next;
            ?????????}

            ??????}

            ?????
            else
            ??????
            {
            ???????????
            if (head3? == ? null )
            ???????????
            {
            ?????????????head3?
            = ?q;
            ?????????????cur?
            = ?q;
            ?????????????q?
            = ?q -> next;
            ????????????}

            ???????????
            else
            ?????????????
            {
            ???????????????cur
            -> next? = ?q;
            ???????????????cur?
            = ?q;
            ???????????????q
            = q -> next;
            ???????????????}

            ????????}

            ???}

            ???
            if (p? == ? null )
            ??????cur
            -> next? = ?q;
            ???
            if (q? == ? null )
            ??????cur
            -> next? = ?p;
            ???
            return ?head3;
            }

            posted @ 2006-11-20 22:04 ailab 閱讀(209) | 評(píng)論 (0)編輯 收藏

            dream come true!(4) strstr

            there are many implentations
            char?*strstr(const?char?*str,const?char?*sub)
            {
            ??
            if(str?==?null?||?sub?==?null)
            ????
            return?null;
            ??
            const?char?*p?=?str;
            ??
            const?char?*q?=?sub;
            ??
            while(*str?!=?'\0'?&&?*sub?!=?'\0')
            ??
            {
            ?????
            if(*str++?!=?*sub++)
            ??????
            {
            ??????????str?
            =?++p;
            ??????????sub?
            =?q;
            ????????}

            ???}

            ??
            if(*sub?==?'\0')
            ????
            return?p;
            ??
            else
            ????
            return?null;
            }
            char?*strstr(const?char?*str,const?char?*sub)
            {
            ??
            if(str?==?null?||?sub?==?null)
            ????
            return?null;
            ??
            const?char?*p?=?str;
            ??
            const?char?*q?=?sub;
            ??
            for(;*str?!=?'\0'?;str++)
            ??
            {
            ????
            if(*str?!=?*sub)
            ??????
            continue;
            ????p?
            =?str;
            ????
            while(1)
            ????
            {
            ????????
            if(*sub?==?'\0')
            ???????????
            return?str;
            ????????
            if(*p++?!=?*sub++)
            ???????????
            break;
            ?????????
            ??????}
            ?
            ?????sub?
            =?q;
            }

            posted @ 2006-11-20 21:50 ailab 閱讀(204) | 評(píng)論 (0)編輯 收藏

            dream come true!(3)

            給定數(shù)組a[0:n-1]以及一個(gè)正整數(shù)k(0<=k<=n-1),設(shè)計(jì)一個(gè)算法,將子數(shù)組a[0:k]和
            a[k+1:n-1]交換位置,要求算法在最壞的情況下耗時(shí)O(n),且用到的輔助空間為O(1)。

            in fact,the essence of above question is "revers two times"
            (a'b')' = ba;

            void?reverse(int?*a,int?n,int?k)
            {
            ??
            if(a?==?null?||?n?<?0?||?k?>?n)
            ????
            return;
            ??revers_array(a,
            0,n-1);
            ??revers_array(a,
            0,k);
            ??revers_array(a,k
            +1,n-1);
            ??
            }

            posted @ 2006-11-20 21:20 ailab 閱讀(241) | 評(píng)論 (0)編輯 收藏

            僅列出標(biāo)題  下一頁
            久久成人精品视频| 99久久国产热无码精品免费久久久久| 亚洲国产精品无码久久久秋霞2| 国产99久久精品一区二区| 久久久久国色AV免费观看| 亚洲精品乱码久久久久久蜜桃图片 | 国产91久久综合| 久久久无码精品亚洲日韩京东传媒 | 综合久久久久久中文字幕亚洲国产国产综合一区首 | 亚洲人成无码www久久久| 99久久精品午夜一区二区| 亚洲色欲久久久久综合网| 久久综合久久综合久久| 人妻少妇久久中文字幕 | 亚洲AV无码成人网站久久精品大| 久久久久久无码国产精品中文字幕| 久久久久久久亚洲Av无码| 亚洲国产成人精品女人久久久| 久久久精品免费国产四虎| 久久久久久午夜成人影院| 久久久www免费人成精品| 久久天天躁狠狠躁夜夜不卡| 色综合久久综合网观看| 漂亮人妻被黑人久久精品| 伊人色综合久久天天人守人婷| 国产精品熟女福利久久AV| 欧美精品一区二区精品久久| 久久夜色精品国产噜噜亚洲AV | 亚洲精品成人网久久久久久| 亚洲国产精品久久久久久| 久久久久免费精品国产| 久久久女人与动物群交毛片 | 国产V综合V亚洲欧美久久| 一本一本久久a久久综合精品蜜桃| 久久亚洲精品无码播放| 国产亚洲色婷婷久久99精品91| 夜夜亚洲天天久久| 国产精品内射久久久久欢欢| 亚洲国产精久久久久久久| 成人a毛片久久免费播放| 狠狠人妻久久久久久综合蜜桃|