Explain an effiffifficient method to fifind the ok-th smallest…
Question Answered step-by-step Explain an effiffifficient method to fifind the ok-th smallest… Explain an effiffifficient method to fifind the ok-th smallest variety in a set of nnumbers (output: one variety), with out fifirst sorting the n numbers, and discussits complexity in terms of n and ok. [4 marks](b) Explain an effiffifficient technique to fifind the okay smallest numbers in a fixed of n numbers(output: ok numbers), with out fifirst sorting the n numbers, and speak itscomplexity in phrases of n and k. How a whole lot greater work is wanted comparedto (a)? [4 marks](c) Draw 4 distinct binary search timber (BSTs) for the subsequent set of keys:1, 2, three, 4. [2 marks] (d) Let a height-balanced BST (hBST) be a BST with the extra defifininginvariant that each node is the parent of subtrees whose heights diffffer by way of atmost 1. Give an effiffifficient manner to insert into an hBST and show that thedefifining invariant is preserved. [10 marks]9 (TURN OVER)CST.2014.1.109Algorithms(a) Explain the phrases amortized analysis, combination evaluation and capacity technique.[6 marks](b) Consider an arbitrary collection of n stack operations PUSH(), POP() andMULTIPOP(x) wherein POP() or MULTIPOP(x) never try and dispose of greaterfactors than there are at the stack. Assuming that the stack begins withs0 items and fifinishes with sn items, determine the worst-case general cost forexecuting the n operations as a function of n, s0 and sn. You might also count onPUSH() and POP() cost 1 each and MULTIPOP(x) fees x. [5 marks](c) Suppose we need to keep some of gadgets in an array, but we do now not realize inboost what number of items want to be stored. The INSERT(x) operation appendsan item x to the array. More precisely, if the size of the array is large sufficient, xis inserted directly at the give up of the array. Otherwise, a brand new array of large sizeis created that incorporates all previous gadgets with x being appended on the cease.The general price of INSERT(x) is 1 within the fifirst case, and the scale of the new arraywithin the 2d case.(i) Devise a approach which, for any integer n, plays any series of nINSERT(.) operations at a total cost of O(n). [5 marks](ii) For the strategy defined in (c)(i), supply a evidence of the value of the set of rulesthe usage of the capacity approach. [4 marks]10CST.2014.1.Eleven10Algorithms(a) Given any directed graph G = (V, E) with non-terrible part weights, don’t forgetthe hassle of all-pairs shortest direction (APSP). Give the asymptotic runtimes ofthe subsequent four algorithms when applied (at once or iterated) to the APSPproblem as a function of provide a brief justifification on youranswer: Bellman-Ford, Dijkstra, matrix multiplication and Johnson. [8 marks](b) Consider the problem of changing currencies modelled by means of vertices representing currencies and every of which has a strictly wonderful weight w(u, v) > 0 representingthe alternate rate. For instance, for any actual number x, we’ve got x USD =w(greenbacks, pounds) · x GBP. Our aim is, given a pair of currencies s, t ? V , tofifind the least costly manner of changing from s to t, in all likelihood by way of the use of extrathan one alternate.(i) How ought to you remodel the graph with the aid of reweighting the rims so that thehassle might be solved with a shortest path algorithm? Indicate whichshortest path set of rules is used. [8 marks](ii) How would you address terrible-weight cycles if they came about inside thetransformed graph? Give the perspective of the forex trader as well asthat of a computer scientist. Write C or C++ program A6p1.C(pp) that accepts one command line argument that is an integer n among 2 and 6 inclusive. Generate a string of 60 random top case English characters and keep them someplace (e.G. In a char array). Use pthread to create n threads to transform the string into a complementary string (A’<->Z, B’<->Y, ‘C’<->X, and so forth). You need to divide this conversion venture many of the n threads as lightly as feasible. Print out the string each before and after conversion on two separatelines. Hint: it’s miles risky to have printing code on your thread characteristic(s). You might also refer to testThread.C, take a look at Thread2.C, pthread ex1.C, pthread_ex2.C for examples. Note: Must use pthread to divide the conversion project among the threads q2: Write public class named MythMouseListener that implements the Mouselistener interface. This magnificence may have a public constructor that takes a JTextArea and a JLabel as parameters and stores these in example variables. Override the mouseEntered technique to. Display the text from the JTextArea on the JLabel in all top case letters. Then, override the mouseReleased approach to show the text from the JTextArea at the JLabel in all lower case letters. The other three methods from the MouseListener interface may be .Left empty q3: Create public elegance named “Servant” with non-public instance variables “sick, “after” and “global” each of kind int. You might also upload another strategies and variables you want to this class. Outside of Servant Cin the Problem Set magnificence) write public static technique named “sortServant” that takes an ArrayList of Servants as a parameter and returns void. This technique will type the innut bv the variable “global” in decreasina order Design and put into effect C/C++ program (myshell5.C) to procedure command (to tokenize and parse the command, and print its additives successfully). Your C/C++ application should be able to parse every command from person (to manner one command after the alternative in a loop), until the user’s command entered is “exit” to terminate the program. Examples (You may additionally create your own output format or template to show the command() being parsed) Run your software for every of the subsequent examples, to show it’s miles running successfully. #3. Two instructions with pipe. For example wc should be parsed and show Command: Is Pipe Command: wc Image transcription text1. Sketch the simplified block diagramof data Communication model forsending a text messages … Show more… Show more Computer Science Engineering & Technology Networking COM MISC Share QuestionEmailCopy link Comments (0)


