Data Structures and Algorithms Mid-Term

0.0(0)
studied byStudied by 2 people
full-widthCall with Kai
GameKnowt Play
learnLearn
examPractice Test
spaced repetitionSpaced Repetition
heart puzzleMatch
flashcardsFlashcards
Card Sorting

1/101

encourage image

There's no tags or description

Looks like no tags are added yet.

Study Analytics
Name
Mastery
Learn
Test
Matching
Spaced

No study sessions yet.

102 Terms

1
New cards

A one dimensional array data[4] has a base address 2222 and each element takes one location. What is the address of the fourth element?

2225

2
New cards

A record is declared as follows: The first letter in the first name is at location 1000, each letter takes one location, and an integer takes two locations. What is the beginning address of age?

1030

3
New cards

C++ does not have any built-in exceptions.

False

4
New cards

Client code can directly access the private members of the base class but derived code cannot.

False

5
New cards

Code that can cause an exception should be enclosed within a try clause.

True

6
New cards

Exception handlers are enclosed within a catch clause.

True

7
New cards

Exceptions must be handled within the function in which they occur.

False

8
New cards

In C++, if class X is a base class of class Y, then Y cannot directly access X's private data.

True

9
New cards

Inheritance is a language mechanism by which one class acquires data and operations of another class.

True 

10
New cards

O(1) is called constant time.

True

11
New cards

O(N) is called log time.

False

12
New cards

O(N*N) is called quadratic time

True

13
New cards

O(N*N) is called quadratic time

False

14
New cards

The OOP term "instance variable" corresponds to the C++ term "class object."

False

15
New cards

The file containing the definitions of the member functions of class DateType is called the ______ file.

implementation

16
New cards

The following statement means that any subsequent use of GetData without qualification refers to myNames::GetData: using myNames::GetData.

True

17
New cards

The logical view of a data structure is associated with:

What?

18
New cards

The member variables and functions declared following the word "______" are accessible to the client program.

public

19
New cards

The members of a class are public by default.

False

20
New cards

Containment is a mechanism by which an internal data member of one class is defined to be an object of another class type.

True

21
New cards

In C++, a derived class's constructor is executed before the base class constructor is executed.

False

22
New cards

Derived class code can directly access the private members of the base class but client code cannot.

False

23
New cards

Reset and GetNextItem implement an iterator

True

24
New cards

using myNames::GetData is a using directive.

False

25
New cards

What is the order of adding 1 to each element in a one dimensional array of N integers?

O(N)

26
New cards

What is the order of adding 10.0 to each element in a one-dimensional array of N real numbers?

O(N)

27
New cards

When a class member function is a binary operation, how are the operands specified?

One operand is passed to the member function and the second is the class instance to which the function is applied.

28
New cards

When writing the code to define a member function, the name of _____ must precede the function name with the _____ operator in between.

the class, ::

29
New cards

using myNames::GetData is a using declaration.

True

30
New cards

using namespace myName is a using directive.

True

31
New cards

A program that includes the file containing a class declaration is called a ________ program of the class.

Client

32
New cards

A program that sets up the testing environment for a subprogram is called a:

test driver

33
New cards

All arrays in C++ are passed as ____________ parameters.

reference

34
New cards

An assertion that is always true is called a:

loop invariant

35
New cards

Arrange the following types of tests in chronological order: 1. integration, 2. regression, 3. acceptance, 4. unit

4, 1, 3, 2

36
New cards

Black-box testing is based on the types of the parameters.

False

37
New cards

Bottom-up testing requires drivers

False

38
New cards

A code segment compiles and prints either the value of count or "Count is equal to 10."

True

39
New cards

Clear-box testing is based on the types of the parameters.

False

40
New cards

Complete black-box testing is feasible

False

41
New cards

Minimum number of test cases needed to adequately test a function Triangle.

8

42
New cards

Software engineering vs software process:

Software process is the process of analyzing, designing, coding, testing, and maintaining software. Software engineering is a disciplined approach to designing and producing software efficiently and correctly.

43
New cards

Program verification

Are we building the product right?

44
New cards

program validation

Are we building the right product?

45
New cards

Type use example: aBird = Birds(aBird + 1)

type casting

46
New cards

Executing every branch at least once is feasible.

True

47
New cards

Function prototypes are:

Declarations

48
New cards

