Computer Science

Abstract Data Types

Stacks - Basic

Consider the usual algorithm for determining whether a sequence of parentheses is balanced. What is the maximum number of parentheses that will appear on the stack AT ANY ONE TIME when the algorithm analyzes: (()(())(()))

What will the following pseudocode output when the wordbrilliantis inputted?

declare a stack of characters while ( there are more characters in the word to read ) { read a character push the character on the stack } while ( the stack is not empty ) { pop a character off the stack write the character to the screen }

Consider the stack \(S\), how many items will it have left after the following operations are performed on it?

1
S.Push(80) , S.Pop() , S.Push(50) , S.Push(40) , S.Push(17) , S.Pop() , S.Push(84) , S.Push(8) , S.Push(31) , S.Push(58) , S.Push(10) , S.Push(82) , S.Pop() , S.Push(64) , S.Push(27) , S.Push(34) , S.Pop() , S.Pop() , S.Pop() , S.Pop() , S.Pop() , S.Push(54) , S.Push(52) , S.Pop() , S.Pop() , S.Pop() , S.Push(61) , S.Push(38) , S.Pop() , S.Push(53) , S.Push(57) , S.Pop() , S.Pop() , S.Push(32) , S.Push(1) , S.Push(35) , S.Push(58) , S.Pop() , S.Pop() , S.Pop() , S.Push(24) , S.Push(56) , S.Pop() , S.Push(17) , S.Push(77) , S.Pop() , S.Push(17) , S.Push(36) , S.Push(90) , S.Push(15) , S.Pop() , S.Pop() , S.Push(25) , S.Push(76) , S.Pop() , S.Push(68) , S.Push(98) , S.Push(82) , S.Push(81) , S.Push(9) , S.Push(18) , S.Pop() , S.Push(11) , S.Push(86) , S.Pop() , S.Pop() , S.Push(84) , S.Pop() , S.Push(13) , S.Push(30) , S.Push(34) , S.Pop() , S.Push(20) , S.Push(71) , S.Pop() , S.Push(17) , S.Push(91) , S.Pop() , S.Push(27) , S.Pop() , S.Push(38) , S.Pop() , S.Push(1) , S.Push(54) , S.Push(70) , S.Push(30) , S.Pop() , S.Push(27) , S.Pop() , S.Push(18) , S.Pop() , S.Push(70) , S.Push(11) , S.Push(52) , S.Push(2) , S.Push(59) , S.Pop() , S.Push(26) , S.Push(80) , S.Push(89)

×

Problem Loading...

Note Loading...

Set Loading...