logo

Crowdly

12-FILS-L-A1-S2: Data Structures and Algorithms (CTI E, IETTI E 2024)

Looking for 12-FILS-L-A1-S2: Data Structures and Algorithms (CTI E, IETTI E 2024) test answers and solutions? Browse our comprehensive collection of verified answers for 12-FILS-L-A1-S2: Data Structures and Algorithms (CTI E, IETTI E 2024) at curs.upb.ro.

Get instant access to accurate answers and detailed explanations for your course questions. Our community-driven platform helps students succeed!

At

each iteration, the loop counter i is either printed or put on a

stack

depending on the result of the boolean function f (); s is an object of type

Stack previously implemented. Because of the logical properties of a stack

, the

below code cannot print certain sequences of the values of the loop counter. Is

it possible the code segment could generate the output “13542”? Choose one

answer.

for (i=1;i<=5;i++)                                                                 

if (f()) cout<<i;                                                      

else s.push(i);                                                       

while (!s.isEmpty())

{              

cout<<s.peek();

s.pop();        

 }

View this question

Consider

and empty

queue

Q, implemented with a circular array of N = 2 positions. What

is the output of the following piece of code? Choose one answer.

Queue

<char> q; q.

enqueue (‘h’); q. enqueue (‘i’); q. enqueue (‘o’); q. enqueue (‘u’); q.

dequeue(); q. enqueue (‘t’); q. enqueue (‘p’); q. dequeue(); q. enqueue (‘a’);

cout<<

queue.peek();

View this question

Consider the usual algorithm for determining

whether a sequence of parentheses is balanced. What is the maximum number of

parentheses that will appear on the

stack

AT ANY ONE TIME when the algorithm

analyzes:  (()(())(()))?

View this question

What does the remove

method do regarding priority queues?

View this question

Consider the

following pseudo code. Assume that IntQueue is an integer

queue

. What does the

function fun do?

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);

    }

}

View this question

Indicate

the applications for which a

queue would be a suitable data structure?

View this question

Popping in a stack

means:

View this question

Suppose we have a circular array

implementation of the

queue class, with ten items in the queue

stored at

data[2] through data[11]. The current capacity is 42. Where does the insert

method place the new entry in the array?

View this question

What is the value of the postfix

expression 6 3 2 4 + - * :

View this question

Following is C++ like

pseudo code of a function that takes a

Queue as an argument, and uses a stack

S

to do processing. What does the below function do in general?

void fun(Queue *Q)

{

   

Stack

S;  // Say it creates an

empty

stack S

 

   

// Run while Q is not empty

   

while (!isEmpty(Q))

   

{

       

// deQueue an item from Q and push the dequeued item to S

       

push(&S, deQueue(Q));

   

}

 

   

// Run while

Stack S is not empty

    while (!isEmpty(&S))

   

{

     

// Pop an item from S and enqueue the poppped item to Q

     

enQueue(Q, pop(&S));

   

}

}

View this question

Want instant access to all verified answers on curs.upb.ro?

Get Unlimited Answers To Exam Questions - Install Crowdly Extension Now!