Order of execution of operators in C++:

NOT first, then relational operators, then other Boolean operators

49
New cards

Testing based on code coverage is called:

clear (white box) testing

50
New cards

Testing based on data coverage is called:

black-box testing

51
New cards

Ability of a program to recover following an error is called:

robustness

52
New cards

Assertion that states what is true after execution is known as:

postcondition

53
New cards

Assertion that states what is true before execution of a code segment is known as:

precondition

54
New cards

The programmer must always write some code before a test plan can be generated.

False

55
New cards

The separation of the logical properties of functions from their implementation is known as:

procedural abstraction

56
New cards

Top-down testing is always preferable to bottom-up testing.

False

57
New cards

Top-down testing requires drivers.

True

58
New cards

A code walk-through is a verification method that must be done by a team.

False

59
New cards

Regression testing is done after a program has been modified.

True

60
New cards

A code walk-through is a verification method done by the programmer.

True

61
New cards

An exception should be handled at a level that understands what the exception means.

True

62
New cards

An unhandled exception in C++ carries the penalty of program termination.

True

63
New cards

Black-box testing is based on the code being tested.

False

64
New cards

C++ provides no mechanisms to manage exceptions.

False

65
New cards

Clear-box testing is based on the code being tested.

True

66
New cards

Executing every path at least once is feasible.

False

67
New cards

Executing every statement at least once is feasible.

true

68
New cards

In object-oriented design, an operation on an object might be designed using structured (top-down) design.

True

69
New cards

What happens when a file with only 5 values is read with a loop expecting 6?

The code prints the first 5 values and crashes.

70
New cards

Goal of information hiding:

Controlling access to the details of a function

71
New cards

Role of count in a loop reading values:

At the beginning of each iteration, count contains the number of values read in

72
New cards

Value of count when loop exits (specific example):

4

73
New cards

What should go in the blank if storing values into int data[LIMIT]?

data[index]

74
New cards

Bottom-up testing is preferable when testing the implementation of an ADT.

True

75
New cards

Stream extraction operator

»

76
New cards

Stream insertion operator

«

77
New cards

A stream in C++ goes into the fail state when a read has been issued after the last value on a file has been read.

True

78
New cards

Operator evaluated first in expression (count && !flag)?

!

79
New cards

Constructor cannot be explicitly called by the client program.

True

80
New cards

A list is:

a variable-sized, user-defined structure; the mechanism for accessing the structure must be provided through functions

81
New cards

An array is fixed size, whereas a list is variable size.

True

82
New cards

An array is

a fixed-size structure; the mechanism for accessing the structure is built into C++

83
New cards

If you have a constructor, you do not need a MakeEmpty operation.

True

84
New cards

In a linked implementation of a list, you can have an iterator.

False

85
New cards

In an unsorted list, there is a semantic relationship between successive items in the list.

False

86
New cards

It is not possible to use a list without knowing how it is implemented.

False

87
New cards

The algorithm for deleting from an unsorted list has the last item replace the item being deleted.

True

88
New cards

The external pointer is considered to be one of the nodes of a linked list.

False

89
New cards

The next item in a linked list can always be found by accessing the next physical location in memory.

False

90
New cards

To prevent a compile-time error with ListNode and NodeType:

Either insert struct ListNode; typedef ListNode* NodeType*; before line 1, or replace line 4 with ListNode* next;

91
New cards

A generic data type is one in which the operations are defined, but the types of items being manipulated are not.

True

92
New cards

An array-based list automatically gives O(1) length operation, but in a linked implementation, length can be O(1) or O(N) depending on design.

True

93
New cards

To implement a list ADT with an unknown and variable number of components, the best choice is:

A linked list represented as dynamic structs and pointers

94
New cards

Deleting from an unsorted list requires elements below the one being deleted to be moved up one slot.

False

95
New cards

Given only the external pointer to a linked list, inserting at the front is faster than at the back.

True

96
New cards

If currPtr points to a node in a dynamic linked list, currPtr++ advances to the next node.

False

97
New cards

Inserting and deleting in an unsorted list have the same time complexity.

True

98
New cards

What is special about the last node in a dynamic linked list?

Its link member contains the value NULL

99
New cards

Order of inserting an element into its place in an unsorted array-based list:

O(1)

100
New cards

Line labeled //2 should be filled with:

moreToSearch && !found