• Shuffle
    Toggle On
    Toggle Off
  • Alphabetize
    Toggle On
    Toggle Off
  • Front First
    Toggle On
    Toggle Off
  • Both Sides
    Toggle On
    Toggle Off
  • Read
    Toggle On
    Toggle Off
Reading...
Front

Card Range To Study

through

image

Play button

image

Play button

image

Progress

1/120

Click to flip

Use LEFT and RIGHT arrow keys to navigate between flashcards;

Use UP and DOWN arrow keys to flip the card;

H to show hint;

A reads text to speech;

120 Cards in this Set

  • Front
  • Back

A is a class and B is a new class derived from A. Also, we have these variables: A a; B b; B b1; B b2;Consider the assignment statement a=b;. Which answer is true?

The assignment statement activates the A assignment operator.

What is the term used to describe the situation when a derived class provides a function already provided in the base class?

Overriding.

How are loops represented in an edge-list representation of a graph?

A vertex will be on its own edge-list.

How many linked lists are used to represent a graph with n nodes and m edges, when using an edge list representation,

n

There are many potential uses for derived classes, but one of the most frequent uses comes from the is-a relationship. “A is-a B” means that ___________________________________________________.

each A object is a particular kind of B object

What is the best actions describtion of the the automatic destructor for a derived class?

The automatic destructor first calls the destructor for any member variables of the derived class, and then calls the destructor for the base class.

Which statement of the following is the most appropriate one?

The connection between a derived class and its base class can often be characterized by the is-a relationship. For example, an herbivore is-a particular kind of animal, so it makes sense to implement herbivore as a derived class of the animal base class.

Which statement of the following is the most appropriate one?

Object-oriented programming supports reusable components by permitting new derived classes to be declared, which automatically inherit all members of an existing base class.

the members that the derived class receives from its base class are called ____________________,

inherited members

What is the initial fish size in the Pond Life Simulation of figure 14.10?

300

What would be the best implementation of a derived class called daylight_clock? A daylight clock is like a clock except that it has one extra boolean member function to determine whether it is currently daylight. Assume that daylight stretches from 7:00 A.M. through 6:59 P.M.

class daylight_clock : public clock{ public: bool is_day( ) const;};bool daylight_clock::is_day( ) const{ if (is_morning( )) return (get_hour( ) >= 7); else return (get_hour( ) < 7);}

What does "#include "organism.h"" do in the Figure 14.6?

It provides the organism class

A vertex in a directed graph has an in-degree, which is the number of edges with v as the target vertex, and an in-degree, which is the number of edges with v as their source vertex. What is the in-degree of Melbourne in the following airline graph?

A vertex in a directed graph has an in-degree, which is the number of edges with v as the target vertex, and an in-degree, which is the number of edges with v as their source vertex. What is the in-degree of Melbourne in the following airline graph?

3

The degree of a vertex v in an undirected graph is the number of times v is an endpoint of an edge. A loop at the vertex contributes twice to the degree. What is the degree of  vertex a in the graph in the margin?

The degree of a vertex v in an undirected graph is the number of times v is an endpoint of an edge. A loop at the vertex contributes twice to the degree. What is the degree of vertex a in the graph in the margin?

5

How many loops does the following airline graph have?

How many loops does the following airline graph have?

0

Suppose that g is a graph with integer labels. The statements are as following and executed one after another, and i is an integer variable. What is the label of vertex 3 and i at the Point 2 marked here?g[3] = 42; // Point 1i = g[3]; // Point 2i = 43; // Point 3

The label is 42 and i is 42.

The degree of a vertex v in an undirected graph is the number of times v is an endpoint of an edge. A loop at the vertex contributes twice to the degree. What is the degree of  vertex b in the graph in the margin?

The degree of a vertex v in an undirected graph is the number of times v is an endpoint of an edge. A loop at the vertex contributes twice to the degree. What is the degree of vertex b in the graph in the margin?

2

