1answer.
Ask question
Login Signup
Ask question
All categories
  • English
  • Mathematics
  • Social Studies
  • Business
  • History
  • Health
  • Geography
  • Biology
  • Physics
  • Chemistry
  • Computers and Technology
  • Arts
  • World Languages
  • Spanish
  • French
  • German
  • Advanced Placement (AP)
  • SAT
  • Medicine
  • Law
  • Engineering
svetoff [14.1K]
3 years ago
3

Write a function that takes a string parameter and determines whether the string contains matching grouping symbols. Grouping sy

mbols are parenthesis ( ) , brackets [] and curly braces { }. For example, the string {a(b+ac)d[xy]g} and kab*cd contain matching grouping symbols. However, the strings ac)cd(e(k, xy{za(dx)k, and {a(b+ac}d) do not contain matching grouping symbols. (Note: open and closed grouping symbols have to match both in number and in the order they occur in the string). Your function must use a stack data structure to determine whether the string parameter satisfies the condition described above. You may define your own stack class or use the STL stack class. Write a driver program (i.e. a function main()) to test your function.
Deliverables:

1. a copy of your function and the test driver program source codes in a text file

2. screen shots of your test driver program runs showing it meets the problem's specifications. This is what I've done so far: I've copied the material from the book as well as from some sources on the internet. Could you edit my code and write it in C++. Some of my code is in Java.

Computers and Technology
1 answer:
Alex73 [517]3 years ago
5 0

Answer:

See attachment below

Program to check for matching symbols

// Program is written in C++

// Comments are used for explanatory purposes

// Program Starts here

#include<bits/stdc++.h>

using namespace std;

bool CheckParenthesis(string word)

{

int pos = 0;

char singlechar;

stack<char> stackchar;

for (pos=0; pos<word.length(); pos++)

{

//Check for opening paranthesis

if (word[pos]=='('||word[pos]=='['||word[pos]=='{')

{

stackchar.push(word[pos]);

continue;

}

if (stackchar.empty())

return false;

switch (word[pos])

{

//Check for closing paranthesis

case ')':

singlechar = stackchar.top();

stackchar.pop();

if (singlechar=='{' || singlechar=='[') {

return false; }

break;

case ']':

singlechar = stackchar.top();

stackchar.pop();

if (singlechar =='(' || singlechar == '{') {

return false; }

break;

}

case '}':

singlechar = stackchar.top();

stackchar.pop();

if (singlechar=='(' || singlechar=='[') {

return false; }

break;

}

return (stackchar.empty());

}

// Main Program Starts Here

int main()

{

//Declare String

string word;

cout<<"Enter some string texts:";

cin>>word;

//Check for matching symbols

if (CheckParenthesis(word))

cout << "Matching Symbols";

else

cout << "No Matching Symbols";

return 0;

}

You might be interested in
What is the descriptor for a filter that warns or blocks you from potentially fraudulent or suspicious websites?.
algol [13]
A VPN. i believe what you’re referring to is called a vpn. it protects your data when you’re working online.
8 0
2 years ago
A network on the internet has a subnet mask of 255.255.240.0. what is the maximum number of hosts it can handle
Lera25 [3.4K]
It is a class B network, so for a class B network, the upper 16 bits form the network address and the lower 16 bits are subnet and host fields. Of the lower 16 bits, most significant 4 bits are 1111. This leaves 12 bits for the host number. So, 4096(2^12) host address exists. First and last address are special so the maximum number of address is 4096-2=4094.
7 0
4 years ago
An outdoor products company wants to test a new website design where customers can get information about their favorite outdoor
ExtremeBDS [4]

Answer:

Option (A) is the right answer for factors.

Option (B) is the right answer for factor levels.

Explanation:

As per the scenario, the company wants to see the effect of their new website design on their customers, for which the factor of time spent on the new website is right because it gives the company to acknowledge the data of time spent by a customer on the new website.

To reach the result of the factor, we have to work on the factor level, in which we will compare the time spent on the old website and the new website because it gives the company an idea of customers preferring which website design.

8 0
3 years ago
A _____, or spider, is a search engine program that automatically searches the web to find new websites and update information a
Len [333]

Answer: B) Web robot

Explanation:

Web robot or spider is the search engine program which automatically visit the new web site and update the information. Basically, it is the internet bot that helps in store the information from the search engine to the index.

Spider searches the web site and read the information in their given page for creating the entries from search engine.

Web robot is also known as web crawler, this type of programs are use by different search engine that automatically download and update the web content on web sites.  

3 0
4 years ago
Expalin the defference between the driver of a desktop and a laptop​
Pani-rosa [81]

Answer:

None, drivers are hardware specific, if both devices share the same hadware manufacurer they tend to have the same drivers.

A driver is a software component that lets the operating system and a device communicate with each other. So asking for a difference in drivers is as asking the difference in hardware in both devices, though one tends to be more intergrated they are all the same in low level functions

Also drivers might not even communicate directly with the device but send a request. thats why some drivers can be written directly into an operating system.

7 0
3 years ago
Other questions:
  • 3 to the power x + 1 equal to 9 to the power 2x + 1​
    15·1 answer
  • Create a lottery game application. Generate three random numbers (see Appendix D for help in doing so), each between 0 and 9. Al
    14·1 answer
  • Kash has created a document that needs to be protected. only certain users should be able to open the document. what option shou
    5·1 answer
  • Which of the following is NOT a design choice when using the ER model?
    5·1 answer
  • All of the following statements concerning project portfolios are true EXCEPT: ​ a. The projects in a portfolio are managed as a
    6·1 answer
  • During project management, who executes tasks and produces the deliverables as stated in the project plan and as directed by the
    9·1 answer
  • What technology is being used instead of Adobe flash player​
    8·1 answer
  • A new PKI is being built at a company, but the network administrator has concerns about spikes of traffic occurring twice a day
    5·1 answer
  • Look at (c), is it accurate? ​
    9·2 answers
  • The firewall protects a computer or network from network-based attacks along with _____________ of data packets traversing the n
    8·1 answer
Add answer
Login
Not registered? Fast signup
Signup
Login Signup
Ask question!