English Deutsch Français Italiano Español Português 繁體中文 Bahasa Indonesia Tiếng Việt ภาษาไทย
All categories

Trying to write Pseudocode for a Java program and then create the program. Link is provided below. Thanks.

http://www.cs.unt.edu/~irby/Courses/1040/Assignments/assignment3.html

2007-02-08 14:22:34 · 2 answers · asked by azhi_saleem 1 in Computers & Internet Programming & Design

2 answers

Well, off the top of my head...

ABCD is the big number, E is the modulus.
Let- ABCD / E = ABC'
Let- ABCD % E = D'
IF ABC' > 0 (integer math) then call the routine recursively,
with ABC' and E
D' = D' + D" (returned from recursive call)

ELSE D' = D'

return D'

2007-02-11 16:34:36 · answer #1 · answered by Alan 6 · 0 0

It's asking you to calculate the winner of an election in approximately n number of steps, if your given and n-length array. The hint is that you should have a function that names the winning candidate has more than n/2 votes and false if each other candidate obtained less than n/2 votes. This is slightly confusing, but the direction I would head would be to initialize a counter for each vote in the n-length array. compare the counter to n/2 and break the loop when a candidate reaches more than n/2. What i get is that your for loop should be no more than n/2 + 1 cycles. Good Luck!

2016-05-23 23:35:07 · answer #2 · answered by Anonymous · 0 0

fedest.com, questions and answers