Ask Question, Ask an Expert

+61-413 786 465

info@mywordsolution.com

Ask Computer Engineering Expert

Q. Reverse the order of the elements on a stack S

   (i) by using two additional stacks

(ii) by using one additional queue.

Ans:      Let S be the stack having n number of elements. Now we need to reverse the elements of S (i) using the two additional stack S1 and S2

while not empty (S)

{       C=pop(S);

push(S1,C);

}

While not empty(S1)

{     C=pop(S1);

push(S2,C);

}

While not empty(S3)

{     C=pop(S3);

push(S,C);

}

(ii) using one additional queue Q

while not empty (S)

{       C=pop(S);

enque(Q,C);

}

While not empty(Q)

{     C=deque(Q);

push(S,C);

}

Computer Engineering, Engineering

  • Category:- Computer Engineering
  • Reference No.:- M9504020

Have any Question?


Related Questions in Computer Engineering

Question summary of what is legal and regulatory

Question : Summary of what is legal and regulatory obligations regarding data and information security. Summary of project initiation in the technology world.

A simple substitution cipher can be created by shifting a

A simple substitution cipher can be created by shifting a letter n positions in alphabetic order. For example, if the possible characters are the list [A...Za...z], a shift of three would translate A to D and Z to c. The ...

Explain that the biggest problems with adware is that it

Explain that the biggest problems with adware is that it slows down the computers its running on.

A bar wants to move into a new area they want to find out

A bar wants to move into a new area. They want to find out the average income of people in the area to set a price point. To estimate the income of the locals with an error of at most $5,000 at a 80% confidence level, wh ...

Given the following three months of data what is the

Given the following three months of data what is the coefficient of variation? t, R_t 1, 21.01% 2, -13.83% 3, 15.67% 4, 0.88% 5, -1.32% Express your answer in total return decimal format.

Program in cit is often times advantageous to be able to

*Program in C* It is often times advantageous to be able to transfer data between two arrays. Need a help with program (transfer.c) that add a range (by start index and end index) of numbers from array #1 to array #2 at ...

For this problem assume the box contains 5 blue balls 7 red

For this problem, assume the box contains 5 blue balls, 7 red balls, and 6 white balls, and that we choose two balls at random from the box. What is the probability of neither being blue given that neither is red?

There are sorted sequences l1 and l2 with 5 and 4 elements

There are sorted sequences L1 and L2, with 5 and 4 elements respectively. a) How many comparisons will it take to merge L1 and L2 in the best case? How many for worst case? Explain your answers. b)Let [54, 26, 93, 17, 77 ...

A single card is randomly drawn from one standard 52-card

A single card is randomly drawn from one standard 52-card deck of playing cards, and events C and D are as follows: C=the card drawn is a king; D-the card drawn is a heart. Find the probability of event C or event D occu ...

What is the difference between dekkers algorithm and igloo

What is the difference between Dekkers Algorithm and Igloo approach? Please provide examples that can explain this.

  • 4,153,160 Questions Asked
  • 13,132 Experts
  • 2,558,936 Questions Answered

Ask Experts for help!!

Looking for Assignment Help?

Start excelling in your Courses, Get help with Assignment

Write us your full requirement for evaluation and you will receive response within 20 minutes turnaround time.

Ask Now Help with Problems, Get a Best Answer

Why might a bank avoid the use of interest rate swaps even

Why might a bank avoid the use of interest rate swaps, even when the institution is exposed to significant interest rate

Describe the difference between zero coupon bonds and

Describe the difference between zero coupon bonds and coupon bonds. Under what conditions will a coupon bond sell at a p

Compute the present value of an annuity of 880 per year

Compute the present value of an annuity of $ 880 per year for 16 years, given a discount rate of 6 percent per annum. As

Compute the present value of an 1150 payment made in ten

Compute the present value of an $1,150 payment made in ten years when the discount rate is 12 percent. (Do not round int

Compute the present value of an annuity of 699 per year

Compute the present value of an annuity of $ 699 per year for 19 years, given a discount rate of 6 percent per annum. As