
Study with the several resources on Docsity
Earn points by helping other students or get them with a premium plan
This page cannot be seen from the preview
Don't miss anything!

Course
Data Structure and Algorithm Gode: ,T-207 I lT-22408 Part- ll
aaaaoaaaaaaaaaaotaaaaa' a
a aa a aaaaoaaaaao o!^ a
Time:2 Hns.45^ Min.^ Marks:
i-. ..
al what are the tlme comFlexities of each^ of^ the^ follo$ring^ code cegmenB?^ Wrhe^ tDur^ answerc^ in Blg Oh^ notation only. tror(l.nt i s 1i 1 .(- n, ,.++) ( for(int (^) J - 0; (^) J (-^ 10000; j++) t t.lttlt++r' l l b) (^) Apply the (^) Qulck rort algorlthm on thls array and show the contents after^ g[g-ElB!ig!
cl Write down the p6t-fix^ forms of the fotlowing infix^ expresslcns {keeping ln^ mlnd^ the op€rator precedence rules of C++): t+c+'llD-&.rlg d) Write brlef answers to the followlnE^ two^ questiont: o l{ame^ one^ advantage^ of^ a^ llnked^ llst^ over^ an^ array. o Name one advantage of an^ array over^ a^ linkad list.
al Given the following declaration of a Orcular.Doubly-Unksd.U* (wlth^ a^ dummy^ heeder node| which
Y vold inrrtltEnd(int^ Trl, CDlinkcdLisr class.^ This firnction^ inscrB'Vtf"^ at the^ cnd^ of^ thc^ tinled^ list. Th€^ tinr^ courBlexity^ of^ this function should^ bc^ constant^ i.s. O(1).
bt Write^ a rccurJve^ C++ function^ to^ count all^ occurrences^ of^ e gfucn^ number^ t3^ in^ a^ given^ array^ of integers. The prototype^ ofytur^ function^ shouH^ ba: Lnt eount (trat* :rr,^ int^ rtaat,^ trtrt^ .nd, int^ Ic) tntheaboveprototype,rrrirthearray,!t ttandrndarestartintrndendlnglndicesofthearraY, and k is the number whose occurrences^ are^ to^ be^ counted. For (^) example, if (^) the array rrr contaiffi th6e^10 ktttte6^ i2rl,?,5,7,?nQ,7,8rQ and^ we^ call count(lrrrOrgr?) thenthisfunctlonshouldretum4(becau:ethenumberToccurc4tlm€sin the above array). Note: Do NOT change thcftnction protatype.^ Do^ NOT^ usc^ qry^ globaAstaic^ vafiabl*.^ 77td lmplementarion musr.^ *^ rciursive.^ No^ Markslor^ itaratlve^ implamcntation
{ frirnd^ clul^ CD&iakrdllrt; I}riv.t.: irlt drtr; DNo&r tl.xt, DNod.r !,Rsy; );
@I"ialedlirt
prlvrt : DHod. lrmdi publia! void inrrtAtDnd (int^ vall t l;