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 and implement a recursive version of the binary search algorithm. Also, write a version of the sequential search algorithm that can be applied to sorted lists. Add this operation to the class orderedArrayListType for array-based lists. Moreover, write a test program to test your algorithm.
In C++, write a program that outputs the nodes of a graph in a breadth first traversal. Data File: Please use this data file. Text to copy: 100 1 3 -9991 4 -9992 5 -9993 2 -9994 -9995 7 8 -9996 4 7 -9997 -9998 -9999 7 8 -999   Diagram: Also, please take a look at figure 20-6 on page 1414 and calculate the weights for the following edges: 0 -> 1 -> 4 0 -> 3 -> 2 -> 5 -> 7 0 -> 3 -> 2 -> 5 -> 8 6 -> 4 6 -> 7 9 -> 7 9 -> 8 To calculates these weights, please assume the following data: 0 -> 1 = 1 0 -> 3 = 2 1 -> 4 = 3 3 -> 2 = 4 2 -> 5 = 5 5 -> 7 = 6 5 -> 8 = 7 6 -> 4 = 8 6 -> 7 = 9 9 -> 7 = 10 9 -> 8 = 11
how to implement this function by giving another example like this function or any similar  : int* returnNeighbors(int v);// returns the indices of the neighbors of the vertex v as an int array
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
C++ Programming: From Problem Analysis to Program...
Computer Science
ISBN:9781337102087
Author:D. S. Malik
Publisher:Cengage Learning