Algorithms S1 //S1,S2,S3are anyO(1)Javastatement for (int i = 1; i < n; i++) { S
ID: 3602744 • Letter: A
Question
Algorithms
S1 //S1,S2,S3are anyO(1)Javastatement
for (int i = 1; i < n; i++) {
S2;
for (int j = 1, j < n; j++)
S3;
}
Q7 (Chapter 5 problem 4 from the MSD textbook) Consider the following outline of a program
(See book for details). Assuming that n is the problem size, what would be the critical section of this program? Why?
Inheritance
Q8 (R9.3) Consider a program for managing inventory in a small appliance store. Why isn’t it useful to
have a superclass SmallAppliance and subclasses Toaster, Car Vacuum, Travel Iron, and so on?
Explanation / Answer
Hi,
Question 7 requires more details to start with solution
Ans 8- It is not useful to have superclass SmallAppliance and subclasses Toaster, Car Vacuum, Travel Iron because these class do not have anything similar in them. These classes will be referred as clild classes of SmallAppliance. These classes should habe atleast one common property which can help us to group them. For inheritance, the parent and child classes should have a "Is A" relationship between them and all the child classes should hold some common properties among them.
Inheritance refers to the genetic acquisition of properties from ancesstors to the child classes. A class which inherits the properties is called derived class and the class whose properties are inherited is called a base class.
Related Questions
drjack9650@gmail.com
Navigate
Integrity-first tutoring: explanations and feedback only — we do not complete graded work. Learn more.