Sale!

COP 4530 Homework 5

$30.00

Category:

COP 4530 Homework 5
Exercises 9.4
For Exercises 1-11, assume that the following declarations have been made:
vector<int> number,
v(10,20),
w(10);
int num;
Assume also that, for exercises that involve input, the following values are entered:
99 33 44 88 22 11 55 66 77 -1
Describe the contents of the given vector after the statements are executed.
3. for (;;) {
cin >> num;
if (num < 0) break;
number.push_back(num);
}
For Exercises 5-11, assume that the loop in Exercise 3 has been executed.
10. vector<int>::iterator iter = number.begin();
while (*iter > 25) {
number.erase(iter);
iter++;
}
11. for (vector<int>::iterator iter = number.begin();
iter != number.end();
iter++)
w.push_back(*iter+1);
Page 1 of 4
COP 4530 Homework 5
Exercises 11.1
2. Write an algorithm or code segment for searching a circular linked list for a given item.
3. Proceed as in Exercise 2, but assume that the list is ordered so that the elements are in ascending order.
Page 2 of 4
COP 4530 Homework 5
4. Write an algorithm or code segment for locating the nth successor of an item in a circular linked list (the nth
item that follows the given item in the list).
6. The shuffle-merge operation on two lists was defined in Exercise 9 of Section 6.4. Write an algorithm to shufflemerge two circular-linked lists. The items in the lists are to be copied to produce the new circular-linked lists;
the original lists are not to be destroyed.
Page 3 of 4
COP 4530 Homework 5
7. Proceed as in Exercise 6, but do not copy the items. Just change links in the two lists (thus destroying the
original lists) to produce the merged list.
Page 4 of 4

Reviews

There are no reviews yet.

Be the first to review “COP 4530 Homework 5”

Your email address will not be published.