Docsity

Midterm Exam 3 for Data Structures, Algorithms and Generic Programming | COP 4530, Exams of Computer Science

Toggle sidebar
bg1
COP 4530 Term Exam 3 Name:
Fall 2001 SSN:
Professor Chris Lacher CS Username:
Score: /100
This test contains 5 questions on 2 pages. Each question is worth 20 points.
1. The following are possible operations for a position-oriented container class (a pContainer). Mark
each possibility with "D", "L", and/or "V" to show whether the operation is part of the public
interface of TDeque<T>,TList<T>, and/or TVector<T>. (In these operations, t represents an
object of type T, I represents an Iterator associated with the container, and n is an integer type. An
operation must have the correct "DLV" code for credit.)
PushBack(t) PushFront(t)
PopBack() PopFront()
Back() Front()
Insert(I,t) Remove(I)
Empty() Size()
SetSize(n) operator [] (n)
2. Complete the implementation of the following function that uses a local stack variable to reverse the
contents of the queue passed as a reference parameter: (Hint: use two loops.)
void Reverse (CQueue<T>& Q)
{
CStack<T> S;
}
3. Use a generic algorithm to copy n elements of the array A to the vector V. (You may assume that
V.Size() >= n. Only one line of code is needed.)
Page 1 of 2
All rights reserved. No part of this exam may be reproduced, stored in a retrieval system, or transmitted in any means without written permission
from the publisher or a license from Florida State University. This exam may not be distributed and is the academic property of the Department
of Computer Science, Florida State University.
pf2

Partial preview of the text

Download Midterm Exam 3 for Data Structures, Algorithms and Generic Programming | COP 4530 and more Exams Computer Science in PDF only on Docsity!

COP 4530 Term Exam 3 Name: Fall 2001 SSN: Professor Chris Lacher CS Username: Score: /

This test contains 5 questions on 2 pages. Each question is worth 20 points.

  1. The following are possible operations for a position-oriented container class (a pContainer). Mark each possibility with "D", "L", and/or "V" to show whether the operation is part of the public interface of TDeque, TList, and/or TVector. (In these operations, t represents an object of type T, I represents an Iterator associated with the container, and n is an integer type. An operation must have the correct "DLV" code for credit.)

PushBack(t) PushFront(t) PopBack() PopFront() Back() Front() Insert(I,t) Remove(I) Empty() Size() SetSize(n) operator [] (n)

  1. Complete the implementation of the following function that uses a local stack variable to reverse the contents of the queue passed as a reference parameter: ( Hint : use two loops.)

void Reverse (CQueue& Q) { CStack S;

  1. Use a generic algorithm to copy n elements of the array A to the vector V. (You may assume that V.Size() >= n. Only one line of code is needed.)

Page 1 of 2 All rights reserved. No part of this exam may be reproduced, stored in a retrieval system, or transmitted in any means without written permission from the publisher or a license from Florida State University. This exam may not be distributed and is the academic property of the Department of Computer Science, Florida State University.

COP 4530 Exam 1 Spring 2001

  1. Define a function class that converts a type char parameter, passed by reference, to lower case:

class MakeLowerCase {

  1. Use a MakeLowerCase object and a generic algorithm to convert all alpha characters in the deque D to lower case:

TDeque D; // code to define D goes here ... ... ... // convert all alpha in D to lower case // write your answer here (only two lines of code):

Page 2 of 2 All rights reserved. No part of this exam may be reproduced, stored in a retrieval system, or transmitted in any means without written permission from the publisher or a license from Florida State University. This exam may not be distributed and is the academic property of the Department of Computer Science, Florida State University.