Lub sijhawm nyuaj ntawm kev xa khoom xa mus yog dab tsi?

Cov txheej txheem:

Lub sijhawm nyuaj ntawm kev xa khoom xa mus yog dab tsi?
Lub sijhawm nyuaj ntawm kev xa khoom xa mus yog dab tsi?

Video: Lub sijhawm nyuaj ntawm kev xa khoom xa mus yog dab tsi?

Video: Lub sijhawm nyuaj ntawm kev xa khoom xa mus yog dab tsi?
Video: Sijhawm Txawj Hloov - Nyaj Xuv Xyooj 2024, Lub peb hlis ntuj
Anonim

In postorder traversal txhua qhov ntawm tsob ntoo binary yog mus xyuas: a) 1 zaug yog tias nws yog nplooj ntoo. c) 2 zaug yog cov node muaj ob sab laug thiab sab xis me nyuam. 2 lub sij hawm vim thaum peb yuav tsum ua tus me nyuam txoj cai ib zaug peb ua tiav nrog nws cov me nyuam sab laug peb yuav tsum tau xyuas seb lub node muaj tus me nyuam txoj cai los tsis.

Lub sijhawm nyuaj ntawm Postorder traversal Mcq yog dab tsi?

Post-order ua raws LRN txoj cai. 7. Dab tsi yog lub sij hawm nyuaj ntawm kev txiav txim ua ntej traversal nyob rau hauv iteration fashion? Nqe lus piav qhia: Txij li thaum koj yuav tsum mus dhau tag nrho cov nodes, qhov nyuaj ua O(n).

Lub sijhawm nyuaj ntawm qib kev txiav txim hla kev yog dab tsi?

Time complexity =O(n), qhov twg n yog tag nrho cov nodes. Theem kev txiav txim traversal yuav tsum tau qhov chaw proportional rau qhov max dav ntawm tsob ntoo (w) uas yog sib npaug ot qhov siab tshaj plaws ntawm cov nodes ntawm ib tug muab. Space Complexity=O(w)(Xav!)

Lub sij hawm nyuaj ntawm binary ntoo traversal yog dab tsi?

Kev Tshawb Fawb: Rau kev tshawb nrhiav 1, peb yuav tsum hla txhua lub ntsiab lus (hauv kev txiav txim 3, 2, 1). Yog li ntawd, kev tshawb nrhiav hauv binary nrhiav tsob ntoo muaj qhov teeb meem phem tshaj plaws ntawm O (n). Feem ntau, lub sij hawm nyuaj yog O(h) qhov twg h yog qhov siab ntawm BST.

Lub sijhawm nyuaj ntawm qib kev txiav txim hloov pauv yog dab tsi?

Sijhawm nyuaj: O(n^2) hauv qhov phem tshaj plaws. Rau ib tsob ntoo skewed, printGivenLevel siv sijhawm O(n) qhov twg n yog tus naj npawb ntawm cov kab hauv tsob ntoo skewed.

Pom zoo: