Deck 13: Pointers and Linked Lists

Full screen (f)
exit full mode
Question
You can directly access the nth node of a linked list
Use Space or
up arrow
down arrow
to flip the card.
Question
If you write a linked list class,then you should implement the destructor,copy constructor,and the assignment operator
Question
The stack exhibits last-in/first-out behavior
Question
There is no need for error checking when popping a stack.
Question
Most applications that use a stack will store a struct or class object on the stack.
Question
*head.item is the same as *head).item
Question
A stack is a first-in-first-out data structure.
Question
A stack is a specialized type of list
Question
A queue is first-in-first-out data structure.
Question
Data is removed at the back of the queue.
Question
Placing data on a stack is called popping the stack.
Question
Data is inserted into a queue at the back.
Question
The linked list is always the most efficient storage mechanism for storing many pieces of data.
Question
Removing data from a stack is called popping the stack.
Question
The last node in a linked list as defined in the text should always point back to the head of the list.
Question
A linked list is not fixed in size.
Question
The constant NULL can be assigned only to pointers that point to numbers
Question
A _______ is a list constructed using pointers.
Question
The stack can be compared to a line of people at a bank,where the first person in line is the first person served.
Question
There is no need for error checking when pushing a stack.
Question
Dynamically allocated memory that is no longer pointed to by any pointer variable causes a ______________.
Question
If you want to make your linked list a class,you must also include the _____.
Question
The number of possible nodes in a linked list is __________
Question
The function used to put data into a stack is typically called _______.
Question
In a node type named MyNode,which of the following correctly declares a pointer to a node of that type?

A)MyNode* ptr;
B)MyNode ptr;
C)ptr myNode*;
D)MyNode.data* ptr;
Question
A _________ is a struct or class object that has one or more member variables that are pointer variables.
Question
The pointer in a node points to

A)the data part of a node
B)the count part of a node
C)the pointer part of the node
D)the whole node
Question
A stack can be implemented using a __________.
Question
The first node in a linked list is generally named _________
Question
The function used to get the data at the top or front)of the stack is called _______.
Question
The arrow operator ->)specifies

A)a member of a struct or class that is pointed to by a pointer variable
B)the pointer member only of a struct or a class that is pointed to by a pointer variable
C)less than or equal
D)is known as NULL
Question
You can define a stack that will hold _________-
Question
The arrow operator ->)combines the actions of which two operators?
Question
If you want to declare a node type struct and typedef a pointer type for that node,in which order must you make these declarations?

A)first the node pointer,then the node,since the node has a pointer in it.
B)first the node,then the typedef.
C)it doesn't matter which order you do them in
D)you cannot do both of them in the same program.
Question
In a linked list as defined in the text,the pointer in the last node in the list should always point to _________.
Question
Which operator * or .)has higher precedence?
Question
When adding a node to a linked list,which pointer variable do you update first?
Question
If head is a NodePtr pointer variable,write the code to make head point to new node of type Node.
Question
Apart from constructors,the operations for a queue listed in the text are ____________,_____________,and _______________,
Question
Apart from constructors,the operations for a stack listed in the text are ____________,_____________,and _______________,
Question
As defined in the text,the pointer variable head

A)is the first node in the list
B)points to the first node in the list
C)is always NULL
D)is undefined
Question
If you push the following numbers onto an integer stack,what item is on the top of the stack? 1,4,8,16)

A)1
B)4
C)8
D)16
Question
The actual value of NULL is

A)-1
B)0
C)99999
D)-99
Question
Which of the following loops correctly uses iter as an iterator to move through the nodes of the linked list?
NodePtr iter; //a pointer to a node

A)whileiter != NULL) iter++;
B)whileiter != NULL) iter=iter->link;
C)foriter=NULL; iter != NULL; iter=iter->link)
D)for iter=head; iter != NULL; iter=iter->link)
Question
To remove an item from the stack,we call the ____ function

A)pop
B)top
C)push
D)empty
Question
To add an item to a stack,we call the ______ function

A)pop
B)top
C)push
D)empty
Question
If you need to access the last element of a linked list with N nodes in it,how many comparisons do you need to make to find the last element?

A)0
B)1
C)N-1
D)N
Question
A stack exhibits ______________ behavior

A)last-in/ first-out
B)last-in/last-out
C)first-in/first-out
D)none of the above
Question
If you need to insert an element in the front of a list with N nodes and move the other elements back one place),how many nodes do you have to move?

A)0
B)1
C)N-1
D)N
Question
If NodeTypePtr is defined to be a pointer type to a node in a linked list,then the declaration
NodeTypePtr head;

A)allocates memory for the node that head will point to
B)automatically makes head->link point to NULL
C)allocates only the memory for a pointer variable
D)allocates a linked list
Question
When would you use a linked list over an array or a dynamic array?

