EBK DATA STRUCTURES AND ALGORITHMS IN C
EBK DATA STRUCTURES AND ALGORITHMS IN C
4th Edition
ISBN: 9781285415017
Author: DROZDEK
Publisher: YUZU
bartleby

Concept explainers

Question
Book Icon
Chapter 4, Problem 3PA
Program Plan Intro

Program to implement the algorithm “delimiterMatching()”:

Program Plan:

  • In “delimiterMatching()” function
    • Function “delimiterMatching()” takes input file name as parameter.
    • Read characters from input file one by one till end of file
    • If character is “(”or “[” or “{” push it into stack “stackk1”.
    • If character is “)”or “]” or “}” check stack “stackk1” is empty or not.
      • If stack is empty return “false”.
      • Otherwise check delimiter is properly matched or not.
        • If stack top is “(” and character is “)” pop stack top from “stackk1”.
        • If stack top is “[” and character is “]” pop stack top from “stackk1”.
        • If stack top is “{” and character is “}” pop stack top from “stackk1”.
        • If stack top is any other character, return “false”.
    • If character is “/” and next character is “*” set “flagg” as “false”.
    • Continuously read characters till finds “*/”. If it finds before end of file set “flagg” as “true”.
    • If stack is not empty, set “flagg” as “false”.
    • Return “flagg”.
  • In “main()” function
    • Read a file name from keyboard and call function “delimiterMatching()” by passing file name as parameter.
    • If “delimiterMatching()” return “true” print message that input is delimiter matched.
    • Otherwise print message that input is not delimiter matched.

Blurred answer
Students have asked these similar questions
Write a java script program for double linked list sorting algorithm by using below logic  If else , while , functions. Output  Before list - 42,57, 84,12,90 After list - 12,42,57,84,90
Write a program to implement the concept of Depth First Search for the string , where A is the initial node and G2 is the goal node.
Write a python program that generates all the permutations of an ordered set that that do not have its largest element before its smallest one. For instance, if the set is [1,2,3,4,5] a good permutation is [4,1,3,2,5] and a bad one is [4,5,3,1,2].
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