Reference no: EM13674768
Assignment 1
Write a function, removeAt, that takes three parameters: an array of integers, the number of elements in the array, and an integer (say, index). The function should delete the array element indicated by index. If index is out of range or the array is empty, output an appropriate message. Assume that the array is unsorted.
Assignment 2
Write a program that creates three identical arrays, list1, list2, and list3 of 5000 elements. The program then sorts list1 using bubble sort, list2 using selection sort, and list3 using insertion sort and outputs the number of comparisons and item assignments made by each sorting algorithm.
Assignment 3
Assume that the nodes are in the usual info-link form. Use this list to answer Numbers 1 through 3. If necessary, declare additional variables.
Number 1
What are the effects, if any, of each of the following C++ statements?
a. trail->link ¼ NULL; delete last;
b. temp->link ¼ trail;
c. list->info ¼ 19;
d. current ¼ current->link; current->link ¼ temp->link;
Number 2
Mark each of the following statements as valid or invalid. If a statement is
invalid, explain why.
a. current ¼ list;
b. temp->link->link ¼ NULL;
c. trail->link ¼ 0;
d. *temp ¼ last;
e. list ¼ 75;
f. temp->link->info ¼ 75;
g. current->info ¼ trail->link;
h. *list ¼ *last;
i. current ¼ last;
j. cout << trail->link->link->info;
Number 3
What is the output of the following C++ code?
a. while (current != NULL) cout << current->info << " ";
current = current->link; cout << endl;
b. while (current != last) current = current->link;
cout << current->info << " "; cout << endl;
Assignment 4
Show what is produced by the following C++ code. Assume the node is in the usual info-link form with the info of the type int. (list, trail, and current are pointers of type nodeType.)
current = new nodeType; current->info = 72;
current->link = NULL; trail = current;
current = new nodeType; current->info = 46;
current->link = trail; list = current;
current = new nodeType; current->info = 52;
list->link = current; current->link = trail;
trail = current; current = new nodeType;
current->info = 91; current->link = trail->link;
trail->link = current; current = list;
while (current!= NULL)
Assignment 5
void mystery(queueType<int>& q)
{
stackType<int> s;
while (!q.isEmptyQueue())
{
s.push(q.front());
q.deleteQueue();
}
while (!s.isEmptyStack())
{
q.addQueue(2 * s.top());
s.pop();
}
}
Two stacks of the same type are the same if they have the same number of elements and their elements at the corresponding positions are the same. Overload the relational operator == for the class stackType that returns true if two stacks of the same type are the same; it returns false other-wise. Also, write the definition of the function template to overload this operator.
Blood pressure gauged on the upper arm
: Blood pressure is normally taken on the upper arm at the level of the heart. Assume, however, that a patient has his arms in a cast so you cannot take his blood pressure in the usual way.
|
Horizontal pipe carries easily flowing liquid with density
: A horizontal pipe carries a easily flowing liquid with density 1.19 × 103 kg/m3. At locations 1 and 2 along the pipe the diameters are 6.41 cm and 2.61 cm, respectively. Is the flow speed at location 2 higher or lower than at location 1?
|
Write about the cocking gass shortage
: Write about the cocking Gas's shortage in Jeddah at early February 2015. what are the reasons and what are the effects. try to explain as detail as you can
|
Two additional charges are fixed on the circle of compass
: A charge of -4.34C is fixed at the center of a compass. Two additional charges are fixed on the circle of the compass (radius = 0.122 m). The charges on the circle are -5.56C at the position due north and +6.30C at the position due east.
|
Write the definition of the function template to overload
: Write a function, removeAt, that takes three parameters: an array of integers, the number of elements in the array, and an integer - write the definition of the function template to overload this operator.
|
Why firms in monopolistically competitive markets
: One reason why firms in monopolistically competitive markets earn zero profit in the long run
|
What is coefficient of friction and acceleration of block
: A 2.5-kg block slides down a 25° inclined plane with constant acceleration. The block starts from rest at the top. At the bottom, its velocity is 0.65 m/s. The incline is 1.6 m long. What is the acceleration of the block?
|
What are the particles position and velocity
: A particle moving along the x-axis has its position explained by the function x =( 4.00 t3? 4.00 t+ 3.00 )m, where tis in s. At t= 3.00, what are the particle's (a) position, (b) velocity, and (c) acceleration?
|
The angular velocity of the earth is decreasing
: The angular velocity of the earth is decreasing, changing the length of a day. Through the year 2000 it took 0.548 s longer to complete 365 revolutions than in the year 1900. What was the average angular acceleration of the earth through this period?
|