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

  What evidence can you find to support your opinion

Steve Jobs was a strong, charismatic leader who co-founded Apple and is credited with much of the success of the company. Some believe that Tim Cook.

  What other conclusions can you draw from your graph

In which entity is the number of data breaches increasing fastest? What other conclusions can you draw from your graph?

  Make a gui based program with a writebutton

make a GUI Based program with a WriteButton used to write data to a sequential data file. Then make another ReadData button to read data from the file created and display it in a JTable on the GUI.

  Find and correct the errors in your program

Unfortunately, errors in transmission sometimes occur. Thus, your program should first attempt to find and correct these errors.

  Identify a stakeholder that may be impacted

Identify and explain key artifacts and activities within the defect management process. For each artifact and activity, identify a stakeholder

  Questionwrite down a java program that creates an array of

questionwrite down a java program that creates an array of integers that called myarray. myarray be able to be of any

  Identify the role of it as a contributor to the business

respond to the followingidentify multiple business pressures on xerox.describe some of the companys response

  What did you set out to achieve

What did you set out to achieve? What was your plan to achieve this? How did this change as you progressed? What went well and why? What could have gone better?

  What amount of time will require to transfer 512byte

what amount of time will require to transfer 512byte of memory if the bus grant request is 2s and the bus release request is 4s

  Create an outline in the scope of your risk management plan

For each of the domains, create an outline in the scope of your risk management plan. Include the following topics- the five major parts of an IT risk.

  Discuss the morality of mary decision

Mary and John are both taking the quiz. They are sitting next to each other in the computer room. John asks Mary for help in answering one of the questions.

  Discuss about information systems security in detail

Discuss one of the most important things you will take from this course. You do not have to document your sources for this question.

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