Skip to content
VUBuddy

CS301 Midterm Past Paper Fall 2003 Session 1

Data Structures PDF 257 KBUpdated 23 Oct 2026
Midterm past paper CS301 Midterm Past Paper Fall 2003 Session 1 PDF 257 KB
vubuddy.com
Type
Midterm past paper
Course
CS301 Data Structures
Size
PDF 257 KB
Updated
23 Oct 2026
Free download 0 of 3 used today
Download free · 257 KB

You get 3 free files a day on the website. Add the Chrome extension for 30 a day.

Unlimited downloads in the Android app Get it free on Google Play

Preview text

Text from pages 1, 2, 3 of 10. Download the file for all 10 pages.

MIDTERM EXAMINATION · SEMESTER FALL 2003 · CS301-DATA STRUCTURE · Instructions

  1. The duration of this examination is 60 Mins.
  2. This examination is closed book, closed notes, closed neighbors; any one found cheating will get no grade.
  3. Unless stated otherwise, all questions carry a single mark.
  4. Most, but not all, of the examination consists of multiple-choice questions. Choose only one choice as your

Answer: a. If you believe that two (or more) of the choices are the correct ones for a particular question, choose the best one. b. On the other hand, if you believe that all of the choices provided for a particular question are the wrong ones, select the one that appears to you as being the least wrong.

  1. You are allowed to use any development environment like Dev C++ etc.

Q1. Marks: 2

Given the class declaration · class MyClass · public: · void Func(); · private: · int n;

what notation does the body of Func use to assign the value 3 to n?

(a) · n = 3; · (b) · MyClass.n = 3; · (c) · MyClass::n = 3; · (d) · someObject.n = 3; · (d)

It can’t be done–n is private.

Q2. Marks: 2

Suppose that the class declaration of SomeClass includes the following function prototype.

bool LessThan( SomeClass anotherObject );

Which of the following tests in the client code correctly compares two class objects alpha and beta?

(a) · if (alpha < beta) · (b) · if (alpha. LessThan(beta)) · (c) · if (LessThan(alpha, beta)) · (d) · if (alpha. LessThan.beta) · (e) · if (LessThan(alpha).beta)

Q3. Marks: 2

When should you use a const reference parameter?

(a)

Whenever the data type might be many bytes.

(b)

Whenever the data type might be many bytes, the function changes the parameter within its body, and you do NOT want these changes to alter the actual argument.

(c)

Whenever the data type might be many bytes, the function changes the parameter within its body, and you DO want these changes to alter the actual argument.

(d)

Whenever the data type might be many bytes, and the function does not change the

parameter within its body.

Q4. Marks: 2

The Bag ADT is like the List ADT. The Bag ADT does not store items in any particular order and it allows duplicates. Suppose that the Bag class is efficiently implemented with a fixed array with a capacity of 4000. Insert appends the new item at the end of the array. Choose the best description of b’s member variables size (count of items in the bag) and data (the array that holds the actual items) after we execute these statements:

Bag b; · b.insert(5); · b.insert(4); · b.insert(6);

What will be the values of b.size and b.data after the statements?

(a)

b.size is 3, b.data[0] is 4, b.data[1] is 5, b.data[2] is 6 · (b) · b.size is 3, b.data[0] is 5, b.data[1] is 4, b.data[2] is 6 · (c) · b.size is 3, b.data[0] is 6, b.data[1] is 4, b.data[2] is 5 · (d) · b.size is 3, b.data[0] is 6, b.data[1] is 5, b.data[2] is 4

Q5. Marks: 2

The operation for removing an entry from a stack is traditionally called:

(a) · delete · (b) · peek · (c) · pop · (d) · remove

Q6. Marks: 2

Which of the following stack operations could result in stack underflow?

(a) · is empty · (b) · pop · (c) · push · (d) · Two or more of the above answers

Q7. Marks: 5

Consider the following pseudo code: · declare a stack of characters · while ( there are more characters in the word to read ) · read a character · push the character on the stack · while ( the stack is not empty ) · pop a character off the stack · write the character to the screen

All CS301 files →
CS301 Data Structures All CS301 handouts, past papers, quizzes and MCQs in one place. Open course page

Get more out of VUBuddy, for free

Android app Free on Google Play
  • Unlimited downloads
  • The explanation behind every MCQ answer
  • Study offline on slow data
Get the Android app
Chrome extension Free on the Chrome Web Store
  • 30 downloads a day instead of 3
  • Sign in and buy Pro Semester here
Add to Chrome

One Pro Semester membership works in both the extension and the app.