Tuesday, April 1, 2014

二元搜尋數(binary search tree)/時間複雜度

Q:(B)將資料2、1、4、5、3 依序插入空的二元搜尋數(binary search tree),再以前
序追蹤(
preorder traversal)其結果為?
(A)12345
(B)21435
(C)21453
(D)54321

桃園縣98年國民中學新進教師甄選【專門科目:電腦】試題#2191




求以下程式的時間複雜度:

for(i=1;i<n;i++)
{
for(j=1;j<n;j=j+i)
x=x+i;

}

答案是nΣ1/n=nθ(logn)=Θ(nlogn)

本信件可能包含中華電信股份有限公司機密資訊,非指定之收件者,請勿蒐集、處理或利用本信件內容,並請銷毀此信件.如為指定收件者,應確實保護郵件中本公司之營業機密及個人資料,不得任意傳佈或揭露,並應自行確認本郵件之附檔與超連結之安全性,以共同善盡資訊安全與個資保護責任.
Please be advised that this email message (including any attachments) contains confidential information and may be legally privileged. If you are not the intended recipient, please destroy this message and all attachments from your system and do not further collect, process, or use them. Chunghwa Telecom and all its subsidiaries and associated companies shall not be liable for the improper or incomplete transmission of the information contained in this email nor for any delay in its receipt or damage to your system. If you are the intended recipient, please protect the confidential and/or personal information contained in this email with due care. Any unauthorized use, disclosure or distribution of this message in whole or in part is strictly prohibited. Also, please self-inspect attachments and hyperlinks contained in this email to ensure the information security and to protect personal information.

No comments:

熱門必看