1. No Profile Picture
Registered User
Devshed Newbie (0 - 499 posts)

Join Date
Feb 2011
Posts
6
Rep Power
0

#### Need help with pseudocode please

I have to calculate the maximum block in a binary number.
For ex:
Binary representation = 11111
Maximum block length = 5

Binary representation = 10111011
Maximum block length = 3

Above are the only 2 examples my professor gave.
"Compute the maximum block length of the binary
representation." This is what he said. I'm assuming this includes 0s as well. I really don't know how to go about it.
2. Maximum block
Can you define the term? I've never seen it before.
3. No Profile Picture
Devshed Novice (500 - 999 posts)

Join Date
Jan 2007
Location
The Crisp Packet!
Posts
603
Rep Power
153
Originally Posted by nomss
I have to calculate the maximum block in a binary number.
For ex:
Binary representation = 11111
Maximum block length = 5

Binary representation = 10111011
Maximum block length = 3

Above are the only 2 examples my professor gave.
"Compute the maximum block length of the binary
representation." This is what he said. I'm assuming this includes 0s as well. I really don't know how to go about it.
Firstly, as NormR has said, what is block length? There is no such thing as a block, let alone block lengths in binary representations. I assume your talking about maximum number of bytes or bits? But you'd have to clarify that.

Secondly, the title suggests you want pseudo code, not actual Java code? Is that correct? This perhaps (??) belongs in another forum then?
4. No Profile Picture
Registered User
Devshed Newbie (0 - 499 posts)

Join Date
May 2011
Posts
21
Rep Power
0
In pseudocode,

1. input binary number

2. Define variables cumulativeMax and currentMax as Int

3. for i = 1 to number.length //set up a loop to iterate
if (number.i) then
currentMax ++
else
currentMax = 0
end if
if (currentMax > cumulativeMax) Then
cumulativeMax = currentMax
end if
next

4. Output cumulativeMax

keep in mind, this is pseudocode, not intended to be a working program in any language, that is the fun part that you get to do, but the idea is above. I didn't want to make it too easy on you... It also assumes that your "block length" is referring to a sequence of on-bits represented by 1.
5. No Profile Picture
Contributing User
Devshed Newbie (0 - 499 posts)

Join Date
Nov 2010
Posts
120
Rep Power
158

#### look at his question

I worry some to think that this forum is for people who can program or at least might vhave a fighting chance of programmin one day, but to not know what a block is given the "EXAMPLE" set out in the question is to not be equiped with the tools necessary for the trade we programmers are supposed to be working in!

I would not have thought that I would be taking my hat off to one of our newest members for a correct pcode answer to what the "QUESTIONER'S PROFESSOR" was alluding to.

And that is " using a loop and counters - solve the following - for a given sequence of 1s and 0s calculate the largest number of consequutive 1s found therein"

I think its not good to have to spell that out!

But here to talk (as always)
Last edited by Incidentals; May 18th, 2011 at 05:18 PM.
6. No Profile Picture
Registered User
Devshed Newbie (0 - 499 posts)

Join Date
Feb 2011
Posts
6
Rep Power
0
I don't really understand as to what you're trying to say >< but I think I have the answer in the above post.