大致的运行时间

时间:2017-03-08 17:20:59

标签: c arrays algorithm

我用C编写了一个程序来解决最大的子阵列问题。该解决方案具有O(N ^ 3)复杂度。有没有办法估算N = 1,000,000的运行时间?我知道有比三阶算法更快的算法,但我需要将它们与我当前的程序进行比较。

<script src="https://ajax.googleapis.com/ajax/libs/jquery/2.1.0/jquery.min.js"></script>
<!DOCTYPE html>
<html>
<title></title>
<meta charset="UTF-8">
<meta name="viewport" content="width=device-width, initial-scale=1">
<link rel="stylesheet" href="css/styles_test.css">
<link rel="stylesheet" href="https://cdnjs.cloudflare.com/ajax/libs/font-awesome/4.7.0/css/font-awesome.min.css">

<body>


  <div class="w3-content w3-container w3-padding-64">
    <div class="w3-row w3-padding-32 w3-section">
      <div class="w3-col m8 w3-container w3-section">
        <form id="ajax-contact" method="POST" action="php/contact.php">
          <div class="w3-row-padding" style="margin:0 -16px 8px -16px">
            <div class="w3-half">
              <input class="w3-input w3-border" type="text" placeholder="Name" required name="name">
            </div>
            <div class="w3-half">
              <input class="w3-input w3-border" type="text" placeholder="Email" required name="email">
            </div>
          </div>
          <textarea class="w3-input w3-border" type="text" placeholder="Message" required name="message"></textarea>
          <button class="w3-btn w3-gold w3-right w3-padding w3-section" type="submit" id="con-submit">
          <i class="fa fa-paper-plane"></i> SEND MESSAGE
        </button>
        </form>
        <div id="form-messages"></div>

      </div>
    </div>
  </div>

  <div class="w3-display-left w3-display-container w3-center" style="white-space:nowrap;">
    <div class="w3-padding-xlarge">
      <button class="w3-btn w3-white w3-padding-large w3-large w3-opacity w3-hover-opacity-off" onclick="document.getElementById('subscribe').style.display='block'">SUBMIT CV</button>
      <button class="w3-btn w3-gold w3-padding-large w3-large w3-opacity w3-hover-opacity-off" onclick="document.getElementById('client').style.display='block'">CLIENT ENQUIRES</button>
    </div>
  </div>

  <!-- Subscribe Modal -->
  <div id="subscribe" class="w3-modal w3-animate-opacity">
    <div class="w3-modal-content w3-padding-jumbo">
      <div class="w3-container w3-white">
        <i onclick="document.getElementById('subscribe').style.display='none'" class="fa fa-remove w3-xlarge w3-closebtn w3-hover-text-grey w3-margin"></i>
        <h2 class="w3-wide">SUBMIT YOUR CV TODAY</h2>
        <p></p>
        <form id="ajax-cv" method="POST" action="php/cv.php">
          <p><input class="w3-input w3-border" placeholder="Full Name" required name="name"></p>
          <p><input class="w3-input w3-border" placeholder="Email Address" required name="email"></p>
          <p><input class="w3-input w3-border" placeholder="Telephone Number" required name="number"></p>
          <p><input type="file" name="cv" accept="file_extension|.doc"></p>
          <button type="submit" id="submit" class="w3-btn-block w3-padding-large w3-gold w3-margin-bottom">Submit</button>
        </form>
      </div>
    </div>
  </div>

  <!-- Client Enquires Modal -->
  <div id="client" class="w3-modal w3-animate-opacity">
    <div class="w3-modal-content w3-padding-jumbo">
      <div class="w3-container w3-white">
        <i onclick="document.getElementById('client').style.display='none'" class="fa fa-remove w3-xlarge w3-closebtn w3-hover-text-grey w3-margin"></i>
        <h2 class="w3-wide">CLIENT ENQUIRES</h2>
        <p></p>
        <form id="ajax-enquires" method="POST" action="php/enquires.php">
          <p><input class="w3-input w3-border" placeholder="Full Name" required name="name"></p>
          <p><input class="w3-input w3-border" placeholder="Email Address" required name="email"></p>
          <p><input class="w3-input w3-border" placeholder="Telephone Number" required name="number"></p>
          <p><textarea class="w3-input w3-border" placeholder="Message" required name="message"></textarea></p>
          <button type="submit" id="submit" class="w3-btn-block w3-padding-large w3-gold w3-margin-bottom">Send</button>
        </form>
      </div>
    </div>
  </div>

  <script src="js/contact.js"></script>

</body>

</html>

1 个答案:

答案 0 :(得分:1)

如果是O(N ^ 3),你可以通过运行N = 1,000来近似N = 1,000,000,然后乘以1,000,000,000。 (但是,由于O符号可以隐藏除N ^ 3之外的其他重要术语,因此您无法确定它是非常好的近似值。)