Ask Question, Ask an Expert

+61-413 786 465

info@mywordsolution.com

Ask Computer Engineering Expert

Assignment

In this lab, using C++, you will create two data structures: a stack and a queue. You will use STL containers to demonstrate basic ADTs.

Queue

For the queue, you will simulate a buffer. Remember it is first-in-first-out. The user will enter a number for the number of rounds to run your simulation. You need one function that randomly generates a number. You will also have a user specified percentage, and the function uses this percentage to randomly put the generated number in the buffer. For example, if the user enters 25, then there is a 25% chance of the randomly generated number been put into the queue. You will have another user specified percentage, which is the chance of a value being removed from the buffer. For example, if the user enters 50, then there is a 50% chance of the number in the buffer been removed in this round.

You need to record the length of the queue in each round. After each round of the simulation, calculate and display the average length of the queue. Equation to calculate the average length would be: ALi = (ALi-1 * (i-1) + Li ) / i, where ALi and ALi-1 are the average length in the ith and i-1th round and Li is queue length in the ith round. Does your buffer behave as expected, i.e. get longer if the input chance is greater, and get shorter if the removing chance is greater? Your program needs to handle the situation when the queue is empty and still try to remove a value. You can start the simulation with a queue of certain length.

Stack

Use a stack to create a function that creates a palindrome, i.e. a string that is the same forwards and backwards. It does not need to be an actual word. The function will receive a string from user input and it will return the string with the palindrome. For example, if you enter a string "abc", your program will return "abccba".

Testing program

Create a menu program for the user to test your buffer and to create a palindrome. For the queue, prompt the user to enter the two chances and the total number of rounds. Display the results to the screen in each round. For the stack, prompt them to enter a string. Create the palindrome and then display it. You can determine how this menu program should look like as long as it test the queue and stack properly

What to submit

- Code to implement your stack, both header and source files
- Code to implement your queue, both header and source files
- Code to test the operation of your stack and queue.

Computer Engineering, Engineering

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

Have any Question?


Related Questions in Computer Engineering

Questions 1 for the set of 1 4 5 16 17 21 of keys draw

Questions: 1. For the set of {1, 4, 5, 16, 17, 21} of keys, draw binary search trees of heights 2, 3, 4, 5, and 6. 2. Use the Binary Search Tree class to Write the TREE-PREDECESSOR procedure. 3. Show that there are at mo ...

A firm produces product a and product b this years sales

A firm produces Product A and Product B. This years sales price of Product A have decreased tremendously, and the sale of Product B has increase by 10 percent. The firm has threeemployees that can produce Product A and f ...

Question cyber attacks on critical infrastructures-a risk

Question: Cyber Attacks On Critical Infrastructures-A Risk To The Nation There has been a great deal of research related to cyber attacks and vulnerabilities and critical infrastructure, but there is an incomplete unders ...

Like users computers in a domain will have an account

Like users, computers in a domain will have an account established for them. Their account can be seen in AD Users and Computers and viewed or modified there. What if you were going to add a new group of people in a new ...

Question suppose your corporate commercial website server

Question : Suppose your corporate commercial Website server is located in a demilitarized zone (DMZ) so that potential and existing customers can access it. Explain the steps you would take to secure the Web server and t ...

Stock portfolio gui projectgoalyou are to write a gui

Stock Portfolio GUI Project Goal You are to write a GUI program that will allow a user to buy, sell and view stocks in a stock portfolio. For example, you might track the profit or loss on the trades. You might allow for ...

Question write a 2 page briefing paper in which you present

Question: Write a 2 page briefing paper in which you present a summary of the issues (including a description of the types of intellectual property which may have been stolen). You should then summarize your research int ...

How does a java server page uses the client-server model to

How does a Java Server Page uses the client-server model to make a Web page interactive?

Question suppose you were looking at network traffic and

Question : Suppose you were looking at network traffic and saw one computer transmit: Who has 192.168.1.1 And saw the reply 192.168.1.1 is at 00:cc:11:8b:73:22. What process would you be looking at? Why is this process n ...

In unix programming ordinarily the exec system call follows

In UNIX programming, ordinarily the exec() system call follows the fork() call. Explain what would happen if a programmer were to inadvertently place the call to exec() before the call to fork().

  • 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