State the pseudo code and worst case running time to evaluate a prefix evaluation using a stack data structureState the pseudo code and worst case running time to evaluate a prefix evaluation using a stack data structure
Algorithm to evaluate prefix-expression
Step 1: start traversing expression from right to left
Step 2: If character at current position is an operand push it to
Stack
Step 3: If the character at current position is an operator pop two
operands from the Stack. Operate on these operands
according to the operator, and push the result to the Stack
Step 4: goto step-2 if complete expression is not traversed(or we reached at left end of expression).
finally,print value at the top of stack will give result of expression.
since we scan the expression once(right to left) and perform O(N) push(take O(1) time) and pop operations (take O(1) time)in worst case .
Therefore overall complexity = O(N)
State the pseudo code and worst case running time to evaluate a prefix evaluation using a...
Write the pseudo code for the linear maximum subsequence sum problem. State the worst-case running time for your problem.
Write the pseudo code for the linear maximum subsequence sum problem. State the worst-case running time for your problem. Please show the work and explain how you arrived at the answer. Thanks
What is the worst case running time of the following pseudo-code. void doSomething(int n, int m) { if(m> n) return; System.out.println("m=" + m); doSomething(n, m+2); } A o(n) B O(nlogn) C O(n2) D O(n+m) E None of the above
Give the psuedo code for inserting and deleting an element in a binary min heap and binary max heap data structure. Discuss the worst case running time for each pseudo code.
In Big-Θ notation, analyze the running time of the following pieces of code/pseudo-code. Describe the running time as a function of the input size (here, n) for(int i=n-1; i >=0; i--){ for(int k=0; k < i*n; k++){ // do something that takes O(1) time } }
Give the best-case and worst-case running time of SELECTION SORT in Θ notation, in details and with explanation
Write the pseudo code algorithm of the Radix sort and derive its Big -O running time.
In Big-Θ notation, analyze the running time of the following pieces of code/pseudo-code. Describe the running time as a function of the input size (here, n) int *a = new int [10]; // new is O(1) int size = 10; for (int i = 0; i < n; i ++) { if (i == size) { int newsize = 3*size/2; int *b = new int [newsize]; // new is O(1) for (int j = 0; j < size; j ++)...
Give an algorithm with the following properties. • Worst case running time of O(n 2 log(n)). • Average running time of Θ(n). • Best case running time of Ω(1).
1) What’s the (worst-case) running time of Hash Table Search for collision resolution by chaining? Express your answer in asymptotic notation. Use the standard notation where n is number of keys and m is number of slots. 2) What’s the (worst-case) running time of Hash Table Search for collision resolution by open-addressing? Express your answer in asymptotic notation. Use the standard notation where n is number of keys and m is number of slots. 3)What simple change in BucketSort can...