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.

Computer Science & Information Technology

You might also like to view...

Declare variable sum of type int and initialize it to 0.

Write a Java statement to accomplish each of the tasks.

Computer Science & Information Technology

A(n) ________ list is sometimes called an ordered list

Fill in the blank(s) with correct word

Computer Science & Information Technology

Log files can point to ports, machines, or other vulnerable computers through which hackers can gain entry. These entry points are known as ____.

A. screens B. logged areas C. intrusions D. holes

Computer Science & Information Technology

Which of the following are types of flash memory cards?

A. CompactFlash B. Memory Stick C. Sandisk D. Secure Digital

Computer Science & Information Technology