Sunday, July 12, 2009

(C++ programing:Arrays&Searching)Co... a partially filled array:?

QuestionA:


Consider a partially filled array: that is, the size of the array is S, but only the first N elements have values (N less than S). Write pseudocode that (i) creates an array of 100 integers; (ii) asks a user how many entries should be filled; (iii) puts random values in the first N entries.





Question B:


This question uses the partially filled array from question 3. Suppose you have a variable "filled" that says how many entries of the array have values. Write pseudocode that (i) prompts a user for the index of an array element to be deleted; (ii) deletes the entry from the array by moving over elements one by one to fill in the gap. The size of the array doesn't change, but the filled part of it decreases in size by 1.


Here is an example interaction:





* Data: 2 5 6 8 4 (5 elements)


* User says to delete element with index 2 (3rd element)


* New Data: 2 5 8 4 (4 elements)

(C++ programing:Arrays%26amp;Searching)Co... a partially filled array:?
roc, I recognize your profile name for posting your homework questions here. Please attempt to do your own homework. Cheating this way cheats yourself and undermines and diploma/degree you earn.


No comments:

Post a Comment