Answer:
- import java.util.ArrayList;
- public class Main {
-
- public static void main(String[] args) {
- ArrayList<String> strList =new ArrayList<String>();
- strList.add("to");
- strList.add("be");
- strList.add("or");
- strList.add("not");
- strList.add("to");
- strList.add("be");
- strList.add("hamlet");
-
- swapPairs(strList);
- System.out.println(strList);
- }
-
- public static void swapPairs(ArrayList<String> list){
- for(int i=0; i < list.size()-1; i+=2){
- String temp = list.get(i);
- list.set(i, list.get(i+1));
- list.set(i+1, temp);
- }
- }
- }
Explanation:
Firstly, let's create a method swapPairs that take one ArrayList (Line 18). In the method, use a for-loop to traverse through each item in the ArrayList and swap the items between the current items at index-i and at index-i+1 (Line 19-22). The index-i is incremented by two in next loop and therefore the next swapping will proceed with third and fourth items and so forth.
In the main program, create a sample ArrayList (Line 5-12) and then test the method (Line 14) and print the output (Line 15). We shall get [be, to, not, or, be, to, hamlet].
The question given is incomplete and by finding it on internet i found the complete question as follows:
Direct Mapped Cache.
Memory is byte addressable
Fill in the missing fields based upon the properties of a direct-mapped cache. Click on "Select" to access the list of possible answers Main Memory Size Cache Size Block Size Number of Tag Bits 3 1) 16 KiB 128 KiB 256 B 20 2) 32 GiB 32 KiB 1 KiB 3) 64 MiB 512 KiB 1 KiB Select] 4 KiB 4) 16 GiB 10 Select ] Select ] 5) 10 64 MiB [ Select ] 6) Select] 512 KiB 7
For convenience, the table form of the question is attached in the image below.
Answers of blanks:
1. 3 bits
2. 20 bits
3. 64 MB
4. 16 MB
5. 64 KB
6. 64 MB
Explanation:
Following is the solution for question step-by-step:
<u>Part 1:</u>
No. of Tag bits = No. of bits to represent
Tag bits = Main memory - cache size bits -------- (A)
Given:
Main memory = 128 KB =
Cache Memory = 16 KB =
Putting values in A:
Tag bits = 17 - 14 = 3 bits
<u>Part 2:</u>
Tag bits = Main memory - cache size bits -------- (A)
Given:
Main memory = 32 GB =
Cache Memory = 16 KB =
Putting values in A:
Tag bits = 35 - 15 = 20 bits
<u>Part 3:</u>
Given:
Tag bits = 7
Cache Memory = 512 KB =
So from equation A
7 = Main Memory size - 19
Main Memory = 7 + 19
Main memory = 26
OR
Main Memory =
<u>Part 4:</u>
Given that:
Main Memory Size =
Tag bits = 10
Cache Memory Bits = 34 - 10 = 24
Cache Memory Size =
<u>Part 5:</u>
Given that:
Main Memory Size = 64 MB =
Tag bits = 10
Cache Memory Bits = 26 - 10 = 16
Cache Memory Size =
<u>Part 6:</u>
Cache Memory = 512 KB =
Tag Bits = 7
Main Memory Bits = 19 + 7 = 26
Main Memory size =
i hope it will help you!
Answer:
In which drawer can yu set certain lights t light up n yur micr:bit?
Explanation:
Answer: Predetermined Overhead Rate, Estimated Manufacturing Overhead and Annual Activity Level.
Explanation:
Generally speaking, manufacturing overhead is applied to production by means of a predetermined overhead rate, which is computed under the general formula of dividing estimated overhead rate by some measure of the annual activity level.
A predetermined overhead rate is usually calculated at the beginning of an accounting period. It is calculated by dividing the estimated manufacturing overhead by an activity driver (e.g machine hours).