Question: C++ code In this lab we are building randomly generated well balanced lists of symbols. For example, parentheses are useful examples of well-balanced lists of
C++ code
In this lab we are building randomly generated well balanced lists of symbols. For example, parentheses are useful examples of well-balanced lists of matching symbols. Here are four examples, () ()) ((())))) ( () ((()))) of well-balanced list of parentheses. Given an integer n, our plan to generate random lists of 2n matching symbols, such as parentheses, has the next steps: 1. Given a list of 2n integers, fill the first n elements with 1 and the next n elements with 1. 2. Use the Fisher-Yates algorithm to randomly scramble this list 3. Toss out any scrambled lists that do not have non-negative or non-positive prefix sums 4. Count the number of non-negative and non-positive prefix sums and compare these with the total number of +1,1 randomly generated sequences
Step by Step Solution
There are 3 Steps involved in it
Get step-by-step solutions from verified subject matter experts
