Computer Science Homework Solutions

Reading from a file in c++

I need to modify this code, instead of asking the user for the matrix, it will read the matrix from a file called Data.txt. The matrix must be 4x4.

Parsing Method

Need a program that will read as a string that will display the number of letters, number of digits, and the number of spaces in a message. The returned values must an integer. The program should use VB.NET.

C++ array

Consider the C++ array int arr[] = (-15, 5, 35, -19, -12, 17, -4); int arrSize = sizeof(arr)/sizeof(int); (a) Declare the list object intList that holds the integers from the array arr. (b) Declare the iterator iter for an integer list. (c) Initialize the iterator iter to the beginning of the list intList. (d) ...continues

C++ Trace the following code...

Trace the following code, and display the resulting elements in the list: int arr[] = (1, 2, 3, 4); int arrSize = sizeof(arr)/sizeof(int); list intList(arr, arr+arrSize); list::iterator iter = intList.begin(); int i; for (i=1; i <= arrSize; i++) intList.insert(iter++, i); Please provide a complete program i ...continues

Data Structures with C++ Using STL

What is the output from the following sequence of stack operations? stack intStack; int x, y = 3; intStack.push(8); intStack.push(9); intStack.push(y); x = intStack.top(); intStack.pop(); intStack.push(18); x = intStack.top(); intStack.pop(); intStackpush(22); while (!intStack.empty()) { y = intStack.top(); ...continues

Data Structures with C++ Using STL

Write a function template void stackClear (stack& s); that clears a stack s. Why is it critical that s be passed by reference? Please provide a complete program if it makes sense.

Data Structures with C++ Using STL

List the elements in the queue after each of the following operations: queue intQueue; intQueue.push(18); intQueue.push(2); intQueue.push(intQueue.front()); intQueue.push(intQueue.front()); intQueue.pop(); Please provide a complete program if it makes sense.

Data Structures with C++ Using STL

Declare a stack, queue, and priority queue of integers, as follows: stack s; queue q; priority_queue pq; Assume that you input the integer sequence 5 8 12 15 1 3 18 25 18 35 2 55 and insert each value into each container in the order given. What is the output of the following statements? while ( ...continues

Data Structures with C++ Using STL

Write a function template void n2front (queue& q, int n); that moves the nth element (counting from the front, which is element 1) of the queue to the front, leaving the order of all other elements unchanged. The function throws the rangeError exception if n < 1 or n> q.size(). The figure illustrates the ac ...continues

Data Structures with C++ Using STL

Linked Lists. See attached file for full problem description.

Browse