Determine if these sequences could represent valid operation

Assignment Help Computer Engineering
Reference no: EM133371028

You are given two sequences - a PUSH sequence and a POP sequence each consisting of n integers that are suppose to represent the sequence of values pushed and values popped from a stack that starts empty and ends empty. The goal is to determine if these sequences could represent valid operation of the stack. In other words, while we are given the order of the values pushed and the order of the values popped, we want to know if there is a way to interleave the push and pop operations to make this the legal behavior of a stack.

(a) First suppose that all values in the PUSH sequence are distinct. Give an O(n) algorithm to deter- mine if the two sequences are valid.

(b) Next, at the other extreme, suppose that the only values in the PUSH sequence are 0 and 1. Again give an O(n) algorithm to determine if the two sequences are valid.

(c) Finally, consider the general case, where the values may repeat but are not restricted to be 0 or 1. Give an O(n4) dynamic programming algorithm to determine if the input represents a valid pair of sequences and prove that your algorithm is correct.

Reference no: EM133371028

Questions Cloud

Summarize the negotiation and prioritization process : Provide a summary of each group member's community/culture and the health-related goal. Summarize the negotiation and prioritization process your
Write a program that reads two input numbers : write a program that reads two input numbers that represent feet and inches and convert this answer to be just inches. Write another program to do the reverse
Discusses militant theology : The text briefly discusses militant theology. how would you explain it to a lay person?
Hobbes or locke social contract theory : Are you more aligned with Hobbes or Locke social contract theory? Would you define some things differently?
Determine if these sequences could represent valid operation : Determine if these sequences could represent valid operation of the stack. In other words, while we are given the order of the values pushed and the order
Should convicted drug offenders : Should convicted drug offenders, who suffer from Substance dependence, be given the same sentencing as offenders who do not suffer from dependence?
Why is it important to have a personal life philosophy : Why is it important to have a personal life philosophy? Please include all information. Define and explain the differences between: A behavior change philosophy
Create a survey questionnaire that could be used to gather : Create a survey questionnaire that could be used to gather feedback from trainees to gauge the effectiveness of the training and inform you about changes
Most important to least important in your life : Why are health, religion, Emotional well-being, love, loyalty, some values from most important to least important in your life.

Reviews

Write a Review

Computer Engineering Questions & Answers

  Mathematics in computing

Binary search tree, and postorder and preorder traversal Determine the shortest path in Graph

  Ict governance

ICT is defined as the term of Information and communication technologies, it is diverse set of technical tools and resources used by the government agencies to communicate and produce, circulate, store, and manage all information.

  Implementation of memory management

Assignment covers the following eight topics and explore the implementation of memory management, processes and threads.

  Realize business and organizational data storage

Realize business and organizational data storage and fast access times are much more important than they have ever been. Compare and contrast magnetic tapes, magnetic disks, optical discs

  What is the protocol overhead

What are the advantages of using a compiled language over an interpreted one? Under what circumstances would you select to use an interpreted language?

  Implementation of memory management

Paper describes about memory management. How memory is used in executing programs and its critical support for applications.

  Define open and closed loop control systems

Define open and closed loop cotrol systems.Explain difference between time varying and time invariant control system wth suitable example.

  Prepare a proposal to deploy windows server

Prepare a proposal to deploy Windows Server onto an existing network based on the provided scenario.

  Security policy document project

Analyze security requirements and develop a security policy

  Write a procedure that produces independent stack objects

Write a procedure (make-stack) that produces independent stack objects, using a message-passing style, e.g.

  Define a suitable functional unit

Define a suitable functional unit for a comparative study between two different types of paint.

  Calculate yield to maturity and bond prices

Calculate yield to maturity (YTM) and bond prices

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