Thread: Bit level algorithm help

  1. #1
    Registered User
    Join Date
    Feb 2013
    Posts
    13

    Unhappy Bit level algorithm help

    I know this is the video game section but it also said algorithms so I hope this post is ok...
    I am having a lot of trouble understanding pseudocode algorithms in my intro Comp Sci class. I understand what while, set etc means but the way my prof uses the variables (i.e., i=1, output[i] = b[i + 1] etc) confuses me way too much. Here is the algorithm:
    i'll put my comments in bold
    input: two 4-bit binary strings a (0011) and b (1010)
    output: one 4-bit binary string output
    1 Set i = 1 this is a control variable to limit us to 4 movements?
    2 while i<4 so while we are under 4 moves right, we do the following?
    3 [I]output= b[i + 1] output is italicized like in instructions at top, so this line is giving me the first digit for the single 4-bit string in our final output correct? is this first loops only concerned with the b string? is nothing changing in the a string yet?

    4 Set i = i + 1 now we move onto the next process?
    5 Set output[4] = 1 why did we jump to output4?
    6 Set i = 1 why are we putting i back to 1??
    7 while i <= 4
    8 [I]output= [I]output AND (NOT(a[i])) which ith are they talking about in the two outputs? and which a[i] are they talking about?
    9 Set i = i + 1
    10 Set tmp = output[4] I really have no idea what this means
    11 Set output[4] = output[3] nor do i get why we go back and forth between 3 and 4
    12 Set output[3] = tmp
    13 Print output

    So that is it... This is what I understand of it or at least what I think I understand of it... I am not a comp sci major but I really want to understand this stuff. I am not the only one in the class struggling like this... the prof is nice but he really really does not explain stuff very well. He kind of assumes everyone already gets it and does not go into detail. The lecture is invaded by 1000 questions constantly and I have been learning more researching on youtube and google than in the class. We also have no textbook so I have nothing to refer to for questions on these weird pseudocode algorithms

  2. #2
    and the hat of int overfl Salem's Avatar
    Join Date
    Aug 2001
    Location
    The edge of the known universe
    Posts
    39,660
    pseudocode bit level help
    We don't do cross-posting or double posting.
    If you dance barefoot on the broken glass of undefined behaviour, you've got to expect the occasional cut.
    If at first you don't succeed, try writing your phone number on the exam paper.

Popular pages Recent additions subscribe to a feed

Similar Threads

  1. Low Level I/O
    By DickArmy in forum C Programming
    Replies: 2
    Last Post: 10-31-2009, 01:26 PM
  2. Level-Up
    By nickodonnell in forum Game Programming
    Replies: 7
    Last Post: 10-02-2005, 02:28 AM
  3. should I go up a level
    By algi in forum Windows Programming
    Replies: 1
    Last Post: 12-07-2004, 04:59 PM
  4. C++ to the next level
    By Daggie in forum C++ Programming
    Replies: 7
    Last Post: 02-14-2003, 07:43 AM
  5. Low-Level and High-level ::: C-style And C++ Style
    By kuphryn in forum C++ Programming
    Replies: 2
    Last Post: 12-22-2001, 05:05 PM

Tags for this Thread