exam 1

¡Supera tus tareas y exámenes ahora con Quizwiz!

True/False: The values stored in the value portion of a node of a linked list can be simple data types, structures, objects of classes, or any other data type.

True

True/False: When a class contains a pointer to dynamically allocated memory, it a good idea to have the class overload the assignment operator.

True

The ________ class constructor is called before the ________ class constructor. A) public, private B) base, derived C) private, public D) derived, base E) None of the above

B) base, derived

A static queue can be implemented as a A) stack. B) circular array. C) dynamic vector. D) dynamic linked list. E) None of the above

B) circular array.

It is a good idea to make a copy constructor's parameters ________ by specifying the ________ keyword in the parameter list. A) static, static B) constant, const C) inline, inline D) global, glob E) None of the above

B) constant, const

Two primary queue operations are A) onqueue and offqueue. B) enqueue and dequeue. C) insert and delete. D) push and pop. E) None of the above

B) enqueue and dequeue.

In a doubly-linked list, each node contains a pointer to the next node in the list, as well as a pointer to A) the tail node. B) itself. C) the previous node. D) the head node. E) None of the above

C) the previous node.

True/False: A new node cannot become the first node in the list.

False

True/False: A new node must always be made the last node in the list.

False

True/False: A real-world example of the queue data structure can be seen in a stack of cafeteria trays, where the last tray pushed onto the stack is the first tray removed.

False

True/False: C++ permits you to overload the sizeof operator.

False

True/False: Enqueue and dequeue are the two most common stack operations.

False

True/False: If a function f is a friend of a class A, and the class A is a friend of a class B, then the function f is able to access private members of B.

False

True/False: If you overload the prefix ++ operator, the postfix ++ operator is automatically overloaded also.

False

True/False: Inserting an item into a linked list requires that all the items past the point of the insertion be shifted to make room for the new item

False

True/False: When a class declares an entire class as its friend, the friendship status is reciprocal. That is, each class's member functions have free access to the other's private members.

False

True/False: When an item stored in a linked list is removed, all list items stored after it have to be moved down to plug up the hole.

False

True/False: When you create a linked list, you must know in advance how many nodes the list will contain.

False

True/False: When you overload the << operator, you must also overload the >> operator.

False

True/False: A derived class may become a base class, if another class is derived from it.

True

True/False: A dynamic stack starts as an empty linked list.

True

True/False: A non-empty linked list of items can be reversed by removing the head, reversing what is left, and then adding the (original) head at the end of the reversed tail.

True

True/False: By default, when an object is assigned to another, each member of one object is copied to its counterpart in the other object.

True

True/False: Deleting an entire list requires traversing the list to delete the nodes.

True

True/False: If a node is not the first node in a linked list, deleting it may require setting the successor pointer in its predecessor.

True

True/False: In a non-empty list, there must be exactly one list item with no successor.

True

True/False: The STL provides containers for deque and queue.

True

True/False: The first item placed onto a stack is always the last item removed from the stack.

True

True/False: The pop function in the stack template of the STL does not return the value from the top of the stack.

True

A dynamic stack has a ________ size, and is implemented as a(n) ________. A) fixed, linked list B) variable, linked list C) variable, array D) fixed, array E) None of the above

B) variable, linked list

The ________ operator may be used to assign one object to another. A) = B) <> C) & D) == E) None of the above

A) =

________ members of a base class are never accessible to a derived class. A) Private B) Protected C) Public D) A, B, and C E) None of the above

A) Private

When a class contains a pointer to dynamically allocated memory, it is a good idea to equip the class with A) a copy constructor. B) a static constructor and an overloaded comparison operator. C) an inline constructor. D) a dynamically allocated constructor. E) None of the above

A) a copy constructor.

The statement stack< int, vector<int> > iStack; creates A) a new stack of integers, implemented as a vector. B) a new stack of integers, implemented as a deque. C) a new vector called stack, implemented with integers. D) a new stack called vector, implemented as integers. E) None of the above

A) a new stack of integers, implemented as a vector.

