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

Question 1 (1 point) What would be the results of f(1) for the following functio

ID: 3736861 • Letter: Q

Question

Question 1 (1 point)

What would be the results of f(1) for the following function?


function f(n) {
if (n == 4) return n;
return 2*f(n+1);
}

Question 1 options:

1)

2)

3)

4)

Save

Question 2 (1 point)

A ______ sort examines the data only by comparing the two elements with a comparison operator.

Question 2 options:

Save

Question 3 (1 point)

What is the output of the following function if called with the argument doFun2(8)?


function doFun2(n) {
// Enqueue is equivalent to push, Dequeue is equivalent to shift
var q = [];
q.push(0); q.push(1);
for (var i = 0; i < n; i++ ){
var a = q.shift();
var b = q.shift();
q.push(b);
q.push(a + b);
}
return q.pop();
}

Question 3 options:

Save

Question 4 (1 point)

The value 356 will place into which slot 0-9 in a hash table using the hash function h(k) = k mod 10

Your Answer:Question 4 options:

Save

Question 5 (1 point)

Which one of the following hash functions on integers will distribute keys most uniformly over 10 buckets numbered 0 to 9 for i ranging from 0 to 2020?

Question 5 options:

1)

2)

3)

4)

Save

Question 6 (1 point)

Given a hash table T with 25 slots that stores 2000 elements, the load factor for T is __________

Question 6 options:

1)

2)

3)

4)

Save

Question 7 (1 point)

Consider a hash function that distributes keys uniformly. The hash table size is 20. After hashing of how many keys will the probability that any new key hashed collides with an existing one exceed 0.5.

Question 7 options:

1)

2)

3)

4)

Save

Question 8 (1 point)

A hash function takes a message of fixed length and generates a code of variable length.

Question 8 options:

Save

Question 9 (1 point)

Consider a hash table with 100 slots. Collisions are resolved using chaining. Assuming simple uniform hashing, what is the probability that the first 3 slots are unfilled after the first 3 insertions?

Question 9 options:

1)

2)

3)

4)

Save

Question 10 (1 point)

If a hash table has 10 slots (0-9) and a random integer between 0 and 9 is placed in the table - what is the probability that slot 0 is unfilled using hash function h(k) = k mod 10?

Question 10 options:

1)

2)

3)

4)

Save

1)

4

2)

8

3)

16

4)

32

Explanation / Answer

If you post more than 1 question, as per chegg guidelines I have to solve only the first question.

Ques 1. Answer : (d) 32

f(1)

return 2 * f(2)

f(2)

return 2 * f(3)

f(3)

return 2 * f(4)

f(4)

return 4

So, now

f(1)

return 2 * ( 2 * ( 2 * ( 4 ) ) )

So, f(1) returns 32.

Question : Answer : Comparison Sort

We compare two elements in comparison sort.

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