Ch5 - EE 322C Data Structures Chapter 5: Algorithm Analysis...

Info iconThis preview shows pages 1–7. Sign up to view the full content.

View Full Document Right Arrow Icon
1 Ramesh Yerraballi 5-1 EE 322C Data Structures Chapter 5: Algorithm Analysis
Background image of page 1

Info iconThis preview has intentionally blurred sections. Sign up to view the full version.

View Full DocumentRight Arrow Icon
2 Ramesh Yerraballi 5-2 To extend or to implement Inheritance is used to extend a base to create a new type [classification] Interfaces are used to introduce capabilities that are non-existent in the base [attribution] Both inheritance and interfaces are is-a relationships Note: Inheritance must be used sparingly by asking the question “am I really introducing a new classification” or “am I just introducing a capability”. E.g., threads (extend Thread vs. implement Runnable ) Recap
Background image of page 2
3 Ramesh Yerraballi 5-3 …To extend or to implement Quote a java forum: “B ecause of the nature of classification the subtypes are likely to benefit from common code provided by the supertype(base). So class extension is best used when you have a classification relationship (because it can carry implementation). This is not so with attribution. Each subtype is likely to have to provide its special implementation so you can as well use interface extension (it doesn't carry implementation). If you use an interface to represent classification you're likely to have to repeat code in the subclasses. So the rule of thumb is to use class extension to avoid that.So it boils down to this: Class extension and interface implementation are equivalent from a typing perspective. Both should be used when there's an is-a relationship (and not a has-a). Class extension is best suited to represent classification and interface implementation is better for attribution relationships.” Recap
Background image of page 3

Info iconThis preview has intentionally blurred sections. Sign up to view the full version.

View Full DocumentRight Arrow Icon
4 Ramesh Yerraballi 5-4 Algorithm Analysis: Outline Estimating the time required for an algorithm Techniques for reducing the running- time of algorithms Mathematical framework for describing running-times of algorithms, problems How to write a simple binary search routine
Background image of page 4
5 Ramesh Yerraballi 5-5 Growth of Functions 7.5*N*log(N) =
Background image of page 5

Info iconThis preview has intentionally blurred sections. Sign up to view the full version.

View Full DocumentRight Arrow Icon
6 Ramesh Yerraballi 5-6 Dominance
Background image of page 6
Image of page 7
This is the end of the preview. Sign up to access the rest of the document.

Page1 / 21

Ch5 - EE 322C Data Structures Chapter 5: Algorithm Analysis...

This preview shows document pages 1 - 7. Sign up to view the full document.

View Full Document Right Arrow Icon
Ask a homework question - tutors are online