Suppose that g is a graph with integer labels. The statements are as following and executed one after another, and i is an integer variable. What is the label of vertex 3 and i at the Point 3 marked here?g[3] = 42; // Point 1i = g[3]; // Point 2i = 43; // Point 3

The label is 42 and i is 43.

What is the depth-first search of the following graph, starting at Sydney?  List the order in which the cities are processed.

What is the depth-first search of the following graph, starting at Sydney? List the order in which the cities are processed.

Sydney, Canberra, Adelaide, Melbourne, Hobart, Perth, Black Stump, Darwin, Brisbane

Consider the following adjacency matrix, which node has the highest out-degree?

Consider the following adjacency matrix, which node has the highest out-degree?

note 0.

A is a class and B is a new class derived from A. Also, we have these variables: A a; B b; B b1; B b2;What C++ syntax is used to declare that a class B is derived from class A?

class B : public A { ... };

A is a class and B is a new class derived from A. Also, we have these variables: A a; B b; B b1; B b2;Consider the declarations above. Suppose there are two functions: f has an argument of type A and g has an argument of type B. Which statement is correct?

f(a) is legal, but g(a) is not legal.

What graph traversal algorithm uses a queue to keep track of vertices which need to be processed?

Breadth-first search

A simple graph has no loops. What other property must a simple graph have?

It must have no multiple edges.

Object-oriented languages provide support that allows programmers to easily create new classes that acquire some or many of their properties from an existing class. The original class is called the ________________.

base class

What is the benefit of a Well-Written Base Class?

With a well-written base class in hand, a programmer can write derived classes without worrying about how the base class accomplishes its work.

Suppose a derived class does not declare any constructors of its own. What constructors is it given automatically?

The derived class receives an automatic default constructor (which calls the default constructor for the base class and then calls the default constructor for any member variables of the derived class). The derived class also receives an automatic copy constructor (which calls the copy constructor for the base class and then calls the copy constructor for any member variables of the derived class).

What is one situation where a virtual member function is required?

The base class has a member function f, which activates another member function g. This g member function will be overridden in a derived class. When an object of the derived class activates f, it will use the base class version of f. But within f, we want it to use the overridden g from the derived class.

What does "#include "organism.h"" do in the Figure 14.10?

It provides herbivore, plant classes

If jacket is a derived class of clothes, are the following statements legal? Why or why not? clothes coat;jacket blazer;blazer = coat;

The assignment is not legal, because an object of the base class (coat) cannot be used as if it were an object of the derived class.

What is AVERAGE_NIBBLES for in the Pond Life Simulation of figure 14.10?

Average number of plants nibbled by a fish over one week.

What statement about the automatic default constructor is the most accurate?

If we don’t declare any constructors for a derived class, then C++ will automatically provide a default constructor. This default constructor will carry out two steps: (1) activate the default constructorfor the base class (to initialize any member variables that the base class uses), then (2) activate default constructors for any new member variables that the derived class has, but the base class does not have.

A cycle in a directed graph is a path that begins and ends at the same vertex.  The length of the cycle is the number of edges. Which of the following has a length of 5 in the following airline graph?

A cycle in a directed graph is a path that begins and ends at the same vertex. The length of the cycle is the number of edges. Which of the following has a length of 5 in the following airline graph?

Canberra, Adelaide, Perth, Black Stump, Darwin, Canberra

A vertex in a directed graph has an in-degree, which is the number of edges with v as the target vertex, and an in-degree, which is the number of edges with v as their source vertex. What is the out-degree of Sydney in the following airline graph?

A vertex in a directed graph has an in-degree, which is the number of edges with v as the target vertex, and an in-degree, which is the number of edges with v as their source vertex. What is the out-degree of Sydney in the following airline graph?

2

Which statement of the following is the most appropriate one?

There are two common ways to implement a graph: an adjacency matrix or an edge list. The different implementations have different time performance for common operations such as determining whether two vertices reconnected.

