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 = 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 I really have no idea what this means
11 Set output = output nor do i get why we go back and forth between 3 and 4
12 Set output = 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