21. Assuming keys are comprised of upper- and lowercase letters, give the bit pa
ID: 3603706 • Letter: 2
Question
21. Assuming keys are comprised of upper- and lowercase letters, give the bit pattern and base 10 numeric value of the pseudo key that would result from processing the key “Mary” using the algorithm illustrated in Figure 5.17.
For the numeric key: 987845369, the key is folded about 845 The addition is performed as: 845 987 369 2201 Thus, the pseudo key would be 201 For the non-numeric key: "ALMcAllister" the key is folded about the second grouping. Alli The addition is performed as: Alli 0100 0001 0110 1100 0110 1100 0110 1001 AIMc 0100 0001 0110 1100 0100 1101 0110 0011 +ster 0111 0011 0111 0100 0110 0101 0111 0010 Treating this result as a positive 32 bit integer, the pseudo key would be 4, 132,249,406.Explanation / Answer
Implementation inheritance is the mechanism whereby a subclass re-uses code in a base class. By default the subclass retains all of the operations of the base class, but the subclass may override some or all operations, replacing the base-class implementation with its own.
In the following Python example, subclasses SquareSumComputer and CubeSumComputer override the transform() method of the base class SumComputer. The base class comprises operations to compute the sum of the squares between two integers. The subclass re-uses all of the functionality of the base class with the exception of the operation that transforms a number into its square, replacing it with an operation that transforms a number into its square and cube respectively. The subclasses therefore compute the sum of the squares/cubes between two integers.
In most quarters, class inheritance for the sole purpose of code reuse has fallen out of favor.[citation needed] The primary concern is that implementation inheritance does not provide any assurance of polymorphic substitutability—an instance of the reusing class cannot necessarily be substituted for an instance of the inherited class. An alternative technique, explicit delegation, requires more programming effort, but avoids the substitutability issue.[citation needed] In C++ private inheritance can be used as a form of implementation inheritance without substitutability. Whereas public inheritance represents an "is-a" relationship and delegation represents a "has-a" relationship, private (and protected) inheritance can be thought of as an "is implemented in terms of" relationship.[12]
Another frequent use of inheritance is to guarantee that classes maintain a certain common interface; that is, they implement the same methods. The parent class can be a combination of implemented operations and operations that are to be implemented in the child classes. Often, there is no interface change between the supertype and subtype- the child implements the behavior described instead of its parent class
Related Questions
drjack9650@gmail.com
Navigate
Integrity-first tutoring: explanations and feedback only — we do not complete graded work. Learn more.