gregbo (gregbo) wrote,

  • Mood:

linking ideas and concepts

Now that the piano recital's behind me, I can start catching up on some of the other journal
entries I wanted to write. This concerns a phone interview I had not too long ago in which I
was asked to give an algorithm for determining whether a number is a power of two. I was able
to think of one that runs in linear time (in the number of bits of the number) by starting off
with 1 and repeatedly left shifting it until you either get the number or hit the maximum
integer. The interviewer didn't ask for a faster algorithm.

I did try to think of a faster algorithm. Two ideas came to me. A power of two in binary
representation will have a one followed by only zeros (unless it's the number 1). If you
subtract one from it, you get a binary representation with all ones. I didn't link these two
concepts together to come up with a faster algorithm (bitwise ANDing the two numbers and
checking if the result is zero). I had actually seen this solution before, but didn't
remember it. But I had enough information to give a better answer without needing to remember
it, if only I'd been able to link the concepts together. (BTW, I read on one of the interview
practice sites that an interviewer was displeased when an interviewee gave a linear time
algorithm for this question.)

In general, this seems to be part of my problem solving problem. I'm able to get most of the
way towards a good solution, but will hit a point where I get stuck, even if I've come up with
enough information that can be linked or combined to give a great answer. So I have to resort
to a correct (but inelegant) answer. I think if I had been more consistent in linking ideas
and concepts in this way, I would have done better on tests in undergrad and grad school.

Some problem solving books I've read suggest breaking cryptograms. Looking for patterns and
rearranging letters supposedly helps the exercise the mind. When I was a kid, I used to have
puzzle books that featured anagrams, cryptograms, and other types of word puzzles. I remember
enjoying working on them, although I don't know offhand why I stopped. I think I spent most
of my time on them during summers before I started working summer jobs. Quite possibly, I
didn't have time for them any more while working.

  • (no subject)

    About three years ago to the date, I started noticing some snoulder problems. They turned into full-blown impingement syndrome, which took me quite…

  • (no subject)

    My shoulder is feeling much better. There's a bit of pain and stiffness when I wake up, but after a while it's hardly noticeable. I can do most of…

  • (no subject)

    My doctor diagnosed my shoulder problem as impingement syndrome, which is an RSI injury. She thinks it was probably aggravated by carrying my…

  • Post a new comment


    default userpic

    Your reply will be screened

    Your IP address will be recorded 

    When you submit the form an invisible reCAPTCHA check will be performed.
    You must follow the Privacy Policy and Google Terms of use.