Review quiz - PowerPoint PPT Presentation

1 / 23
About This Presentation
Title:

Review quiz

Description:

... statements in a client program correctly prints out the year of the variable ... E) The year cannot be printed by a client program. 4. Question #2 ... – PowerPoint PPT presentation

Number of Views:147
Avg rating:3.0/5.0
Slides: 24
Provided by: anne277
Category:
Tags: prints | quiz | review

less

Transcript and Presenter's Notes

Title: Review quiz


1
Review - quiz 2
  • CSC 2110 - Data Structures Abstraction
  • Spring/Summer 2001
  • Wayne State University
  • Instructor Anne-Marie Bosneag

2
Question 1
  • Examine the following class definition
  • class DateType
  • public
  • void Initialize(int, int, int)
  • int YearIs() const // returns year
  • int MonthIs() const // returns month
  • int DayIs() const // returns day
  • private
  • int year
  • int month
  • int day

3
Question 1
  • Which of the following statements in a
    client program correctly prints out the year of
    the variable day1 of type DateType?
  • A) cout ltlt day1.YearIs
  • B) cout ltlt YearIs(day1)
  • C) cout ltlt YearIs.day1
  • D) cout ltlt day1.YearIs()
  • E) The year cannot be printed by a client
    program.

4
Question 2
  • The member variables and functions declared
    following the word __(1)___ are accessible only
    to the class's member functions, while those
    declared following the word __(2)___ are
    accessible to the client program.
  • 1. A. public
  • B . private
  • 2. A. public
  • B. private

5
Question 3
  • The members of a struct are public by
    default.
  • A. True
  • B. False

6
Question 4
  • Reset and GetNextItem implement a
    transformer.
  • A. True
  • B. False

7
Question 5
  • The complexity of a linear search is O(N).
  • A. True
  • B. False

8
Question 6
  • The complexity of a binary search is O(logN).
  • A. True
  • B. False

9
Question 7
  • An exception is
  • A) an error
  • B) an unusual situation
  • C) something with which you do not agree

10
Question 8
  • What is the C statement that alerts the
    system that an exception has occured?
  • A) try
  • B) catch
  • C) throw
  • D) exception
  • E) finally

11
Question 9
  • The order of adding 1 to each element in a one
    dimensional array of N integers.
  • A) O(1)
  • B) O(logN )
  • C) O(N )
  • D) O(N logN )
  • E) O(N2 )

12
Question 10
  • The order of inserting an element into its
    place in an unsorted list implemented in an
    array.
  • A) O(1)
  • B) O(logN )
  • C) O(N )
  • D) O(N logN )
  • E) O(N2 )

13
Question 11
  • An array is
  • A. a fixed-sized structure the mechanism for
    accessing the structure is built into C.
  • B. a variable-sized, user-defined structure the
    mechanism for accessing the structure must be
    provided through functions.

14
Question 12
  • A list is
  • A. a fixed-sized structure the mechanism for
    accessing the structure is built into C.
  • B. a variable-sized, user-defined structure the
    mechanism for accessing the structure must be
    provided through functions.

15
Question 13
  • Fill in the blanks in the following function.
  • void SortedTypeDeleteItem(ListItemType
    item)
  • // Pre List contains valid data, sorted by key
    values.
  • // One and only one list item with the
    same key as item's is in the list.
  • // Post No list element has the same key as
    item the list is still sorted by key values.
  • void SortedTypeDeleteItem(ItemType item)
  • int location 0
  • while (item.ComparedTo(infolocation) !
    ___________)// 1
  • location
  • for (int index location 1 _________
    index) // 2
  • infoindex - 1 infoindex
  • ___________ // 3

16
Question 13 (cont)
  • 1. A LESS
  • B GREATER
  • C EQUAL
  • D 0
  • 2. A. index lt length
  • B. index lt length
  • C. index gt length
  • 3. A. length
  • B. length- -
  • C. nothing goes here

17
Question 14
  • Fill in the blanks in the following function.
  • void UnsortedTypeRetrieveItem(ItemType item,
    bool found)
  • // Pre Key member(s) of item is initialized.
  • // Post If found, item's key matches an
    element's key in the
  • // list and a copy of that element has
    been stored in item
  • // otherwise, item is unchanged.
  • bool moreToSearch
  • int location 0
  • found false
  • moreToSearch (location ________ length)
    // 1

18
Question 14 (cont)
while (__________________)
// 2 switch (item.ComparedTo(info
location)) case LESS case GREATER
location moreToSearch
(_____________) // 3
break case EQUAL found true
item info___________ //
4 break

19
Question 14 (cont)
  • 1. A lt
  • B lt
  • C
  • D gt
  • E gt
  • 2. A. moreToSearch !found
  • B. moreToSearch !found
  • C. moreToSearch found
  • D. moreToSearch found
  • 3. A. location gt length
  • B. length gt location
  • C. location lt length
  • 4. A. location 1
  • B. location
  • C. location - 1

20
Question 15
  • The syntax for overloading an operator in C
    is
  • A. the word operator followed by the symbol to
    be overloaded.
  • B. the operator to be overloaded followed by the
    word operator.
  • C. C doesn't let you overload operators.

21
Question 16
  • All the relational operators can be
    overloaded except for equality.
  • A. True
  • B. False

22
Question 17
  • A generic data type is one in which the
    operations are defined, but the types of items
    being manipulated are not.
  • A. True
  • B. False

23
Question 18
  • A constructor is explicitly called by the client
    program.
  • A. True
  • B. False
Write a Comment
User Comments (0)
About PowerShow.com