Cells // a collection of data cells lines cells :: [Cells] // the cells: a locat
ID: 665672 • Letter: C
Question
Cells // a collection of data cells lines
cells :: [Cells] // the cells: a location and a value
nCells :: Integer // number of cells in the array
capacity :: Integer // maximum size of the array
end Cells
A Cells structure contains the information about a collection of Cell as follow:
Cell
location :: int // a location of data cells lines
value :: int // a value
end Cell
1. Write a pseudocode algorithm, sortCells, which takes a Cells reference and reorders the cells in ascending order of location.
2. Write a pseudocode algorithm, insertTail, which takes a Cells reference and a Cell element and inset the Cell element at the end of the Cells structure.
3. Write another pseudocode algorithm, mergeCells, which takes two Cells reference and returns another Cells reference which contains all of the cells from both Cells structure. The insertTail function should be used in this function. Hint: be sure allocate memory as necessary.
Explanation / Answer
2.
func insert(Cells obj, cell element)
if obj.capacity==obj.nCells
print "Cells object full. No more elements can be inserted"
else
obj.nCells++;
obj.cells[obj.nCells-1]=element;
end func
Related Questions
drjack9650@gmail.com
Navigate
Integrity-first tutoring: explanations and feedback only — we do not complete graded work. Learn more.