<output id="qn6qe"></output>

    1. <output id="qn6qe"><tt id="qn6qe"></tt></output>
    2. <strike id="qn6qe"></strike>

      亚洲 日本 欧洲 欧美 视频,日韩中文字幕有码av,一本一道av中文字幕无码,国产线播放免费人成视频播放,人妻少妇偷人无码视频,日夜啪啪一区二区三区,国产尤物精品自在拍视频首页,久热这里只有精品12

      English interview - three interesting questions of algorithm analysis (英語面試- 三道有趣的算法分析題目)

      Background introduction

      Here are some problems related to Big-O notation.

      From now on, I will try to write blogs in English for my English interview.

      But below the English descriptions there will be some translations in Chinese, so you guys who don't know English well can still read my article.

      中文:

      這是一些關于算法分析的題目。

      我最近要開始嘗試用英語寫博客了,但是我會附上中文翻譯在下面。

      Upper bound or Lower bound?

      Question:

      Suppose your friend discovers a new algorithm and in his excitement tells you that his algorithm has a lower bound of O(n2). Can you explain why your friend's statement makes no sense?

      Answer:

      Let me explain the definition of the two bounds.

      The lower bound is the best an algorithm can perform. Oppositely,the upper bound is the worst an algorithm can perform.

      And Big O notation cares about the upper bound but is silent about the lower bound.

      We can not say in the best case the running time complexity is quadratic or better,may be in linear or constant.

      Hence,It makes no sense and it's not logical.

      中文解讀:

      大O表示法關注的是一個最差的情況,但是下界意思是最佳情況,所以下界是O(n^2)這種表述的意思是 在最佳情況下,算法的時間復雜度最差是n^2,這種說法是不合邏輯的。


      Formal Definition of Big O

      Question:

      Does O(2^2n) equal O(2^n) ?

      Answer:

      First of all, O(g(n)) means a set of functions.

      if O(2^2n) equals O(2^n) , it means that two statements are ture at the same time.

      • we can find any functions which belongs to O(2^2n) must belongs to O(2^n)
      • we can find any functions which belongs to O(2^n) must belongs to O(2^2n)

      Let's test the f(n) = 2^2n

      if 2^2n = O(2^n) , so the inequality 0 <= 2^2n <= c2^n holds when c is positive and n is greater than n0

      let's divide both sides by 2^n, and we can see

      0 <= 2^n <= c ,when c is fix, we can find a n' which makes the inequality false.

      So O(2^2n) is not equal to O(2^n)

      中文解讀:

      首先翻譯一下題目,能想得到若題目條件成立,則必須同時滿足兩個條件:

      • 任何屬于2^2n函數集合的函數也都屬于2 ^ n集合
      • 任何屬于2^n函數集合的函數也都屬于2 ^ 2n集合

      這兩個集合就一模一樣了。

      用反證法證明,若2^2n屬于O(2 ^n),最后推出矛盾結果,所以并不相等。


      M % N means?

      Determine the time complexity for the following snippet of code

          void complexMethod(int n, int m) {
      
             for (int j = 0; j < n; j++) {   
                for (int i = 0; i < m % n; i++) {
                    System.out.println("")
                } 
             }
          }
      

      Answer:

      m%n is the key to solve the problem.

      if m equals n, m%n equals 0 and the inner loop will not run. The complexity is O(n)

      if m is less than n ,m%n equals m and the complexity is O(m*n).

      The last case is when m is greater than n, m%n equals value ranging from 1 to n-1, So the complexity will in the worse case be O(n^2)

      Hence, the complexity would be O(n^2)

      中文解讀:

      內層循環的余數需要分為三種情況討論,最差的情況是O(n^2),所以整個算法的時間復雜度是O(n ^2)

      posted @ 2021-06-07 15:14  Ging  閱讀(195)  評論(0)    收藏  舉報
      主站蜘蛛池模板: 欧洲精品色在线观看| 国产毛片基地| 亚洲综合在线一区二区三区| 亚洲伊人久久综合影院| 久久影院综合精品| 中文字幕乱码熟妇五十中出| 国产一区二区在线观看的| 欧美视频在线播放观看免费福利资源| 日韩乱码人妻无码中文字幕视频| 狠狠色狠狠色综合日日不卡| 人妻出轨av中文字幕| 亚洲免费成人av一区| 高级艳妇交换俱乐部小说| 女同久久一区二区三区| 精品国产成人午夜福利| 国产一区二区三区在线看| 激情内射亚州一区二区三区爱妻| 中文精品无码中文字幕无码专区| 98日韩精品人妻一二区| 久久无码高潮喷水| 激情在线网| 亚洲人成网站在小说| 狠狠色丁香婷婷综合尤物| 衡山县| 亚洲国产精品男人的天堂| 成人午夜在线观看刺激| 绥德县| 欧美亚洲另类制服卡通动漫| 亚洲人成人无码网WWW电影首页 | 亚洲色欲色欲www| 秋霞鲁丝片av无码少妇| 97人妻免费碰视频碰免| 国产午夜精品福利视频| 息烽县| 韩国午夜福利片在线观看| 欧美成人精品一区二区三区免费| 亚洲真人无码永久在线| 亚洲国产精品久久久久秋霞| 日韩欧美一卡2卡3卡4卡无卡免费2020| 日韩欧美在线综合网另类| 资源新版在线天堂偷自拍|