Academic Integrity: tutoring, explanations, and feedback — we don’t complete graded work or submit on a student’s behalf.

label each line for determining the Big-O of the parChecker function. Find the B

ID: 3792906 • Letter: L

Question

label each line for determining the Big-O of the parChecker function. Find the Big-O and the values of c and n0.

sting 3 3.py CAUserslv ncenzoDesktopAlgorithms HWAListingslisting 3-3. File Edit Format Run Options Window Help from pythonds .basic import Stack def parchecker (symboolstring) Stack balanced True index 0 while index len (symbol String) and balanced symbol String [index] symbol if symbol (m s.push (symbol) else: if s isEmpty balanced False else: s.pop index index 1 if balanced and 3.isEmpty return True else: return False

Explanation / Answer

One by one line explanation

def parchecker(symbolstring):                                   //Function calling
        s=stack()                                               //Stack intitalization
        balanced = true                                         // one boolen variable initializing true
        index = 0                                               // one index variable for traversing the string
        while index < len(symbolstring) and balanced:           // loop from stating variable to end variable of string if the string properly terminated.
                symbol = symbolString[index]                    // one by one symbol is assigning in temporary variable symbol
                if symbo == "(":                                // if symbol is ( then push in a stack and increase the index variable.
                        s.push(symbol)
                else:                                           // if not
                        if s.isempty():                         // if list is empty it means the complete string is not accessed.
                                balanced =False                 //      So make balance false, means abnormal termination of loop
                        else:                                   // else
                                s.pop()                         // pop the element from stack and then increment the index.
                index = index + 1                               // while loop is finish after this line
        if balance and s.isempty():                             // if balance is true or stack is empty it will return true.
                return true
        else:                                                   // else false.
                return False
              
              
So in the program the big oh O(n). n is the length of symbolstring. If the string is completely traversed or not, time complexity not increased from the string of symbolstring.
n0 > 1 and c>1 for O(n)
In this, the value of n0 is greater than 1 and c is also greater than 1.