Which statement of the following is the most appropriate one?

Dijkstra’s algorithm provides an efficient way to determine the shortest path from a given start vertex to every other vertex in a graph with weighted edges.

A cycle in a directed graph is a path that begins and ends at the same vertex.  The length of the cycle is the number of edges. Which of the following has a length of 3 in the following airline graph?

A cycle in a directed graph is a path that begins and ends at the same vertex. The length of the cycle is the number of edges. Which of the following has a length of 3 in the following airline graph?

Sydney, Melbourne, Canberra, Sydney

What statement about a depth-first or breadth-first search process all vertices in a graph is the most appropriate?

They are not always searching and processing all vertices in a graph. A vertex v in a graph will not be processed by a DFS or BFS if there is no path from the start vertex to v.

A cycle in a directed graph is a path that begins and ends at the same vertex.  The length of the cycle is the number of edges. Which of the following has a length of 3 in the following airline graph?

A cycle in a directed graph is a path that begins and ends at the same vertex. The length of the cycle is the number of edges. Which of the following has a length of 3 in the following airline graph?

Sydney, Canberra, Brisbane, Sydney

Using the Shortest-Path Algorithm to go through the following graph what would be the actual shortest path from vertex 0 to vertex 3?

Using the Shortest-Path Algorithm to go through the following graph what would be the actual shortest path from vertex 0 to vertex 3?

The shortest distance is 11. The path is vertex 0 to vertex 1, vertex 1 to vertex 2, vertex 2 to vertex 3

Suppose you were going to quickly implement a Stack class as a derived class. Why would it be likely that the base class would be a private base class?

You would not want to have all of the base classes public member functions be public member functions of the stack.

If a class B is derived from A, then which of the following terms describes A?

All of the above

Which of the following statements is true?

Graph vertices may be linked in any manner.

If G is an directed graph with 20 vertices, how many boolean values will be needed to represent G using an adjacency matrix?

400

What is alpha-beta pruning?

Alpha-beta pruning is the process of stopping an evaluation, such as a minimax search, if it cannot produce a better solution than one that has already been determined.

Relationships are drawn in a tree called an ________________________. In this tree, each base class is placed as the parent of its derived classes.

object hierarchy tree

Object-oriented languages provide support that allows programmers to easily create new classes that acquire some or many of their properties from an existing class. The new, slightly different class is the __________________.

subclass

What statement about death function in section 14.2 is the most accurate?

The organism’s current size and growth rate have been set to zero.

Where can a protected member of a class be used?

A protected member can be used and overridden by a derived class but cannot be used outside of a derived class.

What statement about total_mass function in section 14.10 is the most accurate?

The return value is the total mass of all the plants in the collection.

What would be the best statement about set_time function of clock class in section 14.1?

Before comming into this function the hour need to be greater than or equal 1 and less than and equal 12, and the minute need to be greater than or equal to 1 and less than and equal to 59. The function should set the given hour and minute . If the third parameter, morning, is true, then this time is from 12:00 midnight to 11:59 A.M. Otherwise this time is from 12:00 noon to 11:59 P.M.

What is the best actions describtion of the the automatic assignment operator for a derived class?

The automatic assignment operator calls the assignment operator for the base class and then calls the assignment operator for any member variables of the derived class.

A cycle in a directed graph is a path that begins and ends at the same vertex. The length of the cycle is the number of edges. Which of the following has a length of 3 in the following airline graph?

Canberra, Brisbane, Sydney, Canberra

The following graph except changes the weight of the edge that goes from 0 to 5. Its new weight is 4. Using the Shortest-Path Algorithm to go through the new graph what would be the actual shortest path from vertex 0 to vertex 3?

The following graph except changes the weight of the edge that goes from 0 to 5. Its new weight is 4. Using the Shortest-Path Algorithm to go through the new graph what would be the actual shortest path from vertex 0 to vertex 3?

