Perry Campbell

Greenhorn
+ Follow
since May 22, 2012
Perry likes ...
Python Firefox Browser Java
Cows and Likes
Cows
Total received
0
In last 30 days
0
Total given
0
Likes
Total received
0
Received in last 30 days
0
Total given
2
Given in last 30 days
0
Forums and Threads
Scavenger Hunt
expand Ranch Hand Scavenger Hunt
expand Greenhorn Scavenger Hunt

Recent posts by Perry Campbell

So I should look at it as N * the geometric series of (1/3)^i from i=0 to infinity which can be summed up as (1 / (1-x)). x in this case would be 1/3 which is between 0 and 1 (a requirement for geometric series I think) so then I end up with N * (1 / (1-(1/3)) which simplifies to N*(3/2) which is just O(n)? I had to brush up on my geometric series stuff, but I think I got it now. Thanks!
8 years ago
Thanks for the explanation. That makes sense. Reminds me of limits in calculus =).
8 years ago
Although I know that the Big O of the following code is O(n) I'm a bit lost as to why... any help towards understand would be much appreciated! At first glance to me it looks like the outer loop would be O(log n) and the inner loop looks like O(n). My guess is the catch is somewhere in the condition check for the inner loop.

8 years ago
I wanted to wait until after this assignment was due to post my solution so none of my classmates copy it. The basic idea turned out to be really simple. I start at the beginning of a huge binary string and move one place at a time. Ignoring the significant bit and starting with a string = "0" I repeat the following procedure for each time through the loop. No matter what I multiply the result string by 2. If the bit is an ON bit I add 1 as well. That's it. Here is my code for converting a 2s compliment binary string to a decimal string (which I'm sure could use some improvement...but it works!):



Thanks again for all the help!
-Perry
8 years ago
I'm running off to an integral calculus class at the moment but I wanted to get a quick reply in here for clarification. The assignment is to write a BigInt class (http://seattlecentral.edu/faculty/flepeint/java143/hw5.html). I think that the answer may have been touched on here after a quick read through, which is to just do it manually as you would on paper while storing results as a string. So if I had a bit that represents 2^100, manually calculate 2*2*2*2...using strings to hold the large numbers, and then ultimately add up all the results (2^100+2^68+2^12 or something along those lines, again manually with strings) to form the needed decimal. I'll spend a couple hours with this after my math class today and will post my successes/failures here =). I have a couple hours in between my calculus class and my programming lab today and I'll make sure to ask my professor if we're on the right track. I think we very well may be right on, but who knows, maybe there is a more elegant way?

Thank you all so much for your help (and sorry for the rushed post here)! I look forward to solving this problem and sharing my results with y'all.

Kind Regards,
-Perry
8 years ago
So I've been poking around these parts (and google) looking for any way to convert a huge binary string (hundreds of digits) back into decimal. I've been searching for a couple hours with no luck so I figure it's time for a forum post. I've found quite a bit on binary/decimal conversion, but nothing to deal with Huge binary/decimal number conversion without using BigInt. The big catch for my problem is I can't use any BigInt/BigEtc.. types. Thus far I've been able to write a program to convert a huge int to binary which I've stored in a doubly linked list so I can easily do binary multiplication, etc. I'm just plain stuck on how to convert a huge binary number to decimal again. I know I can't store an integer like 2^200 in an int (or a double or a long) and I'm not allowed to use BigInt or anything like it for this assignment. I should probably mention that I'm working with signed integers in 2s compliment. Any help (even a good push!) would be much appreciated. Being stuck is no fun =(.

This is my first post here, but seeing as I'm a CS Student (and passionate about my work!), I hope to become a part of this community to better my knowledge of Java and hopefully help other kind souls on their pursuit of knowledge as well . Thanks in advance for your time, I promise it wont be wasted!
8 years ago