Answer:
The solution is as follows.
class LFilters implements Lock {
int[] lvl;
int[] vic;
public LFilters(int n, int l) {
lvl = new int[max(n-l+1,0)];
vic = new int[max(n-l+1,0)];
for (int i = 0; i < n-l+1; i++) {
lvl[i] = 0;
}
}
public void lock() {
int me = ThreadID.get();
for (int i = 1; i < n-l+1; i++) { // attempt level i
lvl[me] = i;
vic[i] = me;
// rotate while conflicts exist
int above = l+1;
while (above > l && vic[i] == me) {
above = 0;
for (int k = 0; k < n; k++) {
if (lvl[k] >= i) above++;
}
}
}
}
public void unlock() {
int me = ThreadID.get();
lvl[me] = 0;
}
}
Explanation:
The code is presented above in which the a class is formed which has two variables, lvl and vic. It performs the operation of lock as indicated above.
making a selection in the Save in: box.<span>
</span>
Answer:
-3874₁₀ = 1111 1111 1111 1111 1111 1111 1101 1110₂
Explanation:
2's complement is a way for us to represent negative numbers in binary.
To get 2's complement:
1. Invert all the bits
2. Add 1 to the inverted bits
Summary: 2's complement = -N = ~N + 1
1. Inverting the number
3874₁₀ = 1111 0010 0010₂
~3874₁₀ = 0000 1101 1101₂
2. Add 1 to your inverted bits
~3874₁₀ + 1 = 0000 1101 1101₂ + 1
= 0000 1101 1110₂
You can pad the most signigicant bits with 1's if you're planning on using more bits.
so,
12 bits 16 bits
0000 1101 1110₂ = 1111 0000 1101 1110₂
They asked for double word-length (a fancy term for 32-bits), so pad the left-most side with 1s' until you get a total of 32 bits.
32 bits
= 1111 1111 1111 1111 1111 1111 1101 1110