A good reason for overloading an operator is to enable it to A) be used with types defined by the programmer. B) operate on no operands. C) outperform its C language counterparts. D) operate on more operands than in its standard definition. E) None of the above

A) be used with types defined by the programmer.

A(n) ________ is an abstract data type that stores and retrieves items in a last-in-first-out manner. A) stack B) array C) vector D) queue E) None of the above

A) stack

For most people, ________ queues are more intuitive and easier to understand than ________ queues. A) Deque-like, stack-like B) Dynamic, static C) Static, dynamic D) Stack-like, deque-like E) None of the above

B) Dynamic, static

The defining characteristic of a linked list is that A) lists are very efficient at storing data. B) the locations that store list data do not have to be consecutive in memory. C) data are stored in consecutive locations in the memory of the computer. D) the maximum size of a list is fixed when the list is created. E) None of the above

B) the locations that store list data do not have to be consecutive in memory.

To concatenate two linked lists, it is necessary to A) first reverse one of the lists. B) traverse one of the lists to get to its end. C) traverse both lists to get to their ends. D) first reverse both lists. E) None of the above

B) traverse one of the lists to get to its end.

________ allows us to create new classes based on existing classes. A) Polymorphism B) Function overloading C) Inheritance D) The copy constructor E) None of the above

C) Inheritance

In the statement class Car:public Vehicle, which is the base class? A) Car B) class C) Vehicle D) public E) None of the above

C) Vehicle

C++ requires that a copy constructor's parameter be A) a pointer variable. B) a floating-point data type. C) a reference to an object. D) an integer data type. E) None of the above

C) a reference to an object.

When you derive a class from an existing class, you A) must add both new data and new functions. B) can add new functions, but cannot add new data. C) can add both new data and new functions. D) can add new data, but cannot add new functions. E) None of the above

C) can add both new data and new functions.

A ________ is a container that provides quick access to elements at the front and the back of the list. A) queue B) stack C) deque D) All of the above E) None of the above

C) deque

A ________ is a double-ended queue. A) two-tailed vector B) circular array C) dequeue D) two-headed stack E) None of the above

C) dequeue

A ________ stack or queue is implemented using linked lists. A) deque-based B) static C) dynamic D) floating point E) None of the above

C) dynamic

The ________ of a linked list points to the first node in the list. A) starter B) declaration C) head D) tail E) None of the above

C) head

The STL implementation of a linked list is a class called A) LinkedList. B) dequeue. C) list. D) DynamicList. E) None of the above

C) list.

C++ allows you to overload A) undefined variables. B) compiler errors. C) operators and functions. D) preprocessor directives. E) None of the above

C) operators and functions.

In many recursive operations on linked lists, A) the base case considers the last element of the list. B) the head of the list is chopped off and thrown away. C) the base case is when the list is empty or has a single element. D) All of the above E) None of the above

C) the base case is when the list is empty or has a single element.

The Standard Template Library offers a stack template that may be implemented as a A) vector. B) linked list. C) deque. D) All of the above E) None of the above

D) All of the above

The queue data structure is commonly applied in connection with A) operating systems. B) communications software. C) managing the order of print jobs. D) All of the above E) None of the above

D) All of the above

The list container provided by the Standard Template Library is a template version of a A) singly-linked list. B) backward-linked list. C) circular-linked list. D) doubly-linked list. E) None of the above

D) doubly-linked list.

The ________ operation allows an item to be stored on a stack. A) pop B) add C) append D) push E) None of the above

D) push

If the head pointer points to NULL, it is an indication that A) the list needs to be destroyed. B) the list has been destroyed. C) the list is full and cannot accept any new nodes. D) there are no nodes in the list. E) None of the above

D) there are no nodes in the list.

Moving through a linked list is referred to as ________ the list. A) alternating B) node-hopping C) cruising D) traversing E) None of the above

D) traversing


Conjuntos de estudio relacionados

PSYCH 137J Self and Identity Midterm

View Set

Span 121-1 Cap 2 Vocab- University of the Future Section

View Set

Nutrition Ch.3 Digestion and absorption

View Set