Complete this array-based implementation of the adt queue

Assignment Help Basic Computer Science
Reference no: EM131399814

The array-based implementations of the ADT queue in this chapter used a circular array. One implementation counted the entries in the queue, while the other left one location in the array unused. We used these strategies to tell when the queue was empty and when it was full. A third strategy is possible. It does not count and does not have an unused location in the circular array. After initializing frontIndex to 0 and backIndex to -1, you do not use modulo arithmetic when you increment these fields. Instead, you use modulo arithmetic when you index the array, but without changing frontIndex and backIndex. Thus, if queue is the array, queue[frontIndex % queue.length] is the front entry, and the entry at the back of the queue is queue[backIndex % queue.length]. Now if backIndex is less than frontIndex, the queue is empty. The number of entries in the queue is backIndex - frontIndex + 1. You can compare this number with the size of the array to see whether the array is full.
Since frontIndex and backIndex can continue to grow, they might become too large to represent. To reduce the chance of this happening, set frontIndex to 0 and backIndex to -1 whenever the implementation detects an empty queue. Note that adding to a full queue invokes ensureCapacity, which sets frontIndex to 0 and backIndex to the index of the entry at the back of the queue. Complete this array-based implementation of the ADT queue.

Reference no: EM131399814

Questions Cloud

Summarize the current organizational training program : Given the changing employee demographics and rapid updates to technology, it is important for organizations to link training and development to the needs and preferences of its workforce. Training facilitates acquisition of new knowledge and skill..
Physical security policy section of information security : Develop the Physical Security Policy section of the Information Security Policy. Include the following:
Identify and discuss the different types of training modes : An ongoing investment in training and development is essential for improving the performance and participation of employees in organizational initiatives. Such an investment encourages accountability in both management and employees in continuous ..
What are population mean and variance and standard deviation : if the possible values for x are 1, 2, 3, 4, 5 with probabilities .2, .1, .1, .5, .1, respectively, what are the population mean, variance and standard deviation?
Complete this array-based implementation of the adt queue : Note that adding to a full queue invokes ensureCapacity, which sets frontIndex to 0 and backIndex to the index of the entry at the back of the queue. Complete this array-based implementation of the ADT queue.
Number of standards and frameworks : This process is called certification and Accreditation. There are a number of standards and frameworks that may be used, depending on the organizations.
Will standard deviation increase or decrease or stay same : In given problem, suppose the possible values for x are now 0, 2, 4 with the same probabilities as before. Will the standard deviation increase, decrease, or stay the same?
Why are corporations setting up their own universities : Why are corporations setting up their own universities? Explain in detail and indicate the advantages and disadvantages of this approach. What approach would you use to encourage managers to coach their employees?
What are certification and accreditation : What are certification and accreditation when applied to information systems security management? How important are they to an organization?

Reviews

Write a Review

Basic Computer Science Questions & Answers

  Explaining smartphones as important digital devices

Many resources will suggest that in the next few coming years, smartphones will become the one of the most important digital devices we own. Explain the implications of this statement.

  Allow different payment and shipping options

allow different payment and shipping options. There are a plenty of examples of this kind of web sites. Some well-known ones are amazon.com, Barnes & Nobles, and Borders.

  Software designed to damage or perform undesirable actions

Background Malware (short for malicious software) refers to software designed to damage or perform undesirable actions on a computer system. Malware has become an increasingly profitable industry for business savvy hackers. Malware has also become..

  The user location changes our understanding of the query

5. Which of the following is true? Select all that apply. TrueFalse

  Design and implement a program that prints pascal''s triangle

Design and implement a program that prints Pascal's triangle

  Number of sources to obtain the relevant information

You will need to research a number of sources to obtain the relevant information. At least four of these sources should be used for your report and your presentation. The resources must be credible, current (no earlier than 2010) and available in ..

  Highest level of measurement

What is the highest level of measurement that could be correctly applied to the variable "Population Density"?

  What is a referential integrity constraint

In general, how can you transform a relation not in BCNF into ones that are in BCNF?

  Write an hdl module for improved traffic light controller

Sketch your improved Moore machine state transition diagram, state encodings, state transition table, output table, next state and output equations, and your FSM schematic.

  Role of operating system

Title: Role of Operating System Answer these review questions based on operating systems:

  Piece of equipment or materials

This is to avoid allegations that the evidence may have been tampered with when it was unaccounted for, and to keep track of the tasks performed in acquiring evidence from a piece of equipment or materials. What is the term used to describe this p..

  What percent of the times actually fall within this interval

The mean finishing time was 78.21 seconds, with a standard deviation of 1.03 seconds. If the Normal model is appropriate, what percent of the times should be within 0.5 second of 78.21?

Free Assignment Quote

Assured A++ Grade

Get guaranteed satisfaction & time on delivery in every assignment order you paid with us! We ensure premium quality solution document along with free turntin report!

All rights reserved! Copyrights ©2019-2020 ExpertsMind IT Educational Pvt Ltd