The shortest distance is 10. The path is vertex 0 to vertex 5, vertex 5 to vertex 4, vertex 4 to vertex 3.

The following graph except changes the weight of the edge that goes from 0 to 5. Its new weight is 4. Using the Shortest-Path Algorithm to go through the new graph what would be the distance array?

The following graph except changes the weight of the edge that goes from 0 to 5. Its new weight is 4. Using the Shortest-Path Algorithm to go through the new graph what would be the distance array?

Using the Shortest-Path Algorithm to go through the following graph what would be the distance array?

Using the Shortest-Path Algorithm to go through the following graph what would be the distance array?

What would be the adjacency matrix for the graph below?

What would be the adjacency matrix for the graph below?

A vertex in a directed graph has an in-degree, which is the number of edges with v as the target vertex, and an out-degree, which is the number of edges with v as their source vertex. What is the in-degree of Canberra in the following airline graph?

A vertex in a directed graph has an in-degree, which is the number of edges with v as the target vertex, and an out-degree, which is the number of edges with v as their source vertex. What is the in-degree of Canberra in the following airline graph?

3

A vertex in a directed graph has an in-degree, which is the number of edges with v as the target vertex, and an out-degree, which is the number of edges with v as their source vertex. What is the out-degree of Canberra in the following airline graph?

3

How many edges does the following airline graph have?

14

A is a class and B is a new class derived from A. Also, we have these variables: A a; B b; B b1; B b2;Consider the declarations above. Suppose there are two functions: f has an argument of type A and g has an argument of type B. Which statement is correct?

Both f(b) and g(b) are legal function calls.

Suppose you were going to quickly implement a Stack class. What class would be the best base class?

List.

Suppose you have a game with 5 coins in a row and each coin can be heads or tails. What number of vertices might you expect to find in the state graph?

32

Why is the state graph for tic-tac-toe a directed graph rather than an undirected graph?

Once a move is made, it cannot be unmade.

What would be the best statement about advance function of clock class in section 14.1?

After this function the clock has been moved forward by the indicated number of minutes. A negative argument moves the clock backward.

What statement about simulate_week function in section 14.2 is the most accurate?

After the functiuon the size of the organism has been changed by its current growth rate. If the new size is less than zero, then the actual size is set to zero rather than to a negative value, and the growth rate is also set to zero.

What statement about get_rate function in section 14.2 is the most accurate?

The value returned is the organism’s current growth rate (in oz/week).

What statement about a private base class is the most accurate?

The public members of the base class are available to the derived class. In a private base class, the public members of the base class are only available as private members of the derived class.

Object-oriented languages provide support that allows programmers to easily create new classes that acquire some or many of their properties from an existing class. The new, slightly different class is the __________________.

child class

What is the initial weeds size in the Pond Life Simulation of figure 14.10?

2000

Object-oriented languages provide support that allows programmers to easily create new classes that acquire some or many of their properties from an existing class. The original class is called the ________________.

ancestor class

Which statement of the following is the most appropriate one?

An abstract base class (such as the game class) can provide a common framework that is needed by many derived classes. An abstract base class has one or more pure virtual functions, which are functions that must be overridden before the class can be used.

Suppose you are doing a breadth-first search of a graph with n vertices. How large can the queue get?

If n is 1, then the queue needs room for only one vertex. If n is more than 1, then the queue will never have more than n–1 entries.

The degree of a vertex v in an undirected graph is the number of times v is an endpoint of an edge. A loop at the vertex contributes twice to the degree. What is the degree of vertex e in the graph in the margin?

3

Suppose that g is a graph with integer labels. The statements are as following and executed one after another, and i is an integer variable. What is the label of vertex 3 and i at the Point 1 marked here?g[3] = 42; // Point 1i = g[3]; // Point 2i = 43; // Point 3

The label is 42 and i is unknown.

How would you interpret a loop in the following graph?

A loop would be an excursion flight that takes off and lands at the same city.

Consider the following adjacency matrix where is (are) loop(s) in the graph?

