questions
very urgent
1. Let the contents of a queue Q[] be 25, 32, 48, 55, 77 with 25 at the rear end and 77 at front. Let Q.enqueue() and Q.dequeue() be the standard enqueue and dequeue func- tions respectively. Consider the following pseudocode. Assuming the array Q to be sufficiently large (queue never becomes full), describe the queue (contents) by the end of the following sequence of operations. temp < Q.dequeue() + Q.dequcuc() temp + temp/11 Q.enqucuc(temp) Q.enqueue(Q.dequeue)
5. Consider the following Algorithm Task(A,n). Assume array A[O...n - 1) contains n distinct positive values. Identify the best case and worst-case performance scenarios, estimate the number of primitive operations in both cases, and hence express the corre- sponding running times (both best and worst) of the algorithm using big-O notation. 1 function TASK(A,n) for j < 1 to n-1 do k Aj id j-1 while i > 0 and A > k do print Ai 1 end while j{ j +1 end for funeftan
please answer both the 1. Let the contents of a queue Q[] be 25, 32, 48, 55, 77 with 25 at the rear end and 77 at front. Let Q.enqueue() and Q.
-
- Site Admin
- Posts: 899603
- Joined: Mon Aug 02, 2021 8:13 am