Ask Question
21 February, 01:29

Given the following sequence of names added to an ADT sorted list:nameListPtr->insertSorted ("Tammie"); nameListPtr->insertSorted ("Brenda"); nameListPtr->insertSorted ("Sarah"); nameListPtr->insertSorted ("Tom"); nameListPtr->insertSorted ("Carlos"); What would be returned by the call nameListPtr-> getPosition ("Tammie") a. 1b. 3c. 4d. 5

+3
Answers (1)
  1. 21 February, 02:52
    0
    c. 4

    Explanation:

    This will work as following:

    Lets say first Tammie is inserted by this statement insertSorted ("Tammie")

    Next insertSorted ("Brenda") statement adds Brenda on top of Tammie so the sequence is now

    Brenda Tammie

    Next insertSorted ("Sarah"); statement inserts Sarah below Brenda and above Tammie so the sequence becomes:

    Brenda Sarah Tammie

    Next insertSorted ("Tom"); statement inserts Tom below Tammie so the sequence becomes:

    Brenda Sarah Tammie Tom

    Lastly insertSorted ("Carlos"); statement inserts Carlos above sarah and below brenda so the sequence becomes:

    Brenda Carlos Sarah Tammie Tom

    Now the statement getPosition ("Tammie") is called which returns the position value of Tammie. So as you can see above its position is 4th so output is 4.
Know the Answer?
Not Sure About the Answer?
Get an answer to your question ✅ “Given the following sequence of names added to an ADT sorted list:nameListPtr->insertSorted ("Tammie"); nameListPtr->insertSorted ...” in 📙 Computers & Technology if there is no answer or all answers are wrong, use a search bar and try to find the answer among similar questions.
Search for Other Answers