Consider the following adjacency matrix where is (are) loop(s) in the graph?

vertex 1 and 3.

Is the following airline graph a directed graph and the reason?

It is a directed graph because each edge (drawn as an arrow) has an orientation, going from its source to its target.

What would be the adjacency matrix for the graph below?

What would be the adjacency matrix for the graph below?

Consider the following adjacency matrix, which node has the highest in-degree?

Consider the following adjacency matrix, which node has the highest in-degree?

note 0.

A is a class and B is a new class derived from A. Also, we have these variables: A a; B b; B b1; B b2;Using the variable declarations at the top of this section, which of the following assignment statements are legal?

Both (1) and (3) are legal, but not 2).

Consider the assignment statement b=a; (with the variable declarations at the top of this section). Which answer is true?

The assignment statement is illegal.

What is the expected number of operations needed to loop through all the edges terminating at a particular vertex given an adjacency matrix representation of the graph? (Assume n vertices are in the graph and m edges terminate at the desired node.)

O(n)

Suppose you have a directed graph representing all the flights that an airline flies. What algorithm might be used to find the best sequence of connections from one city to another?

A shortest-path algorithm

What would be the best statement about get_minute function of clock class in section 14.1?

The value returned is the current minute on the clock.

What statement about the automatic copy constructor is the most accurate?

If a derived class does not define a copy constructor of its own, then C++ will automatically provide a copy constructor. This copy constructor is similar to the automatic default constructor in that itcarries out two steps: (1) Activate the copy constructor for the base class (to copy any member variables that the base class uses), then (2) activate copy constructors for any new member variables that the derived class has but the base class does not have. The copy constructors that are activated in Steps 1 and 2 may

What statement about is_alive function in section 14.2 is the most accurate?

If the current size is greater than zero, then the return value is true. Otherwise the return value is false.

Object-oriented languages provide support that allows programmers to easily create new classes that acquire some or many of their properties from an existing class. The original class is called the ________________.

parent class

What would be the best statement about is_morning function of clock class in section 14.1?

After this function if the clock’s time lies from 12:00 midnight to 11:59 A.M. (inclusive), the function returns true; otherwise it returns false.

What statement about a public base class is the most accurate?

The public members of the base class are available to the derived class. In a public base class, the public members are available as public members of the derived class.

Which statement of the following is the most appropriate one?

All members of a base class are inherited by the derived class, but only the nonprivate members of the base class can be accessed by the programmer who implements the derived class.

What statement about assign_need function in section 14.2 is the most accurate?

Before comming into this function new_need >= 0. After this function, the animal’s weekly food requirement has been changed to new_need (measured in ounces per week).

How many vertices does the following airline graph have?

9

The degree of a vertex v in an undirected graph is the number of times v is an endpoint of an edge. A loop at the vertex contributes twice to the degree. What is the degree of  vertex c in the graph in the margin?

The degree of a vertex v in an undirected graph is the number of times v is an endpoint of an edge. A loop at the vertex contributes twice to the degree. What is the degree of vertex c in the graph in the margin?

2

A vertex in a directed graph has an in-degree, which is the number of edges with v as the target vertex, and an in-degree, which is the number of edges with v as their source vertex. What is the out-degree of Melbourne in the following airline graph?

2

Consider the following adjacency matrix, which node has the highest out-degree?

Consider the following adjacency matrix, which node has the highest out-degree?

node 3.

A cycle in a directed graph is a path that begins and ends at the same vertex. The length of the cycle is the number of edges. Which of the following has a length of 4 in the following airline graph?

Sydney, Melbourne, Canberra, Brisbane, Sydney

Consider the following adjacency matrix where is (are) loop(s) in the graph?

Consider the following adjacency matrix where is (are) loop(s) in the graph?

vertex 0.

A cycle in a directed graph is a path that begins and ends at the same vertex. The length of the cycle is the number of edges. Which of the following has a length of 3 in the following airline graph?

