Ask Question
16 November, 23:35

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. 17 November, 03:07
    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 and Technology if you're in doubt about the correctness of the answers or there's no answer, then try to use the smart search and find answers to the similar questions.
Search for Other Answers