A)when you know the maximum size at compile time
B)when you know the maximum size at run-time
C)when you do not know the maximum size
D)when you need to access any item quickly
Unlock Deck
Sign up to unlock the cards in this deck!
Unlock Deck
Unlock Deck
1/51
auto play flashcards
Play
simple tutorial
Full screen (f)
exit full mode
Deck 13: Pointers and Linked Lists
1
You can directly access the nth node of a linked list
False
2
If you write a linked list class,then you should implement the destructor,copy constructor,and the assignment operator
True
3
The stack exhibits last-in/first-out behavior
True
4
There is no need for error checking when popping a stack.
Unlock Deck
Unlock for access to all 51 flashcards in this deck.
Unlock Deck
k this deck
5
Most applications that use a stack will store a struct or class object on the stack.
Unlock Deck
Unlock for access to all 51 flashcards in this deck.
Unlock Deck
k this deck
6
*head.item is the same as *head).item
Unlock Deck
Unlock for access to all 51 flashcards in this deck.
Unlock Deck
k this deck
7
A stack is a first-in-first-out data structure.
Unlock Deck
Unlock for access to all 51 flashcards in this deck.
Unlock Deck
k this deck
8
A stack is a specialized type of list
Unlock Deck
Unlock for access to all 51 flashcards in this deck.
Unlock Deck
k this deck
9
A queue is first-in-first-out data structure.
Unlock Deck
Unlock for access to all 51 flashcards in this deck.
Unlock Deck
k this deck
10
Data is removed at the back of the queue.
Unlock Deck
Unlock for access to all 51 flashcards in this deck.
Unlock Deck
k this deck
11
Placing data on a stack is called popping the stack.
Unlock Deck
Unlock for access to all 51 flashcards in this deck.
Unlock Deck
k this deck
12
Data is inserted into a queue at the back.
Unlock Deck
Unlock for access to all 51 flashcards in this deck.
Unlock Deck
k this deck
13
The linked list is always the most efficient storage mechanism for storing many pieces of data.
Unlock Deck
Unlock for access to all 51 flashcards in this deck.
Unlock Deck
k this deck
14
Removing data from a stack is called popping the stack.
Unlock Deck
Unlock for access to all 51 flashcards in this deck.
Unlock Deck
k this deck
15
The last node in a linked list as defined in the text should always point back to the head of the list.
Unlock Deck
Unlock for access to all 51 flashcards in this deck.
Unlock Deck
k this deck
16
A linked list is not fixed in size.
Unlock Deck
Unlock for access to all 51 flashcards in this deck.
Unlock Deck
k this deck
17
The constant NULL can be assigned only to pointers that point to numbers
Unlock Deck
Unlock for access to all 51 flashcards in this deck.
Unlock Deck
k this deck
18
A _______ is a list constructed using pointers.
Unlock Deck
Unlock for access to all 51 flashcards in this deck.
Unlock Deck
k this deck
19
The stack can be compared to a line of people at a bank,where the first person in line is the first person served.
Unlock Deck
Unlock for access to all 51 flashcards in this deck.
Unlock Deck
k this deck
20
There is no need for error checking when pushing a stack.
Unlock Deck
Unlock for access to all 51 flashcards in this deck.
Unlock Deck
k this deck
21
Dynamically allocated memory that is no longer pointed to by any pointer variable causes a ______________.
Unlock Deck
Unlock for access to all 51 flashcards in this deck.
Unlock Deck
k this deck
22
If you want to make your linked list a class,you must also include the _____.
Unlock Deck
Unlock for access to all 51 flashcards in this deck.
Unlock Deck
k this deck
23
The number of possible nodes in a linked list is __________
Unlock Deck
Unlock for access to all 51 flashcards in this deck.
Unlock Deck
k this deck
24
The function used to put data into a stack is typically called _______.
Unlock Deck
Unlock for access to all 51 flashcards in this deck.
Unlock Deck
k this deck
25
In a node type named MyNode,which of the following correctly declares a pointer to a node of that type?

A)MyNode* ptr;
B)MyNode ptr;
C)ptr myNode*;
D)MyNode.data* ptr;
Unlock Deck
Unlock for access to all 51 flashcards in this deck.
Unlock Deck
k this deck
26
A _________ is a struct or class object that has one or more member variables that are pointer variables.
Unlock Deck
Unlock for access to all 51 flashcards in this deck.
Unlock Deck
k this deck
27
The pointer in a node points to

A)the data part of a node
B)the count part of a node
C)the pointer part of the node
D)the whole node
Unlock Deck
Unlock for access to all 51 flashcards in this deck.
Unlock Deck
k this deck
28
A stack can be implemented using a __________.
Unlock Deck
Unlock for access to all 51 flashcards in this deck.
Unlock Deck
k this deck
29
The first node in a linked list is generally named _________
Unlock Deck
Unlock for access to all 51 flashcards in this deck.
Unlock Deck
k this deck
30
The function used to get the data at the top or front)of the stack is called _______.
Unlock Deck
Unlock for access to all 51 flashcards in this deck.
Unlock Deck
k this deck
31
The arrow operator ->)specifies

