Kramer answers your questions about program #7

  1. Q:
    I need help on program 7. I have completed the program up to the last step, that's where I'm having problems and I just can't seem to get it.

    I have four functions total:

    I'm having problems with the last step and don't know how to set up the loops and everything to reorganize the array. Can you give me some good advice on that?

    A:
    Ok, first of all, your approach to the problem is great. But your last function seems to have a difficult strategy. Try this instead:

    Since the loop counts down, you should go through each run starting with the largest and ending with the smallest!


  2. Q: Did you know that project 7 isn't due till tuseday? i mite be able to get it done by then.

    A: Yes I did. Do you feel lucky.....punk


  3. Q: The problem definition states that we are supposed t sort in ascending order. It doesn't account for 2 identical numbers in a row - How would you like the program to implement this?

    A: Don't start a new run if the numbers are identical. Only start a run if the next number is smaller.


  4. Q: I have no idea what a run is.

    A: Well little buddy, let's look at Glinert's example:

    13 34 55 68 46 61 73 90 37 26 41 84 38 92

    • The first number, 13, indicates the amount of numbers that will follow.
    • Start counting at 34 and go until you get to a number that is not larger than the prior one.
    • In this case, you will only get to 68 because the next number, 46, is smaller.
    • So your first run is 34 55 68
    • The next 46 61 73 90
    • The next 37
    • And so on until you get to the end.

    The worst case would be if all the numbers were in descending order, then you would have the same amount of runs as you do numbers!


  5. Q: What is a good way to approach solving this program. I don't know where to start!

    A: There are several ways to attack this problem, and many will work. Some people may feel more comfortable using a 2-D array and sticking each run into each row of the array. You could accomplish this by putting the first run in the first row, then have a "check" for when the next run starts and go to the next row. You will also need another array to hold the sizes of each run. While this will work fine, it may be tricky for people who don't know how to use nested for-loops.

    Another way, would be to have 3 separate arrays.

    • The first array should hold all your numbers.
    • The second array should hold all the indexes of where each run begins. For Glinert's example (above), it would look something like this:
      0 3 7 8 11
    • And the last array should hold the sizes of each run. (Don't forget to have a variable that counts how many runs you have)

    Finally, start to write the program slowly, taking baby steps. First just get your program to put the indexes in the second array. Then, when that works fine, write another function that fills in the third array with the sizes of the runs. And then finally, after you have all three arrays filled in correctly, get the program to output the runs from biggest to smallest.


  6. Q: I have been working on my program for quite a while now. I almost have it, only it tells me that I have exceeded my quota. I have no clue where all the space is going? I have nothing in my directories. My 'yesterday' file is taking up 52% of the space. My quota is 7000 and not 5000, but still it would not save my program.

    A: First of all, don't worry about your yesterday directory taking up disk space (it's all stored on a backup server).

    Second, try to look for large hidden files. Do this by typing:

    ls -la
    If you find any files that look like .__afs3475 delete them. These files are each about 1/2 a meg and are huge. You will find them where you compile your stuff. I've found that sometimes, when a compilation fails, g++ will put these hidden files in your account.

    Also another answer is to clear the cache in Netscape. It download tons of pictures and these really build up quickly.


    TA SLAUGHTERS UNDERGRAD :
    Bloodbath during office hours .
    Insane rage rumored to be sparked by a single email message - Judge's verdict: Justifiable homicide.

<---- Comp Sci 1 Homepage