Starting Out With C++: Early Objects (10th Edition)
Starting Out With C++: Early Objects (10th Edition)
10th Edition
ISBN: 9780135235003
Author: Tony Gaddis, Judy Walters, Godfrey Muganda
Publisher: PEARSON
bartleby

Concept explainers

Question
Book Icon
Chapter 18, Problem 11PC
Program Plan Intro

Balanced Multiple Delimiters

Program Plan:

  • Include required header files
  • Declare function prototype
  • Inside “main ()” function,
    • Declare a variable “strng”.
    • Get a string from the user.
    • Check if the Boolean function “is_Balanced ()” returns true.
      • If the condition is true then the string has balanced delimiters.
      • If the condition is not true then the string does not have balanced delimiters.
  • Inside “is_Balanced ()” function,
    • Declare a Boolean variable “status”.
    • Declare a character variable “expected”
    • Create an object for stack.
    • Loop each character.
      • Switch to the character.
        • If left parenthesis is detected,
          • Push it into the stack using the function “push ()”.
        • If left braces is detected,
          • Push it into the stack using the function “push ()”.
        • If left bracket is detected,
          • Push it into the stack using the function “push ()”.
        • If right parenthesis or right bracket or right braces is detected,
          • Get the top element from the stack and store it in a variable “expected”
        • Check if the expected character is not equal to “str[k]”.
          • Assign “false” if the condition is true.
          • Else, pop the element
    • Check if the stack is empty and assign “true”. Else, assign “false”.
    • Return the variable “status”.

Blurred answer
Students have asked these similar questions
WAP c# program creates a string, s1, which deliberately leaves space for a name, much like you’d do with a letter you plan to run through a mail merge. We add two to the position where we find the comma to make sure there is a space between the comma and the name.
java Use Map data structure Write a method that returns the frequency of each characters of a given String parameters If the given String is null ,then return null
T/F Suffix array can be created in O(nlogn) time.
Knowledge Booster
Background pattern image
Computer Science
Learn more about
Need a deep-dive on the concept behind this application? Look no further. Learn more about this topic, computer-science and related others by exploring similar questions and additional content below.
Similar questions
SEE MORE QUESTIONS
Recommended textbooks for you
Text book image
Database System Concepts
Computer Science
ISBN:9780078022159
Author:Abraham Silberschatz Professor, Henry F. Korth, S. Sudarshan
Publisher:McGraw-Hill Education
Text book image
Starting Out with Python (4th Edition)
Computer Science
ISBN:9780134444321
Author:Tony Gaddis
Publisher:PEARSON
Text book image
Digital Fundamentals (11th Edition)
Computer Science
ISBN:9780132737968
Author:Thomas L. Floyd
Publisher:PEARSON
Text book image
C How to Program (8th Edition)
Computer Science
ISBN:9780133976892
Author:Paul J. Deitel, Harvey Deitel
Publisher:PEARSON
Text book image
Database Systems: Design, Implementation, & Manag...
Computer Science
ISBN:9781337627900
Author:Carlos Coronel, Steven Morris
Publisher:Cengage Learning
Text book image
Programmable Logic Controllers
Computer Science
ISBN:9780073373843
Author:Frank D. Petruzella
Publisher:McGraw-Hill Education