Write a program that creates three identical arrays|Software Engineering

Write a program that creates three identical arrays|Software Engineering

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.

Order from us and get better grades. We are the service you have been looking for.