Answer the following statements true (T) or false (F)
1. Suppose the swapValues template is instantiated as follows:
```
int x = 2, y =3;
swapValue(x, y);
// use x and y
```
and
```
double d= 3.0, f=4.5;
swap(d, f);
// use x and y
```
Then the compiler generates code for two copies of the swapValues template.
2. Insertion into a linked list takes the same number of operations no matter where the insertion occurs
3. A stack is a first-in-first-out data structure.
4. A queue is first-in-first-out data structure.
5. Most applications that use a stack will store a struct or class object on the stack.
1. True
The compiler generates code for one function of every type for which you instantiate the template. There are instantiations for two different types here.
2. True
Given a pointer to the node in the list prior to position of the new node. In addition to allocation, it will require two operations to insert a node into this list. This is independent of the position in the list.
3. False
The correct description is first-in-last-out. A stack is unfair. Data items are retrieved in opposite order of arrival.
4. True
A queue is fair. Entries are serviced and removed from the queue in the order of arrival.
5. True
The struct stored on the stack to store data on the stack. Such a struct is called a stack frame.
You might also like to view...
The Convert Text to Table feature can be accessed through a icon found on the:
A) Insert tab. B) Page Layout tab. C) Home tab. D) Review tab.
Develop an application that allows a user to decrypt a secret message (a string of numbers). The user should enter each number of the message one at a time in a JTextField. When the Decrypt JButton is clicked, the number should be decrypted to a letter. That letter should then be appended to the Decrypted message: JTextField. When the user enters the numbers 39, 79, 79, 68, 0, 55, 79, 82, 75, 1 in order, your application should appear as in Fig. 14.19.
a) Copying the template to your working directory. Copy the C:Exam- plesTutorial14ExercisesDecryption directory to your C:SimplyJava direc- tory.
b) Opening the template file. Open the Decryption.java file in your text editor.
c) Adding an instance variable. After the last GUI component is declared (line 18), add a declaration for a private String named message which will hold the decrypted message. Initialize message to the empty string. Use one line for a com- ment.
d) Storing the user input. Add code in the decryptJButtonActionPerformed method that will store the user input in an int variable named encryptedLetter. The rest of the code you will add in this exercises should be placed in the decryptJButtonAc- tionPerformed method.
e) Testing the user input. Your application should only accept user input in the range 0 to 94. Add an if statement that will test whether the user’s input is in the accepted range of values.
f) Decrypting the input. Add