Write a pseudocode function swap(aList, i, j)that interchanges the itemscurrently in positions i and j of a list. Define the function in terms of the ADT list operations,so that it is independent of any particular implementation of the list. Assume that the list, infact, has items at positions i and j. What impact does this assumption have on your solution?
What will be an ideal response?
```
// Swaps the i-th and j-th items in the list aList.
swap(aList:List, i:integer, j:integer): void
{
//Copy the i-th and j-th items.
ithItem = aList.getEntry(i)
jthItem = aList.getEntry(j)
//Replace the i-th item with the j-th item.
aList.remove(i)
aList.insert(i, jthItem)
//Replace thej-th item with the i-th item.
aList.remove(j)
aList.insert(j, ithItem)
}
```
You might also like to view...
A module that calls itself is known as a(n) __________ module.
Fill in the blank(s) with the appropriate word(s).
The sheet boxis composed of two areas: the page area, which contains the content of the document, and the margin area, which contains the space between the printed content and the edges of the page.
Answer the following statement true (T) or false (F)
What are roughs, and what is their purpose in the design process?
What will be an ideal response?
What is one advantage of merging to a printer instead of to a new file?
A. You can avoid creating a large file. B. You can edit the main document. C. You can edit the individual merge documents. D. You can save each merge document as a separate file.