CH 3,4,5 C++ True/False

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

1/48

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.

49 Terms

1
New cards

The typedef statement allows you to change the item type easily.

True

2
New cards

The size_type type is used to track the number of items.

True

3
New cards

The value_type name must be used in all functions.

False

4
New cards

The insert function adds a new element to the bag.

True

5
New cards

The erase_one function removes all occurrences of a value.

False

6
New cards

The erase function removes all occurrences of a value.

True

7
New cards

The count function returns the number of occurrences of a given value. 

True

8
New cards

The size function returns the number of items in the bag.

True

9
New cards

The CAPACITY constant can be changed by non-member functions.

False

10
New cards

Using 'using namespace std;' in header files is good practice.

False

11
New cards

The used variable tracks the number of elements in the bag.

True

12
New cards

Container classes cannot be reused with a different data type.

False

13
New cards

A bag object is a type of container class.

True

14
New cards

A container class stores a collection of items.

True

15
New cards

The new operator allocates memory from the heap.

True

16
New cards
17
New cards

The delete operator returns memory to the heap.

True

18
New cards

The bad_alloc exeption is thrown if new fails.

True

19
New cards

Pointer notation p→m is equivalent to (*p).m.

True

20
New cards

A pointer to a const int allows changing the value pointed to.

False

21
New cards

Passing a pointer by reference allows a function to modify the pointer itself.

True

22
New cards

Dynamic arrays require delete{} to free the memory.

True

23
New cards

Automatic assignment operators are safe for classes with dynamic memory.

False

24
New cards

A destructor is automatically called when an object goes out of scope.

True

25
New cards

Local objects with destructors are destroyed when their function returns.

True

26
New cards

Reference parameters with destructors are destroyed when the function returns.

False

27
New cards

Deleting dynamic objects call their destructor.

True

28
New cards

The reserve function expands the dynamic array capacity in a bag.

True

29
New cards

Returning a local object copies it to a return location.

True

30
New cards

The copy function in is used to copy dynamic arrays.

True.

31
New cards

A linked list is a sequence of nodes connected by pointers.

True

32
New cards

Each node contains data and a pointer to the next node.

True

33
New cards

The head_ptr points to the first node in the list.

True

34
New cards

The tail_ptr points to the last node in the list

True

35
New cards

An empty list has head_ptr equal to NULL.

True

36
New cards

A NULL pointer indicates a node does not point to anything.

True

37
New cards

The list_search function returns a pointer to the node containing the target value or NULL.

True

38
New cards

Inserting at the head adds a node before the first node.

True

39
New cards

Inserting after a node places the new node after the given node.

True

40
New cards

Deleting the first node requires moving head_ptr and deleting the old node.

True

41
New cards

Deleting after a node uses previous_ptr->get_next() and set_next().

True

42
New cards

Traversing a list is done using ptr = head_ptr; ptr != NULL; ptr = ptr->get_next().

True

43
New cards

head_ptr points to NULL after deleting the last node.

True

44
New cards

A linked list can contain multiple nodes with the same value.

True

45
New cards

A linked list node cannot contain a pointer to a previous node in a singly linked list.

True

46
New cards

The get_next() function returns a pointer to the next node.

True

47
New cards

The get_value() or get_data() function returns the data stored in a node.

True

48
New cards

A pointer to a node can be set to NULL to indicate the end of a list.

True

49
New cards

Traversing a list incorrectly can cause access to invalid memory.

True