Ask Question

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

+5
Answers (1)
  1. 3 August, 22:56
    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?
Find 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 the answers seem to be not correct or there’s no answer. Try a smart search to find answers to similar questions.
Search for Other Answers