Code Monkey home page Code Monkey logo

stack_queue_problems's Introduction

Problem 1

Write a program that creates a Queue from a stack. After creation the top of the stack will be the front of the queue.

Input Data-

S: 1 2 3 4 5

Output Data-

Q: 5 4 3 2 1

Problem 2

Given an integer k and a queue of integers, write a program to remove the first k elements of the queue, reverse their order and append them at the end of the queue, leaving the other elements in the same relative order.

Only a stack can be used as an auxiliary space and the following standard operations are allowed on queue.

• enqueue(x) : Add an item x to rear of queue

• dequeue() : Remove an item from front of queue

Examples:

Input: Q = 10, 20, 30, 40, 50, 60, 70, 80, 90, 100, k =5

Output: Q = 60, 70, 80, 90, 100, 50, 40, 30, 20, 10

Input: Q = 10, 20, 30, 40, 50, 60, 70, 80, 90, 100, k =2

Output: Q = 30, 40, 50, 60, 70, 80, 90, 100, 20, 10

stack_queue_problems's People

Contributors

nushratjabenaurnima avatar

Watchers

 avatar

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    🖖 Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. 📊📈🎉

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google ❤️ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.