You are on page 1of 28
PART-I: MCS.021 Question 1 Sort che fallowmng drray items using quick sort method. oS24 $6.47 38 1090 82 314 TI jorathm 19 C to implement this a od find its time complexity Wrne un al 6 Marks) Ans (1) Quicksort Sorting Aigorithm:- Quickest 1s a widely used sorting algorithm invented by C. A. R, Hoare in 1960. [ts popularity has fasted stn its mrenton because it's casy Lo implement. ist “yeaetal purpose” sori. ind consumes thsver resolurees thar; mans oiher sorting methods 1n different situations. Quicksor is in-place algorithm diving only a smrall aanifiary stack) requiring on average N log N operations vert Nites Bi also has an extremely short inner loop, The analysis af why 1s conmplenity is ON nf the alyorithsn 1s thar it takes N2 operations in the tne tha germ captures the 1. The zemaining log Syis found here:, However a dns wars! case Quteksort is also Rnown as a parntion-exebang Daste ies cf the mctheni. Que oF dle elements is seleeied as the partition elem tenis are compared fo it anc a series of exchanges is performed, When the series of exche: one. the original sequenes hy been partitioned into three subsequences: sort bee all items less tha’ the partion elem 2. the partitioning element in ats final place 3. all stems s1eates then the partition elemest completed and quicksor! will be applied recursively to steps 1 ad 3. The nes, At this stage. step sence is sorted whew the recursion termi suid cut by selecting an clement os the partition clement. Then we | we find an clement greater than the partition «aw clement fess than the The partitions process is Sein a potter from the beginning of the array clemeat, and sean a pointer from the end of the array uncil we partition eiewent, These elements ave exchanged seeause they are clearly out of place. This process is continued until the pointers eros, which is also the correct place to insert the partition element include #define MAXARRAY 10 void quicksortGn’ ary{J. ant Low. ant high): int maintveid) | int array{MAXARRAY]~ {0} min 0; * Toad some random values into the array * for(i = 0; i< MAXARRAY, i+) array{i] + rand0 % 100; * print the original aay " print{("Before quicksort for(i = 0; i MANARRAY: int) / printit” a *, array quicksort(array, 0, (MAXARRAY - 1)); * print the “quicksorted’ array * printf("Afier guickson: "); tori = 0 i= MAXARRAY: 1 printi( Yed", arrayfipy print") return 0: * sort everything inbenween ‘low’ <-~ “high #/ Void quicksort(int arr{], int low, int high) { inti= low: int j = high. inty= 0: compare vaiue * intz = artiflow + big * parntion * do © tind member while(arr] <2) i * tind clement below... * whileteerh) > inn + swap reo elements */ yeasts anti) sshuledd = iflow nis valid oF not Is there a way to find out if the converted postfix expre Yes. We nced to associate a rank far ench symbol of the expression. The rank of an ops and the rank of an operand is +1. The total rank of an expression can be determined as follows += If an operand is plaved in the post fix expression, incremeat the ra =f an operator is placed in the pos’ fiy expression, decrement the 74 Ataay point of time, while converting an infis expression 10 a postfix expression, the rank of the expression can be greater thas or equal to one. Ifthe cauk ss anytime fess than ene. the fs invalid, Onoe the eutize expression is converted, the rank: mus: be equal 10 L Fise expression is invalid, Conversion from infix to predin This is very similar to the method mentioned above, except the fact chat we avd the special value [at the stat of the expression amd jt the stack and sve move throu the infix expression fro right fo left, Also at the end, reverse the output expression go. £9 get the pretin expression, Evaluation of a postfix expression ere is the psendecorie, As we scan from Teft to right * If'we encounter an operand, push it onto the stack + If-we encounter an operator, pop 2 operand from the stack. The first ox popped is called ‘operand? andl the second one is called operandi, »'Pecform Resultoperond] operator operand2, © Push the result onto the sisck “ Repeat the above steps tll the end of the input, Convert trom postfis expression to intin Ths isthe same as postfix evaluation, the onty di fg. Pat we Won evaluace the expression. but just present the answer, The seanning is dome from fel to righ pression ABC-D*+ A(B-C)D*+ (BCD) AH(E-C}D) Convert from postfix expression to infix ‘The seanning is done froma right to left and s sitnilar to what we did above ABCD Reverse it DCB-A+ DIB-CyA, (-C #)A- AM (B-C)*D) Question 1: Show o sorted ist of Files in sour hoe directory those contain the word “eomiputer inside them, @ Marks) Any ‘One of the most common things we do in Termina! is yo looking Hor files and directories, Sonetinses We know right where t loak and sometimes we look in a few different places, ov even ‘use the find command to look through potertially vast numbers of directories. Vee can also ask the shell to find files fora given pattern, If we are in a directory vith many images Whose names are descriptive, we could use a command like this to find al files that inelade the word computer: Is Yeomputer* I Mag OS X the Hilesystem is by default essentially easesinsensitive for the purposes of file slobbing. So, even ifthe file 1s called BIG_compurer SMILES jpg it will sull be matehed by the “bove pattern The * character matches zero oF move chatacters. The” character matches exact! So. .we eould match ell es with a dree-leter extension like this won't matel ¢ He whyse name ie “boesttle” nor wil ic mate a file with a twodetter extension, voc as myprogramn.py. for example. won't match tiles in a subdirectory of the 1a Took in subdirectories nor span directories So, 9 pattemn ike * current Girec.ors. Bus, we ean clude slasiies ou « pa *'*airpat®/* ipa The above will look ia all subdirectories of the current directory (*9, and in each subdirectory it \vill gontinue the search in those that sich "dicpat, and im any matching direcories it will Fst all files endity in jp We could also use a find und grep pipeline like this find .-name * ipa -peint | grep dirpat The difference és that the find command will descend into all subdirectories, recursively, and the grep command sll match the dirpat regardiess of whether itis one, Ww, three oz any numdcr of circetories below the cumrent directory Question 2; Set the execution time ofa job so that it can run automatically after 15 minuces ALTER SYSTEM SET JOB_QUEUE_PROCES' It the new value is lower than the previous setting and le: (2 Marks) Ans? ‘We vim schedule routines (jobs) to be run pesiodically using the job quue. Ts sehedule a,b We sulnmit ito the job queve, using the Oracle supplied DBSIS_ JOB package. ane speci liequency at whicit the job is to be ran. Additional functonaliy enables we to alte, disable, dele 9 jah thar we previousty submitted, Josh queue {lnm provesses exevete jobs in the job queue: For each instance. these job quene re dynamically spawaed by 2 coordinator job queue (CIQD) background provess. The periodically selects jobs that are ready to run ikon» the jobs shown 19 he DES_JOLS, view, It orders them by tine, end then spawns Jn processes to sua the selected jobs. Tech drm process executes ene of the selected jobs The JOB_QUEUE_PROCESSES initialization parsnseter controls whether a cogrdinator job ‘queue process started by aa instance, I hts param 21 (0 O, no coordinate jnb queue process is started at database startup, and consequently a0 jab queue jobs ave executed. The JOB. QUFUR_ PROCESSES iniiia!izarion parameter also specifies the maximum wumber of Jepsm caily run un an instance, He maximum numberof processes Ht car provesses that can concur be specified is 1000. ‘The following initialization parameter setting causes the courdinator job queue process (9 Slat at freq = new Haslitahte <1) 4 butler append(ehar) ch) in.closet}: return butfer.oStringy * eatch (JOB ception e) | cprinSiack facet) return nuit Public static void main Str args) | String a Strang = mew String’ uoSe5 672 usa9e 6587 USS 7.US217"): wrleOutputjastran String inpatString = readlupat(): String display Sir fring ~ "" ~ input Suing; hew ShowStrandisplaySuing. “Conversion Demo")

You might also like