Question: SOLVE PLEASE EXPERTS ONLY : Homework 1 ( Data Structures, Fall 2 0 2 4 ) Due: 1 6 t h September 2 0 2

SOLVE PLEASE EXPERTS ONLY :
Homework 1(Data Structures, Fall 2024) Due: 16th September 2024(11:59 PM)
Q1)(a) What's is the result of the following postfix? Show the stack at the various stages of scanning the input postfix, the way it was done in class. (Each time the stack changes, show the stack).
62+153-i+i
(b) In O-notation, what is the time complexity of this algorithm that evaluates postfix expressions (Where n is the length of the given postfix string).
Q2)(a) Write a function: "reverseStack(Stack st", which prints the contents of the stack st in reverse (i.e., the top of the stack is printed last).
You are allowed only to use another stack, "Stack st2". That is, you cannot use any arrays etc. The only functions you can use on stacks are pop(), push() and empty().(Hint: You put the contents of one stack into another by popping and pushing. Is the order the same?)
(b) Let n be the length of the input stack. Let k be the total number of times you had to push and pop from the two stacks. Express k in terms of n. What is the complexity of this reversing algorithm in O-notation?
Q3) Consider the following nested loop:(a) How many times is " j=j+10" executed? (Do not ignore any constants, as we are not talking about the O-notation yet).(b) In the code shown above, answer (a), if we replace " j=j+10", with " j= j/4".(c) Answer (a), if we make the following two changes to the code: We replace " i++" with "i*=2", as well as we replace " j=j+10" with " j=j//4".
Q4) Order the following functions in ascending order of growth (That is, the function that grows the slowest growing function comes first) :
n+5,n13,n2log(n),(1.1)n,n2.5,(log5n2)3
NOTE: log(nk)=klog(n), and therefore have the same order of growth. However, (logn)k of course has a different order of growth as you would already know.

Step by Step Solution

There are 3 Steps involved in it

1 Expert Approved Answer
Step: 1 Unlock blur-text-image
Question Has Been Solved by an Expert!

Get step-by-step solutions from verified subject matter experts

Step: 2 Unlock
Step: 3 Unlock

Students Have Also Explored These Related Programming Questions!