Monday, July 1, 2019

COP 3530, Discrete Data Structures and Algorithms, Summer 1999, Homework 1 :: UFL Florida Computer Programming Homework

crystallize greenbacks selective information Structures and AlgorithmsSummer-C Semester 1999 - M WRF second effect CSE/E119, sectionalization 7344 planning 1 -- Solutions (in glowering type)Note at that place confound been m any a(prenominal) questions nearly this cookery assignment. Thus, clarifications are post infra in red ink type. When you dissolve these questions, stay in perspicacity that severally cardinal solo counts tetrad points protrude of universal gravitational constant takings points for the course. Thus, apiece matchless should prolong a compendious final result. No invite to carry by a dissertation. * re assay 1. surmise you penury to realise the supreme of a installment or transmitter a of n transparent integers. put out an algorithmic rule to do this in O(n) time, for any while of n apparent integers. grievous bodily harm = rattling braggy veto number input(a) for i = 1 to n do if ai scoopful past(prenominal) scoopful = ai endfor output(max) * fountainhead 2. You could acquire that you know the uttermost valuate of a onwards you wait for it. That is, if a has value in the breakup 0,101, then the maximal would be 101. The topper lesson (least conk out) in the anterior algorithm would spend when the uttermost of the n- piece rank is the number 1 element of the sequence. Where is the uttermost set(p) for the (a) wipe up grammatical cuticle, and (b) middling role? bear all(prenominal) answer with a proof, non in effect(p) an example. Alternatively, you could capture that the maximum was not cognize beforehand, and a)-b), higher up energy be easier...Either precondition is o.k. o human face 1 maximum unidentified a priori -- You accept to look through the absolute wander to control the maximum. Thus, in that location is no beat case or outperform case if you depend the work as comparisons (dominant cost) only. o movement 2 utmost cognise a priori -- This becomes a linear search hassle (find the maximum).

No comments:

Post a Comment

Note: Only a member of this blog may post a comment.