Purchase Solution

C++ explained in this solution

Not what you're looking for?

Ask Custom Question

C++. See attached file for full problem description. Thank you so much!

Question 31
A queue is modeled on a ____ structure.

LIFO

FIFO

stack

list

Question 32

The function deleteQueue does which of the following?

uses one queue to delete another

removes the back element from the queue

removes the front element from the queue

removes all elements from the queue leaving an empty queue

Question 33

Refer to the figure above. Which of the following members from the UML diagram removes an element from the front of the queue?

destroyQueue

front

deleteQueue

removeQueue

Question 34

int func2(int m, int n) {
if (n == 0)
return 0;
else
return m + func2(m, n-1);
}

What is the output of func2(3, 2)?

2

3

5

6

Question 35

int func1(int m, int n) {
if (m==n || n==1)
return 1;
else
return func1(m-1,n-1) + n*func1(m-1,n);
}

What precondition must exist in order to prevent the code above from infinite recursion?

m > = 0 and n >= 0

m >= 0 and n >= 1

m >= 1 and n >= 0

m >= 1 and n >= 1

Question 36

int func3(int m, int n) {
if (m < n)
return 0;
else
return 1 + func3(m-n, n);
}

What is the value of func3(-5, 1), based on the code above?

-5

0

1

5

Question 37

Assume there are four functions A, B, C, and D. If function A calls function B, function B calls function C, function C calls function D, and function D calls function A, which of the following functions is indirectly recursive?

A

B

C

D

Question 38

int func1(int m, int n) {
if (m==n || n==1)
return 1;
else
return func1(m-1,n-1) + n*func1(m-1,n);
}

Based on the function above, what is the value of func1(4, 2)?

3

5

7

9

Question 39

void decToBin(int num, int base)
{
if(num > 0)
{
decToBin(num/base, base);
cout<<num % base;
}
}

Based on the code above, which of the following calls to the function would produce the result 1001?

decToBin(4, 2)

decToBin(2, 4)

decToBin(9, 2)

decToBin(8, 1)

Question 40

int func2(int m, int n) {
if (n == 0)
return 0;
else
return m + func2(m, n-1);
}

What is the limiting condition of the code above?

n >= 0

m > n

m >= 0

n > m

Attachments
Purchase this Solution

Solution Summary

C++ is explained in the solution.

Solution Preview

31. Answer: B
FIFO: First In First Out

32. Answer: C
Remove the front element from the queue

33. Answer: C
deleteQueue

34. ...

Purchase this Solution


Free BrainMass Quizzes
Inserting and deleting in a linked list

This quiz tests your understanding of how to insert and delete elements in a linked list. Understanding of the use of linked lists, and the related performance aspects, is an important fundamental skill of computer science data structures.

Word 2010: Table of Contents

Ever wondered where a Table of Contents in a Word document comes from? Maybe you need a refresher on the topic? This quiz will remind you of the keywords and options used when working with a T.O.C. in Word 2010.

Basic Networking Questions

This quiz consists of some basic networking questions.

Javscript Basics

Quiz on basics of javascript programming language.

C# variables and classes

This quiz contains questions about C# classes and variables.