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

Assume that IntQueue is an integer queue. void fun(int n) { IntQueue q = new Int

ID: 3556161 • Letter: A

Question

Assume that IntQueue is an integer queue.

void fun(int n)

{

    IntQueue q = new IntQueue();

    q.enqueue(0);

    q.enqueue(1);

    for (int i = 0; i < n; i++)

    {

        int a = q.dequeue();

        int b = q.dequeue();

        q.enqueue(b);

        q.enqueue(a + b);

        ptint(a);

    }

}

What does the function fun do?

a) Prints first n Fibonacci numbers

b) Prints numbers from 0 to n-1

c) Prints numbers from n-1 to 0

d) Prints first n Fibonacci numbers in reverse order

void fun(int n)

{

    IntQueue q = new IntQueue();

    q.enqueue(0);

    q.enqueue(1);

    for (int i = 0; i < n; i++)

    {

        int a = q.dequeue();

        int b = q.dequeue();

        q.enqueue(b);

        q.enqueue(a + b);

        ptint(a);

    }

}

What does the function fun do?

a) Prints first n Fibonacci numbers

b) Prints numbers from 0 to n-1

c) Prints numbers from n-1 to 0

d) Prints first n Fibonacci numbers in reverse order

Explanation / Answer

Ans.

a) Prints first n Fibonacci numbers

0,1,1,2,3...

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