Starting Out with C++ from Control Structures to Objects (9th Edition)
Starting Out with C++ from Control Structures to Objects (9th Edition)
9th Edition
ISBN: 9780134498379
Author: Tony Gaddis
Publisher: PEARSON
bartleby

Concept explainers

Question
Book Icon
Chapter 19, Problem 15PC
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
Domino cycledef domino_cycle(tiles):A single domino tile is represented as a two-tuple of its pip values, such as (2,5) or (6,6). This function should determine whether the given list of tiles forms a cycle so that each tile in the list ends with the exact same pip value that its successor tile starts with, the successor of the last tile being the first tile of the list since this is supposed to be a cycle instead of a chain. Return True if the given list of domino tiles form such a cycle, and False otherwise. tiles Expected result [(3, 5), (5, 2), (2, 3)] True [(4, 4)] True [] True [(2, 6)] False [(5, 2), (2, 3), (4, 5)] False [(4, 3), (3, 1)] False
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

Chapter 19 Solutions

Starting Out with C++ from Control Structures to Objects (9th Edition)

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