CPTS 121 FINAL EXAM WITH CORRECT ACTUAL QUESTIONS AND
CORRECTLY WELL DEFINED ANSWERS LATEST ALREADY
GRADED A+
recursion - ANSWER-The process in which a function calls itself either directly or indirectly
through another function
base case - ANSWER-tells when the recursion has to stop. For example, let us take factorial
function. The base case here is when n=0 or when n=1; and after every recursive call to fact()
function n value reduced by 1 and finally reaches base case.
recursive step - ANSWER-the line that calls the recursive function
recursive function - ANSWER-A function that calls itself
function call stack - ANSWER-(often referred to just as the call stack or the stack) is responsible
for maintaining the local variables and parameters during function execution.
what is a bit - ANSWER-Bit is derived from binary digit - A binary digit or bit has two possible
values; 0 or 1
nibble - ANSWER-A sequence of 4-bits
One example of a nibble of data is 11112 This is the number 15 in decimal
byte - ANSWER-A sequence of 8-bits
One example of a byte of data is 0100 00012 This is the number 65 in decimal It's also the
ASCII value for 'A'
, How can we determine if a number is even or odd without using the mod (%) operator? -
ANSWER-If the least significant bit (lsb) is 1 the number is odd, if its 0 the number is even
How do we multiply and divide by powers of 2 without using the multiplication (*) and division (/)
operators? - ANSWER-Recall multiplication and division is expensive and resource intensive
o Shift all bits in a number to the left by 1 to multiply by 2
o Shift all bits in a number to the right by 1 to divide by 2
bitwise negation - ANSWER-~
0 -> 1 or 1 -> 0, where -> represents "becomes"
bitwise left shift - ANSWER-<<
means shift each bit in the number to the left by two positions and rotate in zeros - The result is
11002 if only a nibble of memory is available; otherwise it's 1011002
bitwise right shift - ANSWER->>
means shift each bit in the number to the right by one position and rotate in zeros - The result is
01012; note the lsb is lost in the result
bitwise and - ANSWER-&
10102 & 00112; means AND each bit in each corresponding position - The result is 00102
bitwise or - ANSWER-|
10102 | 00112; means OR each bit in each corresponding position - The result is 10112
bitwise xor - ANSWER-^
10102 ^ 00112; means XOR each bit in each corresponding position - The result is 10012
what is a command line argument - ANSWER-
CORRECTLY WELL DEFINED ANSWERS LATEST ALREADY
GRADED A+
recursion - ANSWER-The process in which a function calls itself either directly or indirectly
through another function
base case - ANSWER-tells when the recursion has to stop. For example, let us take factorial
function. The base case here is when n=0 or when n=1; and after every recursive call to fact()
function n value reduced by 1 and finally reaches base case.
recursive step - ANSWER-the line that calls the recursive function
recursive function - ANSWER-A function that calls itself
function call stack - ANSWER-(often referred to just as the call stack or the stack) is responsible
for maintaining the local variables and parameters during function execution.
what is a bit - ANSWER-Bit is derived from binary digit - A binary digit or bit has two possible
values; 0 or 1
nibble - ANSWER-A sequence of 4-bits
One example of a nibble of data is 11112 This is the number 15 in decimal
byte - ANSWER-A sequence of 8-bits
One example of a byte of data is 0100 00012 This is the number 65 in decimal It's also the
ASCII value for 'A'
, How can we determine if a number is even or odd without using the mod (%) operator? -
ANSWER-If the least significant bit (lsb) is 1 the number is odd, if its 0 the number is even
How do we multiply and divide by powers of 2 without using the multiplication (*) and division (/)
operators? - ANSWER-Recall multiplication and division is expensive and resource intensive
o Shift all bits in a number to the left by 1 to multiply by 2
o Shift all bits in a number to the right by 1 to divide by 2
bitwise negation - ANSWER-~
0 -> 1 or 1 -> 0, where -> represents "becomes"
bitwise left shift - ANSWER-<<
means shift each bit in the number to the left by two positions and rotate in zeros - The result is
11002 if only a nibble of memory is available; otherwise it's 1011002
bitwise right shift - ANSWER->>
means shift each bit in the number to the right by one position and rotate in zeros - The result is
01012; note the lsb is lost in the result
bitwise and - ANSWER-&
10102 & 00112; means AND each bit in each corresponding position - The result is 00102
bitwise or - ANSWER-|
10102 | 00112; means OR each bit in each corresponding position - The result is 10112
bitwise xor - ANSWER-^
10102 ^ 00112; means XOR each bit in each corresponding position - The result is 10012
what is a command line argument - ANSWER-