I
iVan on CSC 101
hi to all!....I'm really having having problms with this array
thing...our instructor just gave us 15 pages copy all about Arrays and
of course problms about it...I have 5 problems and really don't know
how to solve these.....geezzz.....they suck!...=D...hhmmmm...anyway
i'm here for any help from you guys...
beginners like us really need ( I think) to have lectures by those who
should do it but I dunnot know why they're just giving us this stuff
without explanations...hhhhmmm....
nyways, here are the problems about Arrays....
1. Longest plateau. Given an array of integers, find the length and
location of the longest contiguous sequence of
equal values.
2. Bad shuffling. Suppose that you choose a random integer between 0
and N-1 in Shuffle.java instead of 0 and i.
Show that the resulting order is not equally likely to be one ot
the N! possibilities, even whenn N-3. Assuming
the elements are named A, B, and C, verify that all 6 outcomes are
possible, but that theu occur with the
following baised probabilities.
ABC ACB BAC BCA CAB CBA
4/27 5/27 6/27 4/27
5/27 3/27
3. Scheduling with deadline. Suppose that you have N tasks to
schedule. Each task takes 1 unit of time and has
a deadling by which time it is expected to finish. If a task is
not completed by its deadline, you pay a $1,000
fine. Find a schedule that minimizes the penalty. Hint: schedule
the tasks in order of their deadline, but don't
bother with any task that won't finish by its deadline.
4. Magic squares. Write a program MagicSquare.java that reads in an
odd integer N form the command line and prints our an N-by-N magic
square. the square contains each of the integers between 1 and N^2
exactly once, such that all row sums, column sums, and diagonal sums
are equal.
4 9 2 11 18 25 2 9
3 5 7 10 12 19 21 3
8 1 6 4 6 13 20 22
12 5 7 14 16
17 24 1 8 15
lastly,
5. US postal barcodes. The POSTNET barcode is used by the US Postal
System to route mail. Each decimal digit in the zip code is encoded
using a sequence of 5 short lines for use by scanners as follows:
Value Encoding
0 I I i i i
1 i i i I I
2 i i I i I
3 i i I I i
4 i I i i I
5 i I i I i
6 i I I i i
7 I i i i I
8 I i i I i
9 I i I i i
i = are small bar lines
I = are the larger ones
thank you so much for reading dude!.....hoping for your positive
response.....badly needing it for our midterms....
you could also email me at (e-mail address removed)....thanks a
lot!...... ^ ^
God bless dudes!!!!
thing...our instructor just gave us 15 pages copy all about Arrays and
of course problms about it...I have 5 problems and really don't know
how to solve these.....geezzz.....they suck!...=D...hhmmmm...anyway
i'm here for any help from you guys...
beginners like us really need ( I think) to have lectures by those who
should do it but I dunnot know why they're just giving us this stuff
without explanations...hhhhmmm....
nyways, here are the problems about Arrays....
1. Longest plateau. Given an array of integers, find the length and
location of the longest contiguous sequence of
equal values.
2. Bad shuffling. Suppose that you choose a random integer between 0
and N-1 in Shuffle.java instead of 0 and i.
Show that the resulting order is not equally likely to be one ot
the N! possibilities, even whenn N-3. Assuming
the elements are named A, B, and C, verify that all 6 outcomes are
possible, but that theu occur with the
following baised probabilities.
ABC ACB BAC BCA CAB CBA
4/27 5/27 6/27 4/27
5/27 3/27
3. Scheduling with deadline. Suppose that you have N tasks to
schedule. Each task takes 1 unit of time and has
a deadling by which time it is expected to finish. If a task is
not completed by its deadline, you pay a $1,000
fine. Find a schedule that minimizes the penalty. Hint: schedule
the tasks in order of their deadline, but don't
bother with any task that won't finish by its deadline.
4. Magic squares. Write a program MagicSquare.java that reads in an
odd integer N form the command line and prints our an N-by-N magic
square. the square contains each of the integers between 1 and N^2
exactly once, such that all row sums, column sums, and diagonal sums
are equal.
4 9 2 11 18 25 2 9
3 5 7 10 12 19 21 3
8 1 6 4 6 13 20 22
12 5 7 14 16
17 24 1 8 15
lastly,
5. US postal barcodes. The POSTNET barcode is used by the US Postal
System to route mail. Each decimal digit in the zip code is encoded
using a sequence of 5 short lines for use by scanners as follows:
Value Encoding
0 I I i i i
1 i i i I I
2 i i I i I
3 i i I I i
4 i I i i I
5 i I i I i
6 i I I i i
7 I i i i I
8 I i i I i
9 I i I i i
i = are small bar lines
I = are the larger ones
thank you so much for reading dude!.....hoping for your positive
response.....badly needing it for our midterms....
you could also email me at (e-mail address removed)....thanks a
lot!...... ^ ^
God bless dudes!!!!