Question

In: Computer Science

State two direct applications of stacks? State two indirect applications of stacks? Give an example from...

  1. State two direct applications of stacks?
  1. State two indirect applications of stacks?
  1. Give an example from the daily life of queues.
  1. What are the main queue operations and do they do?

Solutions

Expert Solution

Two direct applications of stacks:
* Stacks are commonly used in the history of all the website webpages-visited in a web browser.
* Another user application level use case is when users use the 'undo' command or feature in any text editor to undo any mistakes or recent actions or unintended incorrect characters typed in following the undo sequence in order.

Two indirect applications of stacks:
* Stacks are used as a very common data structure in programs.
* Stacks are used as a component of other data structures.
* It is also used as an auxiliary data structure for algorithms.

An example from the daily life of queues:
* Car owners waiting in their respective cars for their turn to fill gas into their car gas tanks at gas stations.
* Customers waiting in lines for different services where they follow the first-come and first-serve policy or rule.
* In computer technology, different computers wait for shared resources such as printers, etc.

What the main queue operations and do they do:
* Insertions and deletions happen in the first-in and first-out scheme/fashion or on first-come and first-serve basis.
* Queues store arbitrary items, objects, values, or data.
* Insertions happen at the rear end of the queue whereas the deletions/removals happen at the front end of the queue.
* To insert an object at the rear end of the queue it uses the function enqueue (object) where object value is provided as input to be inserted.
*To remove/delete an object from the queue at the front end of the queue and return it as an output (with its value), it uses the function dequeue() returning with the object value been removed.
* Queues also have auxiliary queue operations such as to display or return the object at the front end of the queue without deleting or removing it with the function front().
* To return or display the value with the number of objects stored in a queue using the operation size(), this basically gives the queue size in integer data type.
* Another operation is performed to indicate if the queue is empty or not letting know if the queue has at least one object stored in it or nil. It uses the function isEmpty() which returns the value in boolean data type.

There is an exception operation which the queue performs when an attempt is made to execute the dequeue operation at the front end of the queue to delete/remove the object and return the same when there is no object in the queue (not even a single object) or the queue is empty and it throws an error message EmptyQueueException.


Related Solutions

1. In your workplace, give a good example of a direct cost? An indirect cost? Please...
1. In your workplace, give a good example of a direct cost? An indirect cost? Please provide an explanation of why your example fits the definition. 2. Does your organization use responsibility centers? please explain .. I work for a hospital setting.
Compare and contrast direct finance and indirect finance. Give a specific example of each and discuss...
Compare and contrast direct finance and indirect finance. Give a specific example of each and discuss in detail the differences. Which is more likely to have a larger share of the total financial market in a mature economy like the United States? Explain why
Give an example of indirect labor and where are they located
Give an example of indirect labor and where are they located
) Explain the difference between a direct and indirect observation. Provide an example of each not...
) Explain the difference between a direct and indirect observation. Provide an example of each not found in the “Error in Surveying” reading. What is the definition of an error? Why can we not calculate an exact error?
Compare direct and indirect competition. Give some examples for both of them.
Compare direct and indirect competition. Give some examples for both of them.
Explain the operation of piezoresistive sensor, and give an example for its applications.
Explain the operation of piezoresistive sensor, and give an example for its applications.
Define, compare, and contrast direct and indirect competition. Provide an example of how each of these...
Define, compare, and contrast direct and indirect competition. Provide an example of how each of these general phenomena shapes the distribution of organisms in shallow marine habitats
Direct or Indirect cost
Baird Manufacturing Company makes tents that it sells directly to camping enthusiasts through a mail-order marketing program. The company pays a quality control expert $110,500 per year to inspect completed tents before they are shipped to customers. Assume that the company completed 1,570 tents in January and 1,180 tents in February. For the entire year, the company expects to produce 17,000 tents.Required If the cost objective is to determine the cost per tent, is the expert’s salary a direct or...
We are trying to use two stacks to implement a queue. Name the two stacks as...
We are trying to use two stacks to implement a queue. Name the two stacks as E and D. We will enqueue into E and dequeue from D. To implement enqueue(e), simply call E.push(e). To implement dequeue(), simply call D.pop(), provided that D is not empty. If D is empty, iteratively pop every element from E and push it onto D, until E is empty, and then call D.pop(). Considering the worst case running time, what is the performance in...
2. What is the difference between the direct approach and the indirect approach to writing? Give...
2. What is the difference between the direct approach and the indirect approach to writing? Give an example for using each. What types of messages would work best with each approach?
ADVERTISEMENT
ADVERTISEMENT
ADVERTISEMENT