Define the method getPositionfor the class SortedListHasA.

What will be an ideal response?

```
template
int SortedListHasA::getPosition(const ItemType& anEntry) const
{
int position = 1;
int length = listPtr->getLength();
while ( (position <= length) &&
(anEntry> listPtr->getEntry(position)) )
position++;
if ( (position > length) || (anEntry != listPtr->getEntry(position)) )
position = -position;
return position;
} // end getPosition

```

Computer Science & Information Technology

You might also like to view...

In a UML class diagram, the minus (-) indicates:

a. public access b. protected access c. private access d. package access

Computer Science & Information Technology

Which of the following code fragments gives a random double value between 2 and 5 inclusive? You can assume that the random number seed has been set and any needed definitions and initializations have been made.

a. 3.0*rand() + 2 b. 3.0*(RAND_MAX-rand())/RAND_MAX + 2 c. ((RAND_MAX-rand())/static_cast(RAND_MAX))*3 + 2 d. (RAND_MAX-rand())/static_cast(RAND_MAX)*5 -2 e. rand()/static_cast(RAND_MAX)*2 + 3

Computer Science & Information Technology