Academic Integrity: tutoring, explanations, and feedback — we don’t complete graded work or submit on a student’s behalf.

Hi chegg experts, i am currently stuck on this exam and any help on it would be

ID: 3577240 • Letter: H

Question

Hi chegg experts, i am currently stuck on this exam and any help on it would be appreciated.

Question 1

Consider this function declaration:

    void quiz (int i)

    {

        if (i > 1)

        {

            quiz (i / 2);

            quiz (i / 2);

        }

        cout << "*";

    }

How many asterisks are printed by the function call quiz(5)?

3

4

7

8

Question 2

In a single function declaration, what is the maximum number of statements that may be recursive calls?

1

2

n (where n is the function argument)

There is no fixed maximum

Question 3

Consider this prototype for a template function:

          template <class Item>

          void foo(Item x);

Which is the right way to call the foo function with an integer argument named i?

int i = 5;

foo<int>( i );



foo<Item>(i );



foo(<int> i );

int i = 5;

foo(i );


Question 4

When is insertion sort a good choice for sorting an array?

The array has only a few items out of place.

Each component of the array requires a large amount of memory.

The processor speed is fast.

Each component of the array requires a small amount of memory.

Question 5

In the linked list implementation of the queue class, where should the push member function place the new entry on the linked list?

Either the head or the tail

In sorted order

At the tail

At the head

Question 6

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

Depth-first search.

Breadth-first search.

Question 7

Consider the following function. How would the output that is generated with the call test_a(4) be
different if the cout line were listed after the recursive call in this function?
void test_a(int n)
{
cout << n << " ";
if (n>0)
test_a(n-2);
}

The integers would print in descending order instead of in ascending order.

There would be no difference in the output of this function.

The recursive call would never execute because the base case would be true immediately.

The integers would print in ascending order instead of in descending order.

Question 8

What is the best definition of a collision in a hash table?

Two entries with different keys have the same exact hash value.

Two entries with different data have the exact same key.

Two entries with the exact same key have different hash values.

Two entries are identical except for their keys.

Question 9

Which of the following is the least efficient way to sort a million 32 bit integers?

Quick sort

Bubble sort

Merge sort

Question 10

A(n) ________________ connects two nodes in a graph.

linkage

edge

object

node

Question 11

The std::binary_search function will test if a value exists in sorted sequence. It returns true if any element in the range [first,last] is equivalent to that value, and false otherwise.

True

False

Question 12

I have implemented the queue with a linked list, keeping track of a front pointer and a rear pointer.
which of these pointers will change during a deletion operation?

Only front_ptr changes.

Neither changes

Both change.

Only rear_ptr changes.

Question 13

Suppose we remove the root, replacing it with something from the left subtree. What will be the new root?

1

2

4

5

Question 14

In an open-address hash table there is a difference between those spots which have never been used and those spots which have previously been used but no longer contain an item. Which function has a better implementation because of this difference?

size

insert

is_present

remove

Two or more of the above functions

Question 15

The _______________ may be selected in the quicksort algorithm for comparison purposes.

last element

middle element

random element

Any of the above

Question 16

You have a stack of 10 items and you wish to do a pop operation. Which element would be removed from the stack if it were implemented with an array?

index 0

index 10

index 9

index 1

Question 17

Which of the following statements regarding binary trees are true?

Every node has at most two children.

Every non-empty tree has exactly one root node.

Every non-root node has exactly one parent.

Every binary tree has at least one node.

Question 18

Which of the following statements is true?

A graph can drawn on paper in only one way.

A graph must have at least one vertex.

A graph must have at least one edge.

Graph vertices may be linked in any manner.

Question 19

Consider the following function. The line numbers are indicated on the left side for reference only and are not part of the code.

1 float p( float x, int n )
2 {
3 if ( n == 0 )
4 return 1;
5 else
6 return x * p( x, n – 1 );
7 }

The base case is shown on:

lines 5-6

lines 3-4

lines 3-6

line 1

Question 20

Which of the following problems would be best solved with a breadth-first search?

You need to find a valid path from one node to the next through a maze graph.

