1. If the Length operation associated with an unsorted list returns43, and we th
ID: 3611467 • Letter: 1
Question
1. If the Length operation associated with an unsorted list returns43, and we then call the Delete operation for the list, passing ita value that matches the 21st item in the list:a. What is the index of the component that is deleted?
b. What is the index of the component that takes its place?
c. What does the length operation return after the deletion?
d. How many components in the list change their position as aresult of the deletion?
1. If the Length operation associated with an unsorted list returns43, and we then call the Delete operation for the list, passing ita value that matches the 21st item in the list:
a. What is the index of the component that is deleted?
b. What is the index of the component that takes its place?
c. What does the length operation return after the deletion?
d. How many components in the list change their position as aresult of the deletion?
2. If the Length operation associated with an sorted list returns43, and we then call the Delete operation for the list, passing ita value that matches the 21st item in the list:
a. What is the index of the component that is deleted?
b. What is the index of the component that takes its place?
c. What does the length operation return after the deletion?
d. How many components in the list change their position as aresult of the deletion?
Will Rate Lifesaver.
Thank you.
Explanation / Answer
For both sorted and unsorted lists, the algorithm fordeletion is the same. Find the position of the element to be removed, remove the elementand move all the elements to the right of that element by oneposition 1. If the Length operation associated with an unsorted list returns43, and we then call the Delete operation for the list, passing ita value that matches the 21st item in the list: Ans: In c++. the list starts with index 0. therefore theindex of 21st element will be 20. a. What is the index of the component that is deleted? ans) 20..as 21st element has index 20 in the list b. What is the index of the component that takes itsplace? ans) The element with index 21 will take the place of theelement deleted. c. What does the length operation return after thedeletion? ans) Length of the operation gives 42..since one element isdeleted from the list and 43-1 =42 d. How many components in the list change theirposition as a result of the deletion? ans) Number of elements that change their position are43-21 = 22... as the elements after index 20 to index 42 will change theirposition Total elements that change their position are from index 42 - 20=22 2. If the Length operation associated with an sorted list returns43, and we then call the Delete operation for the list, passing ita value that matches the 21st item in the list: a. What is the index of the component that is deleted? ans) 20..as 21st element has index 20 in the list b. What is the index of the component that takes itsplace? ans) The element with index 21 will take the place of theelement deleted. c. What does the length operation return after thedeletion? ans) Length of the operation gives 42..since one element isdeleted from the list and 43-1 =42 d. How many components in the list change theirposition as a result of the deletion? ans) Number of elements that change their position are43-21 = 22... as the elements after index 20 to index 42 will change theirposition Total elements that change their position are from index 42 - 20=22
Related Questions
Navigate
Integrity-first tutoring: explanations and feedback only — we do not complete graded work. Learn more.