Computer Science Canada Just a little help |
| Author: | ScarletSkyFury [ Thu Nov 29, 2007 12:44 pm ] |
| Post subject: | Just a little help |
Allo Well the problem is actually extremely simple, which is makes me frustrated cause i can't seem to get my head around it. Well here it is: I get the user to fill up 2 arrays with integer numbers Then i have to make a union of those arrays and put them into a 3rd array ex: 1st Array: 2,3,2 2nd Array: 4,5,2 But repeated numbers arent added into the third array, hence in this case the 3rd Array would be: 3rd Array: 2,3,4,5 Thanks in advanced xD |
|
| Author: | HeavenAgain [ Thu Nov 29, 2007 12:56 pm ] |
| Post subject: | RE:Just a little help |
Hmmm.... go through the first array first, record down ith number (in the 3rd array), and number recorded shows up again, dont count it (so you probably need a nested loop) and do the same for the 2nd array, using 3rd array to check and then just simply sort the 3rd array |
|
| Author: | wtd [ Thu Nov 29, 2007 7:57 pm ] |
| Post subject: | RE:Just a little help |
Let's think about some base cases. Union of two empty arrays? Union of one non-empty array and an empty array? |
|
| Author: | HeavenAgain [ Thu Nov 29, 2007 9:46 pm ] |
| Post subject: | Re: RE:Just a little help |
wtd @ Thu Nov 29, 2007 8:57 pm wrote: Let's think about some base cases.
Union of two empty arrays? Union of one non-empty array and an empty array? that doesnt matter much does it? if its empty, then length of array is 0, which means the "searching" loop wont even run? |
|
| Author: | wtd [ Thu Nov 29, 2007 11:10 pm ] | ||
| Post subject: | RE:Just a little help | ||
I am trying to get the OP to think algorithmically; to think before writing code. But to put that into code:
|
|||