Deck 3: Pointers and Array-Based Lists
Question
Question
Question
Question
Question
Question
Question
Question
Question
Question
Question
Question
Question
Question
Question
Question
Question
Question
Question
Question
Question
Question
Question
Question
Question
Question
Question
Question
Question
Question
Question
Question
Question
Question
Question
Question
Question
Question
Question
Question
Question
Question
Question
Question
Question
Unlock Deck
Sign up to unlock the cards in this deck!
Unlock Deck
Unlock Deck
1/45
Play
Full screen (f)
Deck 3: Pointers and Array-Based Lists
1
The values belonging to pointer data types are the memory addresses of your computer.
True
2
In the line of code int* p,q, p and q are both pointer variables of type int.
False
3
The ampersand, &, is a binary operator that returns the address of its operand.
False
4
Two different pointer variables cannot point to same memory location.
Unlock Deck
Unlock for access to all 45 flashcards in this deck.
Unlock Deck
k this deck
5
When * is used as a unary operator, * refers to the object to which the operand of the * (that is, the pointer) points.
Unlock Deck
Unlock for access to all 45 flashcards in this deck.
Unlock Deck
k this deck
6
A declaration such as int *p; allocates memory for p only, not for *p.
Unlock Deck
Unlock for access to all 45 flashcards in this deck.
Unlock Deck
k this deck
7
Pointer variables must be initialized if you want them to point to something.
Unlock Deck
Unlock for access to all 45 flashcards in this deck.
Unlock Deck
k this deck
8
When a program no longer needs a dynamic variable, the operator delete is used.
Unlock Deck
Unlock for access to all 45 flashcards in this deck.
Unlock Deck
k this deck
9
The operator new has two forms: one to allocate a single variable, and another to allocate an array of variables.
Unlock Deck
Unlock for access to all 45 flashcards in this deck.
Unlock Deck
k this deck
10
When a dynamic variable is no longer needed, it can be destroyed; that is, its memory can be deallocated.
Unlock Deck
Unlock for access to all 45 flashcards in this deck.
Unlock Deck
k this deck
11
The increment operator increments the value of a pointer variable by twice the size of the memory to which it is pointing.
Unlock Deck
Unlock for access to all 45 flashcards in this deck.
Unlock Deck
k this deck
12
The decrement operator decrements the value of a pointer variable by the size of the memory to which it is pointing.
Unlock Deck
Unlock for access to all 45 flashcards in this deck.
Unlock Deck
k this deck
13
When an integer is added to a pointer variable, the value of the pointer variable is incremented by the integer times the size of the memory to which the pointer is pointing.
Unlock Deck
Unlock for access to all 45 flashcards in this deck.
Unlock Deck
k this deck
14
When an integer is subtracted from a pointer variable, the value of the pointer variable is decremented by the integer times half the size of the memory to which the pointer is pointing.
Unlock Deck
Unlock for access to all 45 flashcards in this deck.
Unlock Deck
k this deck
15
An array created during the execution of a program is called a dynamic array.
Unlock Deck
Unlock for access to all 45 flashcards in this deck.
Unlock Deck
k this deck
16
In a shallow copy, two pointers of different data types point to the same memory.
Unlock Deck
Unlock for access to all 45 flashcards in this deck.
Unlock Deck
k this deck
17
In a deep copy, two or more pointers have their own data.
Unlock Deck
Unlock for access to all 45 flashcards in this deck.
Unlock Deck
k this deck
18
The copy constructor does not execute when the return value of a function is an object.
Unlock Deck
Unlock for access to all 45 flashcards in this deck.
Unlock Deck
k this deck
19
The length of a list is the number of elements in the list.
Unlock Deck
Unlock for access to all 45 flashcards in this deck.
Unlock Deck
k this deck
20
In order to maintain and process the list in an array, we need the array holding the list elements, a variable to store the length of the list, and a variable to store the size of the array.
Unlock Deck
Unlock for access to all 45 flashcards in this deck.
Unlock Deck
k this deck
21
It is good programming practice to develop separate code for each type of list we need.
Unlock Deck
Unlock for access to all 45 flashcards in this deck.
Unlock Deck
k this deck
22
The time complexity of the function isEmpty in an array list is O(1).
Unlock Deck
Unlock for access to all 45 flashcards in this deck.
Unlock Deck
k this deck
23
The time complexity of the function seqSearch in an array list is O(n2).
Unlock Deck
Unlock for access to all 45 flashcards in this deck.
Unlock Deck
k this deck
24
A ____ variable is a variable whose content is a memory address.
A) class
B) dynamic
C) pointer
D) heap
A) class
B) dynamic
C) pointer
D) heap
Unlock Deck
Unlock for access to all 45 flashcards in this deck.
Unlock Deck
k this deck
25
The value of a pointer variable is an ____.
A) address
B) entry in a table
C) array
D) unknown value
A) address
B) entry in a table
C) array
D) unknown value
Unlock Deck
Unlock for access to all 45 flashcards in this deck.
Unlock Deck
k this deck
26
The general syntax to declare a pointer variable is ____.
A) dataType &identifier;
B) *dataType identifier;
C) &dataType identifier;
D) dataType *identifier;
A) dataType &identifier;
B) *dataType identifier;
C) &dataType identifier;
D) dataType *identifier;
Unlock Deck
Unlock for access to all 45 flashcards in this deck.
Unlock Deck
k this deck
27
The ampersand, &, is called the ____.
A) address of operator
B) sizeof operator
C) entry operator
D) heap operator
A) address of operator
B) sizeof operator
C) entry operator
D) heap operator
Unlock Deck
Unlock for access to all 45 flashcards in this deck.
Unlock Deck
k this deck
28
The * is commonly referred to as the ____ operator.
A) referencing
B) allocating
C) dereferencing
D) addressing
A) referencing
B) allocating
C) dereferencing
D) addressing
Unlock Deck
Unlock for access to all 45 flashcards in this deck.
Unlock Deck
k this deck
29
The syntax for accessing a class (struct) member using the operator -> is ____.
A) pointerVariableName.classMemberName
B) pointerVariableName->classMemberName
C) pointerVariableName&->classMemberName
D) &pointerVariableName.classMemberName
A) pointerVariableName.classMemberName
B) pointerVariableName->classMemberName
C) pointerVariableName&->classMemberName
D) &pointerVariableName.classMemberName
Unlock Deck
Unlock for access to all 45 flashcards in this deck.
Unlock Deck
k this deck
30
You can initialize a pointer variable by setting it to ____.
A) EMPTY
B) NULL
C) INIT
D) NONE
A) EMPTY
B) NULL
C) INIT
D) NONE
Unlock Deck
Unlock for access to all 45 flashcards in this deck.
Unlock Deck
k this deck
31
Variables that are created during program execution are called ____ variables.
A) stack
B) heap
C) dynamic
D) static
A) stack
B) heap
C) dynamic
D) static
Unlock Deck
Unlock for access to all 45 flashcards in this deck.
Unlock Deck
k this deck
32
The statement ____ stores the address of x in p.
A) p = &x;
B) p = &x
C) x = &p;
D) x = &p
A) p = &x;
B) p = &x
C) x = &p;
D) x = &p
Unlock Deck
Unlock for access to all 45 flashcards in this deck.
Unlock Deck
k this deck
33
When a dynamic variable is no longer needed, it can be ____.
A) recycled
B) reassigned
C) reconstructed
D) destroyed
A) recycled
B) reassigned
C) reconstructed
D) destroyed
Unlock Deck
Unlock for access to all 45 flashcards in this deck.
Unlock Deck
k this deck
34
A ____ leak is when there is an unused memory space that cannot be allocated.
A) variable
B) function
C) constructor
D) memory
A) variable
B) function
C) constructor
D) memory
Unlock Deck
Unlock for access to all 45 flashcards in this deck.
Unlock Deck
k this deck
35
The statement ____ declares list to be an array of five integers.
A) int [5] list;
B) int list[5];
C) int list[];
D) int list[]={0,1,2,3,4,5};
A) int [5] list;
B) int list[5];
C) int list[];
D) int list[]={0,1,2,3,4,5};
Unlock Deck
Unlock for access to all 45 flashcards in this deck.
Unlock Deck
k this deck
36
If p is a pointer variable of type int, then the statement ____ copies the value of list into p.
A) list = p;
B) p.copy(list);
C) p->copy(list);
D) p = list;
A) list = p;
B) p.copy(list);
C) p->copy(list);
D) p = list;
Unlock Deck
Unlock for access to all 45 flashcards in this deck.
Unlock Deck
k this deck
37
A pointer variable can be passed as a parameter to a function either by value or by ____.
A) retention
B) reference
C) approximation
D) referral
A) retention
B) reference
C) approximation
D) referral
Unlock Deck
Unlock for access to all 45 flashcards in this deck.
Unlock Deck
k this deck
38
The statement ____ declares board to be a pointer to a pointer.
A) int **board;
B) int *&board;
C) *int *board;
D) **int board;
A) int **board;
B) int *&board;
C) *int *board;
D) **int board;
Unlock Deck
Unlock for access to all 45 flashcards in this deck.
Unlock Deck
k this deck
39
If a class has member variables that are pointers, you must ensure that you implement ____.
A) garbage collection
B) base constructors
C) friend functions
D) a destructor
A) garbage collection
B) base constructors
C) friend functions
D) a destructor
Unlock Deck
Unlock for access to all 45 flashcards in this deck.
Unlock Deck
k this deck
40
The correct syntax for the destructor of the class tempClass is ____.
A) tempClass::~tempClass()
B) tempClass::~tempClass(x)
C) tempClass::tempClass()
D) tempClass::tempClass(x)
A) tempClass::~tempClass()
B) tempClass::~tempClass(x)
C) tempClass::tempClass()
D) tempClass::tempClass(x)
Unlock Deck
Unlock for access to all 45 flashcards in this deck.
Unlock Deck
k this deck
41
The general syntax to include the copy constructor in the definition of a class is ____.
A) className(className& otherObject);
B) className(className otherObject);
C) className(const className& otherObject);
D) className(const className* otherObject);
A) className(className& otherObject);
B) className(className otherObject);
C) className(const className& otherObject);
D) className(const className* otherObject);
Unlock Deck
Unlock for access to all 45 flashcards in this deck.
Unlock Deck
k this deck
42
To determine whether the item to be inserted is already in the list, the insert function calls the _____ member function.
A) isEmpty
B) size
C) seqSearch
D) copy
A) isEmpty
B) size
C) seqSearch
D) copy
Unlock Deck
Unlock for access to all 45 flashcards in this deck.
Unlock Deck
k this deck
43
In an array list, the time complexity of the isEmpty function is identical to the time complexity of the ____ function.
A) removeAt
B) isFull
C) insertAt
D) print
A) removeAt
B) isFull
C) insertAt
D) print
Unlock Deck
Unlock for access to all 45 flashcards in this deck.
Unlock Deck
k this deck
44
In an array list, the time complexity of the removeAt function is identical to the time complexity of the ____ function.
A) isEmpty
B) seqSearch
C) isFull
D) isItemAtEqual
A) isEmpty
B) seqSearch
C) isFull
D) isItemAtEqual
Unlock Deck
Unlock for access to all 45 flashcards in this deck.
Unlock Deck
k this deck
45
In an array list the time complexity of the remove function is identical to the time complexity of the ____ function.
A) insert
B) isEmpty
C) isFull
D) maxListSize
A) insert
B) isEmpty
C) isFull
D) maxListSize
Unlock Deck
Unlock for access to all 45 flashcards in this deck.
Unlock Deck
k this deck