A)a member of a struct or class that is pointed to by a pointer variable
B)the pointer member only of a struct or a class that is pointed to by a pointer variable
C)less than or equal
D)is known as NULL
Unlock Deck
Unlock for access to all 51 flashcards in this deck.
Unlock Deck
k this deck
32
You can define a stack that will hold _________-
Unlock Deck
Unlock for access to all 51 flashcards in this deck.
Unlock Deck
k this deck
33
The arrow operator ->)combines the actions of which two operators?
Unlock Deck
Unlock for access to all 51 flashcards in this deck.
Unlock Deck
k this deck
34
If you want to declare a node type struct and typedef a pointer type for that node,in which order must you make these declarations?

A)first the node pointer,then the node,since the node has a pointer in it.
B)first the node,then the typedef.
C)it doesn't matter which order you do them in
D)you cannot do both of them in the same program.
Unlock Deck
Unlock for access to all 51 flashcards in this deck.
Unlock Deck
k this deck
35
In a linked list as defined in the text,the pointer in the last node in the list should always point to _________.
Unlock Deck
Unlock for access to all 51 flashcards in this deck.
Unlock Deck
k this deck
36
Which operator * or .)has higher precedence?
Unlock Deck
Unlock for access to all 51 flashcards in this deck.
Unlock Deck
k this deck
37
When adding a node to a linked list,which pointer variable do you update first?
Unlock Deck
Unlock for access to all 51 flashcards in this deck.
Unlock Deck
k this deck
38
If head is a NodePtr pointer variable,write the code to make head point to new node of type Node.
Unlock Deck
Unlock for access to all 51 flashcards in this deck.
Unlock Deck
k this deck
39
Apart from constructors,the operations for a queue listed in the text are ____________,_____________,and _______________,
Unlock Deck
Unlock for access to all 51 flashcards in this deck.
Unlock Deck
k this deck
40
Apart from constructors,the operations for a stack listed in the text are ____________,_____________,and _______________,
Unlock Deck
Unlock for access to all 51 flashcards in this deck.
Unlock Deck
k this deck
41
As defined in the text,the pointer variable head

A)is the first node in the list
B)points to the first node in the list
C)is always NULL
D)is undefined
Unlock Deck
Unlock for access to all 51 flashcards in this deck.
Unlock Deck
k this deck
42
If you push the following numbers onto an integer stack,what item is on the top of the stack? 1,4,8,16)

A)1
B)4
C)8
D)16
Unlock Deck
Unlock for access to all 51 flashcards in this deck.
Unlock Deck
k this deck
43
The actual value of NULL is

A)-1
B)0
C)99999
D)-99
Unlock Deck
Unlock for access to all 51 flashcards in this deck.
Unlock Deck
k this deck
44
Which of the following loops correctly uses iter as an iterator to move through the nodes of the linked list?
NodePtr iter; //a pointer to a node

A)whileiter != NULL) iter++;
B)whileiter != NULL) iter=iter->link;
C)foriter=NULL; iter != NULL; iter=iter->link)
D)for iter=head; iter != NULL; iter=iter->link)
Unlock Deck
Unlock for access to all 51 flashcards in this deck.
Unlock Deck
k this deck
45
To remove an item from the stack,we call the ____ function

A)pop
B)top
C)push
D)empty
Unlock Deck
Unlock for access to all 51 flashcards in this deck.
Unlock Deck
k this deck
46
To add an item to a stack,we call the ______ function

A)pop
B)top
C)push
D)empty
Unlock Deck
Unlock for access to all 51 flashcards in this deck.
Unlock Deck
k this deck
47
If you need to access the last element of a linked list with N nodes in it,how many comparisons do you need to make to find the last element?

A)0
B)1
C)N-1
D)N
Unlock Deck
Unlock for access to all 51 flashcards in this deck.
Unlock Deck
k this deck
48
A stack exhibits ______________ behavior

A)last-in/ first-out
B)last-in/last-out
C)first-in/first-out
D)none of the above
Unlock Deck
Unlock for access to all 51 flashcards in this deck.
Unlock Deck
k this deck
49
If you need to insert an element in the front of a list with N nodes and move the other elements back one place),how many nodes do you have to move?

A)0
B)1
C)N-1
D)N
Unlock Deck
Unlock for access to all 51 flashcards in this deck.
Unlock Deck
k this deck
50
If NodeTypePtr is defined to be a pointer type to a node in a linked list,then the declaration
NodeTypePtr head;

A)allocates memory for the node that head will point to
B)automatically makes head->link point to NULL
C)allocates only the memory for a pointer variable
D)allocates a linked list
Unlock Deck
Unlock for access to all 51 flashcards in this deck.
Unlock Deck
k this deck
51
When would you use a linked list over an array or a dynamic array?

A)when you know the maximum size at compile time
B)when you know the maximum size at run-time
C)when you do not know the maximum size
D)when you need to access any item quickly
Unlock Deck
Unlock for access to all 51 flashcards in this deck.
Unlock Deck
k this deck
locked card icon
Unlock Deck
Unlock for access to all 51 flashcards in this deck.