You need to find the closest node to node x that stores a value greater than 10.

You need to discover if there is a cycle in a graph.

Question 21

When an element is retrieved in a chained hash table:

an element is hashed to a position in the array, then a sequential search of the linked list at that position is performed.

each linked list in the table is searched, one by one, until the element is found

a sequential search is made from the hashed position through the array until the element is found

an element is hashed to a position in the array and if the element is not found in that location, the
search returns NULL.

Question 22

Consider the following function:

    void test_a(int n)

    {

       cout << n << " ";

       if (n>0)

          test_a(n-2);

    }

Which function call will result in the output: 4 2 0

test_a(0);

test_a(2);

test_a(4);

Question 23

0, 1, 4, 2, 3, 5, 6

0, 1, 4, 3, 6, 5

0, 1, 2, 3, 4, 5, 6

0, 1, 3, 5, 6, 4

Question 24

What is this an example of?

priority matrix

linked list

adjacency list

adjacency matrix

Question 25

int mysteryFunction(vector vec, int low, int high, int key)
{
if ( low > high )
{
return -1;
}
int mid = (low + high)/2;
if ( vec[mid] == key )
return mid;
else if ( vec[mid] > key )
return mysteryFunction(vec, low, mid-1, key);
else
return mysteryFunction(vec, mid+1, high, key);
}
What is this an example of?

in-order traversal of a binary search tree

circular array pop function

binary search function

binary search tree insert function

Question 26

Consider the following function. The line numbers are indicated on the left side for reference only and are not part of the code.

1 float p( float x, int n )
2 {
3 if ( n == 0 )
4 return 1;
5 else
6 return x * p( x, n – 1 );
7 }

The recursive case is shown on:

lines 3-4

lines 5-6

line 1

lines 3-6

Question 27

The _______ case is the case that stops recursion.

condition

blocking

base

recursive

Question 28

A(n) _____________ is a node in a graph.

pointer

vertical

vertex

edge

Question 29

Consider the following recursive function:

void quiz(int i)
{
if (i > 1)
{
quiz(i / 2);
quiz(i / 2);
}
cout << "*";
}

How many asterisks will print with this call:

quiz(0);

0

1

Question 30

Here is a small binary tree:

What is the order of nodes visited using a pre-order traversal?

1 2 3 14 7 10 11 40 30

1 3 2 7 10 40 30 11 14

14 2 1 3 11 10 7 30 40

1 2 3 7 10 11 14 30 40

Question 31

A queue should not be built with an array. A circular array would be a better implementation choice for this data structure.

True

False

Question 32

Mergesort makes two recursive calls. Which statement is true after these recursive calls finish, but before the merge step?

The array elements form a tree.

Elements in each half of the array are sorted among themselves.

Elements in the first half of the array are less than or equal to elements in the second half of the array.

Question 33

Consider the following graph:

In what order are the vertices visited for a depth-first search that starts at v0?

0, 4, 1, 6

0, 1, 3, 5, 6, 4, 2

0, 1, 3, 6, 5, 4

0, 2, 1, 3, 5, 6

Question 34

What additional requirement is placed on an array, so that binary search may be used to locate an entry?

The array's size must be a power of two.

The array elements must form a tree.

The array must have at least 2 entries.

The array must be sorted.

3

4

7

8

14 216 4

Explanation / Answer

Hi, friend, I have answered first 10 questions.

Please repost rest of questions in separate post.

Please let me know in case of any issue in answer of first 10.


1)
   Ans: 7

2)
   Ans: There is no fixed maximum
3)
   int i = 5;
   foo<int>( i );
4)
   The array has only a few items out of place.
5)
   At the tail
6)
   Breadth-first-search
7)
   The integers would print in ascending order instead of in descending order.
8)
   Two entries with different keys have the same exact hash value.
9)
   Bubble Sort
10)
   edage

Hire Me For All Your Tutoring Needs
Integrity-first tutoring: clear explanations, guidance, and feedback.
Drop an Email at
drjack9650@gmail.com
Chat Now And Get Quote