Compilers check your program for syntax errors, but a missing brace, parenthesis, or bracket may cause...
Fantastic news! We've Found the answer you've been seeking!
Question:
Transcribed Image Text:
Compilers check your program for syntax errors, but a missing brace, parenthesis, or bracket may cause the compiler to output many errors without identifying the instruction that caused the malformed instruction. The goal of this assignment is for you to write a program that checks a string of symbols to determine whether the symbols are balanced. For simplicity, your program will only need to consider the brackets'[', ']', curly brackets '{', '}', and parentheses '(',')'. Examples of legal and illegal sequences are below: ()()-legal ([)]-illegal ([]) - legal ([()]) - legal {[()]} - legal The following algorithm uses a stack data structure for its solution. Make an empty stack Read characters to end of line If the character is an opening symbol, push it onto the stack If the character is a closing symbol and the stack is empty, print an error message Otherwise, pop the stack If the symbol is not the corresponding opening symbol then report an error If you have reached the end of line and the stack is not empty, then report an error, else print legal Repeat until you reach the end file. The requirements of the assignment are: Your program should be implemented in either C or C++. You are to implement your own stack functions, including push() and pop(). You must use a linked list to implement your stack. Do not use pre-defined lists classes or modules. You can use a basic struct to create a node for your linked list data structure: Please see the example below: struct Node { } char symbol; Node *next; Your program should read its input from a file. You should specify the filename on the command line when running your program. This will require the use of argc and argv. Do not hardcode the filename. You may assume that each line of the file will contain a string of symbols. Compilers check your program for syntax errors, but a missing brace, parenthesis, or bracket may cause the compiler to output many errors without identifying the instruction that caused the malformed instruction. The goal of this assignment is for you to write a program that checks a string of symbols to determine whether the symbols are balanced. For simplicity, your program will only need to consider the brackets'[', ']', curly brackets '{', '}', and parentheses '(',')'. Examples of legal and illegal sequences are below: ()()-legal ([)]-illegal ([]) - legal ([()]) - legal {[()]} - legal The following algorithm uses a stack data structure for its solution. Make an empty stack Read characters to end of line If the character is an opening symbol, push it onto the stack If the character is a closing symbol and the stack is empty, print an error message Otherwise, pop the stack If the symbol is not the corresponding opening symbol then report an error If you have reached the end of line and the stack is not empty, then report an error, else print legal Repeat until you reach the end file. The requirements of the assignment are: Your program should be implemented in either C or C++. You are to implement your own stack functions, including push() and pop(). You must use a linked list to implement your stack. Do not use pre-defined lists classes or modules. You can use a basic struct to create a node for your linked list data structure: Please see the example below: struct Node { } char symbol; Node *next; Your program should read its input from a file. You should specify the filename on the command line when running your program. This will require the use of argc and argv. Do not hardcode the filename. You may assume that each line of the file will contain a string of symbols.
Expert Answer:
Related Book For
Management Accounting Information for Decision-Making and Strategy Execution
ISBN: 978-0137024971
6th Edition
Authors: Anthony A. Atkinson, Robert S. Kaplan, Ella Mae Matsumura, S. Mark Young
Posted Date:
Students also viewed these computer network questions
-
Q1. You have identified a market opportunity for home media players that would cater for older members of the population. Many older people have difficulty in understanding the operating principles...
-
Design a Java class that represents a cache with a fixed size. It should support operations like add, retrieve, and remove, and it should evict the least recently used item when it reaches capacity.
-
Explain how you solve problems during the implementation of your projects. Does this operate as a formal approach and/or use specific supportive techniques?
-
Bertrand Manufacturing uses a job-order cost system and applies overhead to production on the basis of direct labour costs. On January 1, 2012, Job No. 50 was the only job in process. The costs...
-
A certain type of machine will be used to produce three products: A, B, and C. Sales forecasts for these products are: 52,000, 65,000, and 70,000 units per year, respectively. Production rates for...
-
Assume an auditor sets acceptable risks of incorrect rejection and incorrect acceptance at .10 and .05, respectively, applies ratio estimation, and obtains the following results: estimated population...
-
1. Critically evaluate the questionnaire. 2. Will Canterbury Travels gain the information it needs from this survey? Hometown, located in the north central United States, had a population of about...
-
How do organizational leaders cultivate a culture of commitment that transcends mere compliance, leveraging strategies like transformational leadership and authentic communication ?
-
Presented below are annual coupon rates, yield rates, and expected duration for a series of debentures. Calculate the issuance price for each debenture assuming that the face value of each bond is...
-
Adjusting Journal Entries (Appendix A)(instruction): Proper journal entries are prepared for all items on the trial balance that require adjustment. Required entries are properly formatted with a...
-
The Sisters of the Most Holy and Immaculate Heart of the Blessed Virgin Mary have a bone to pick with their archdiocese as well as property law. The good sisters have an eightacre convent (in which...
-
The rsum is a door opener for a job seeker. What's on it can get you in the door or cause the door to be slammed in your face. With that type of pressure, it is not surprising to learn that one 2006...
-
The EPA announced allegations against Volkswagen AG (VW) of using a defeat device in 482,000 of its cars since 2008 in order to make the cars test clean during emissions testing. The EPA alleged that...
-
Since the Hofstede and Javidan and House studies of cultural dimensions, do you suspect that cultural differences are increasing or decreasing? What evidence do you draw from?
-
What are your reactions to the GLOBE project (led by Professors Javidan and House), specifically the various cultural dimensions and highest-scoring countries the data revealed? Can you think about...
-
A manufacturing facility has 15 CNC machines on site. The length of a machine job is modeled as an exponential random variable with a mean length of 6.2 hours. If all machines are currently full, and...
-
Big Jim Company sponsored a picnic for employees and purchased a propane grill equipped with a standard-sized propane tank for the picnic. To make sure there was enough propane for all the cooking...
-
Rossman Instruments, Inc., is considering leasing new state-of-the-art machinery at an annual cost of $900,000. The new machinery has a fouryear expected life. It will replace existing machinery...
-
What is a stock option plan?
-
What is the relationship between value engineering and target costing?
-
Pegasus Veterinary Hospital (PVH) is a partnership of five veterinarian surgeons who specialize in treating horses. PVH is located in a $25 million facility on 20 acres of land, employing over 40...
-
A tender evaluation method specifies 60% price and 40% quality. What is the weighted score of a tender that scored 80 points (out of 100) for price and 60 for quality?
-
You are a recently appointed purchasing manager who is overseeing terms and con- ditions of contract for an important international purchase with a UN country. What rules should you be particularly...
Study smarter with the SolutionInn App