Adelaide, Melbourne, Canberra, Adelaide

What would happen if the visited vertices were not marked in the breadth-first and depth-first search?

A traversal will loop indefinitely on a graph with a cycle if visited vertices are not marked

A is a class and B is a new class derived from A. Also, we have these variables: A a; B b; B b1; B b2;Consider the declarations above. Suppose there are two functions: f has an argument of type A and g has an argument of type B. Which statement is correct?

Both f(b) and g(b) are legal function calls.

Consider the assignment statement b=a; (with the variable declarations at the top of this section). Which answer is true?

The assignment statement is illegal.

If G is an directed graph with 20 vertices, how many boolean values will be needed to represent G using an adjacency matrix?

400

What is the expected number of operations needed to loop through all the edges terminating at a particular vertex given an adjacency matrix representation of the graph? (Assume n vertices are in the graph and m edges terminate at the desired node.)

O(n)

What would be the best statement about the clock constructor in section 14.1?

The clock is set to 12:00 (midnight).

What statement about simulate_week function in section 14.2 is the most accurate?

After the functiuon the size of the organism has been changed by its current growth rate. If the new size is less than zero, then the actual size is set to zero rather than to a negative value, and the growth rate is also set to zero.

What would be the best statement about get_hour function of clock class in section 14.1?

The value returned is the current hour using a 12-hour clock.

What is BIRTH_RATE for in the Pond Life Simulation of figure 14.10?

At the end of each week, some fish have babies. The total number of new fish born is the current number of fish times the BIRTH_RATE (rounded down to an integer).

What statement about the automatic constructors of a derived class is the most accurate?

A derived class may declare its own constructors, or it may use the automatic default constructor and the automatic copy constructor that are provided for every C++ class.

Object-oriented languages provide support that allows programmers to easily create new classes that acquire some or many of their properties from an existing class. The new, slightly different class is the __________________.

descendant class

Object-oriented languages provide support that allows programmers to easily create new classes that acquire some or many of their properties from an existing class. The new, slightly different class is the __________________.

derived class

Object-oriented languages provide support that allows programmers to easily create new classes that acquire some or many of their properties from an existing class. The original class is called the ________________.

superclass

The degree of a vertex v in an undirected graph is the number of times v is an endpoint of an edge. A loop at the vertex contributes twice to the degree. What is the degree of  vertex d in the graph in the margin?

The degree of a vertex v in an undirected graph is the number of times v is an endpoint of an edge. A loop at the vertex contributes twice to the degree. What is the degree of vertex d in the graph in the margin?

2

Consider the following adjacency matrix, which node has the highest in-degree?

Consider the following adjacency matrix, which node has the highest in-degree?

node 1

What is the breadth-first search of the following graph, starting at Sydney? List the order in which the cities are processed.

Sydney, Canberra, Melbourne, Adelaide, Brisbane, Hobart, Perth, Black Stump, Darwin

What value indicates that there is no path between vertices in Dijkstra’s algorithm?

The infinity symbol indicates that there is no path between two vertices.

What kind of search occurs if you replace a breadth-first search’s queue with a stack?

A depth-first search

Which statement of the following is the most appropriate one?

There are several different kinds of graphs: undirected graphs (where edges have no particular orientation), directed graphs (where each edge goes from a source vertex to a target vertex), graphs with loops (i.e., an edge connecting a vertex to itself), graphs with multiple edges (i.e., more than one edge may connect the same pair of vertices), labeled graphs (where each vertex has an associated label), and graphs with weighted edges (where each edge has an associated number called its weight).

A vertex in a directed graph has an in-degree, which is the number of edges with v as the target vertex, and an out-degree, which is the number of edges with v as their source vertex. What is the out-degree of Sydney in the following airline graph?

2

Which statement of the following is the most appropriate one?

Graphs are a flexible data structure with many occurrences in computer science and in applications. Many problems can be solved by asking an appropriate question about paths in a graph.