Deck 7: Stacks

ملء الشاشة (f)
exit full mode
سؤال
The time complexity of the postfix expression evaluation algorithm is O( n2 ) .
استخدم زر المسافة أو
up arrow
down arrow
لقلب البطاقة.
سؤال
When converting from infix form to postfix form, parentheses are added to the equation.
سؤال
With a stack, you always access the item that has been most recently added.
سؤال
When using a stack to determine if brackets are balanced in an expression, the stack should not be empty when you reach the end of the expression.
سؤال
Access to a stack is restricted to the bottom end.
سؤال
The first step in evaluating a postfix expression is to scan the expression from left to right.
سؤال
The push operation for a stack raises an error if the stack is empty.
سؤال
The operator in an infix expression follows the operands.
سؤال
Stacks adhere to a LIFO protocol.
سؤال
Stack interfaces implement a peek operation for examining the element at the top of the stack.
سؤال
The pop operation for a stack raises an error if the stack is empty.
سؤال
The operator in a postfix expression follows the operands.
سؤال
The equation 17 46 + is an example of postfix form.
سؤال
When evaluating an arithmetic expression, first you transform it from its postfix form to its infix form.
سؤال
A stack structure is a built-in part of the Python language.
سؤال
A token in the postfix expression evaluation algorithm is an operand or operator.
سؤال
The operation for removing an item from the stack is called push.
سؤال
A Python list structure and its methods implement a stack perfectly.
سؤال
A tuple is an immutable collection type.
سؤال
Using a stack is a good approach to determining if the use of brackets in an expression is balanced.
سؤال
In a linked structure stack implementation, efficient pushing and popping require adding and removing of nodes at the head of the linked sequence.
سؤال
What protocol are stacks said to adhere to?

A) LIFO
B) FIFO
C) one-to-one
D) many-to-one
سؤال
To avoid stack overflow, the stack algorithm should raise an error if an item is added to a full stack.
سؤال
What is the operation that adds items to a stack?

A) get
B) set
C) push
D) pop
سؤال
Which of the following is true about stacks?

A) they are analogous to a row of books on a shelf
B) items are always added to the bottom
C) access is restricted to just one end
D) most implementations allow access to the middle
سؤال
Because of their linear structure, stacks can only be implemented using linked structures.
سؤال
When using a stack to evaluate the balance of brackets and parentheses in an expression, what is the first step?

A) push opening brackets onto the stack while scanning the expression
B) pop closing brackets onto the stack while scanning the expression
C) push closing brackets onto the stack while scanning the expression
D) pop opening brackets onto the stack while scanning the expression
سؤال
Which of the following is true about a postfix expression?

A) the operator is between its two operands
B) the operator follows its two operands
C) stack of bricks
D) table of contents
سؤال
Which of the following is NOT an application of stacks in computer science?

A) implementation of a hash-based database search function
B) managing computer memory in support of function calls
C) supporting the undo feature in a text editor
D) maintaining a history of visited links by a web browser
سؤال
What is the first step in the algorithm to evaluate an arithmetic expression?

A) transform the expression from postfix form to infix form
B) calculate the result from the postfix expression
C) calculate the result from the infix expression
D) transform the expression from infix form to postfix form
سؤال
The Node class for use in the linked structure stack contains three fields: data, next, and previous.
سؤال
In the algorithm that checks for a balanced expression, which of the following is true if a closing bracket is encountered?

A) if the stack is empty, the brackets balance
B) if the item on the top of the stack is a closing bracket of the same type, the brackets balance
C) if the stack is empty or the item on the top of the stack is not an opening bracket of the same type, the brackets don't balance
D) if the stack is empty or the item on the bottom of the stack is an opening bracket of the same type, the brackets balance
سؤال
When using a stack to evaluate the balance of brackets and parentheses in an expression, what is the final step?

A) at the end of the expression, if a final closing bracket is found, the brackets balance
B) at the end of the expression, if the stack is empty, the brackets do not balance
C) at the end of the expression, if the stack is full, the brackets balance
D) at the end of the expression, if the stack is empty, the brackets balance
سؤال
In the algorithm to evaluate a postfix expression, what does the algorithm do when an operator is encountered?

A) pop the resulting value from the stack
B) push the preceding operands onto the stack
C) apply the operator to the two preceding operands
D) push the operator onto the stack
سؤال
Which of the following is NOT an example of a stack in everyday life?

A) a spindle of blank DVDs
B) a stack of plates in a cafeteria line
C) a pile of napkins
D) a jar of jellybeans
سؤال
Addition and subtraction have higher precedence when evaluating an infix expression.
سؤال
If the current state of the stack is [ x, y, z ] where x is the bottom of the stack and z is the top of the stack, what is the state of the stack and the value returned after a pop operation?

A) the state is [ x, y ]; z is returned
B) the state is [ x, y, z ]; z is returned
C) the state is [ y, z ]; x is returned
D) the state is [ x, y, z ]; x is returned
سؤال
What is the function of the peek method in a stack implementation?

A) to return the bottom item without removing it
B) to return the top item without removing it
C) to return the top item and remove it from the stack
D) to return the bottom item and remove it from the stack
سؤال
Which of the following is NOT an operation supported by a stack interface?

A) push
B) insert
C) clear
D) peek
سؤال
In what way doesn't the Python list data structure accurately emulate a stack?

A) the append method pushes elements onto the stack
B) the pop method removes and returns the top element
C) a list uses an array as the underlying data structure
D) list methods allow manipulation of items at any position
سؤال
Which of the following begins in a predefined starting state and then moves from state to state in search of a desired ending state?

A) backtracking algorithm
B) memory management algorithm
C) infix to postfix converter
D) postfix to infix converter
سؤال
In the linked implementation of a stack, what type of helper function simplifies the __iter__ method?

A) binary
B) sequential
C) recursive
D) random
سؤال
If the portion of the postfix expression scanned so far is 7 6 2 +, what is the result when the operator is applied to the operands?

A) 8
B) 15
C) 13
D) 9
سؤال
In the following code that defines the push method for the array-based stack, what is the missing code? def push (self, item):
< missing code >
Self.size += 1

A) self.items += 1
B) self.items[ len(self) ] = item
C) items[ size ] = len(self.item)
D) item = self.items[ self.size + 1 ]
سؤال
In the algorithm to evaluate a postfix expression, what does the algorithm do when an operand is encountered?

A) pop the operand from the stack
B) push the operand onto the stack
C) pop the operator from the stack
D) push an operator onto the stack
سؤال
What is the resulting infix expression from the following postfix expression? 17 4 - 6 + 8 *

A) 17 - (4 + 6 * 8)
B) 17 - (4 + 6) * 8
C) (17 - 4) + (6 * 8)
D) (17 - 4 + 6) * 8
سؤال
If the entire postfix expression is 9 1 4 + - 2 *, what is the final value?

A) 12
B) 8
C) 17
D) 10
سؤال
What is the function of the PVM?

A) converts methods to subroutines
B) executes a python program from bytecodes
C) compiles Python code into assembly language
D) links a Python program to imported modules
سؤال
What is the resulting postfix expression from the following infix expression? (12 + 5) * 2 - 3

A) 12 5 2 + * 3 -
B) 12 5 + 2 3 * -
C) 12 5 + 2 * 3 -
D) 12 5 2 + 3 - *
سؤال
What are the two fields required by the Node class in the linked implementation of a stack?

A) prev, items
B) prev, data
C) items, next
D) data, next
فتح الحزمة
قم بالتسجيل لفتح البطاقات في هذه المجموعة!
Unlock Deck
Unlock Deck
1/50
auto play flashcards
العب
simple tutorial
ملء الشاشة (f)
exit full mode
Deck 7: Stacks
1
The time complexity of the postfix expression evaluation algorithm is O( n2 ) .
not answer
2
When converting from infix form to postfix form, parentheses are added to the equation.
False
3
With a stack, you always access the item that has been most recently added.
True
4
When using a stack to determine if brackets are balanced in an expression, the stack should not be empty when you reach the end of the expression.
فتح الحزمة
افتح القفل للوصول البطاقات البالغ عددها 50 في هذه المجموعة.
فتح الحزمة
k this deck
5
Access to a stack is restricted to the bottom end.
فتح الحزمة
افتح القفل للوصول البطاقات البالغ عددها 50 في هذه المجموعة.
فتح الحزمة
k this deck
6
The first step in evaluating a postfix expression is to scan the expression from left to right.
فتح الحزمة
افتح القفل للوصول البطاقات البالغ عددها 50 في هذه المجموعة.
فتح الحزمة
k this deck
7
The push operation for a stack raises an error if the stack is empty.
فتح الحزمة
افتح القفل للوصول البطاقات البالغ عددها 50 في هذه المجموعة.
فتح الحزمة
k this deck
8
The operator in an infix expression follows the operands.
فتح الحزمة
افتح القفل للوصول البطاقات البالغ عددها 50 في هذه المجموعة.
فتح الحزمة
k this deck
9
Stacks adhere to a LIFO protocol.
فتح الحزمة
افتح القفل للوصول البطاقات البالغ عددها 50 في هذه المجموعة.
فتح الحزمة
k this deck
10
Stack interfaces implement a peek operation for examining the element at the top of the stack.
فتح الحزمة
افتح القفل للوصول البطاقات البالغ عددها 50 في هذه المجموعة.
فتح الحزمة
k this deck
11
The pop operation for a stack raises an error if the stack is empty.
فتح الحزمة
افتح القفل للوصول البطاقات البالغ عددها 50 في هذه المجموعة.
فتح الحزمة
k this deck
12
The operator in a postfix expression follows the operands.
فتح الحزمة
افتح القفل للوصول البطاقات البالغ عددها 50 في هذه المجموعة.
فتح الحزمة
k this deck
13
The equation 17 46 + is an example of postfix form.
فتح الحزمة
افتح القفل للوصول البطاقات البالغ عددها 50 في هذه المجموعة.
فتح الحزمة
k this deck
14
When evaluating an arithmetic expression, first you transform it from its postfix form to its infix form.
فتح الحزمة
افتح القفل للوصول البطاقات البالغ عددها 50 في هذه المجموعة.
فتح الحزمة
k this deck
15
A stack structure is a built-in part of the Python language.
فتح الحزمة
افتح القفل للوصول البطاقات البالغ عددها 50 في هذه المجموعة.
فتح الحزمة
k this deck
16
A token in the postfix expression evaluation algorithm is an operand or operator.
فتح الحزمة
افتح القفل للوصول البطاقات البالغ عددها 50 في هذه المجموعة.
فتح الحزمة
k this deck
17
The operation for removing an item from the stack is called push.
فتح الحزمة
افتح القفل للوصول البطاقات البالغ عددها 50 في هذه المجموعة.
فتح الحزمة
k this deck
18
A Python list structure and its methods implement a stack perfectly.
فتح الحزمة
افتح القفل للوصول البطاقات البالغ عددها 50 في هذه المجموعة.
فتح الحزمة
k this deck
19
A tuple is an immutable collection type.
فتح الحزمة
افتح القفل للوصول البطاقات البالغ عددها 50 في هذه المجموعة.
فتح الحزمة
k this deck
20
Using a stack is a good approach to determining if the use of brackets in an expression is balanced.
فتح الحزمة
افتح القفل للوصول البطاقات البالغ عددها 50 في هذه المجموعة.
فتح الحزمة
k this deck
21
In a linked structure stack implementation, efficient pushing and popping require adding and removing of nodes at the head of the linked sequence.
فتح الحزمة
افتح القفل للوصول البطاقات البالغ عددها 50 في هذه المجموعة.
فتح الحزمة
k this deck
22
What protocol are stacks said to adhere to?

A) LIFO
B) FIFO
C) one-to-one
D) many-to-one
فتح الحزمة
افتح القفل للوصول البطاقات البالغ عددها 50 في هذه المجموعة.
فتح الحزمة
k this deck
23
To avoid stack overflow, the stack algorithm should raise an error if an item is added to a full stack.
فتح الحزمة
افتح القفل للوصول البطاقات البالغ عددها 50 في هذه المجموعة.
فتح الحزمة
k this deck
24
What is the operation that adds items to a stack?

A) get
B) set
C) push
D) pop
فتح الحزمة
افتح القفل للوصول البطاقات البالغ عددها 50 في هذه المجموعة.
فتح الحزمة
k this deck
25
Which of the following is true about stacks?

A) they are analogous to a row of books on a shelf
B) items are always added to the bottom
C) access is restricted to just one end
D) most implementations allow access to the middle
فتح الحزمة
افتح القفل للوصول البطاقات البالغ عددها 50 في هذه المجموعة.
فتح الحزمة
k this deck
26
Because of their linear structure, stacks can only be implemented using linked structures.
فتح الحزمة
افتح القفل للوصول البطاقات البالغ عددها 50 في هذه المجموعة.
فتح الحزمة
k this deck
27
When using a stack to evaluate the balance of brackets and parentheses in an expression, what is the first step?

A) push opening brackets onto the stack while scanning the expression
B) pop closing brackets onto the stack while scanning the expression
C) push closing brackets onto the stack while scanning the expression
D) pop opening brackets onto the stack while scanning the expression
فتح الحزمة
افتح القفل للوصول البطاقات البالغ عددها 50 في هذه المجموعة.
فتح الحزمة
k this deck
28
Which of the following is true about a postfix expression?

A) the operator is between its two operands
B) the operator follows its two operands
C) stack of bricks
D) table of contents
فتح الحزمة
افتح القفل للوصول البطاقات البالغ عددها 50 في هذه المجموعة.
فتح الحزمة
k this deck
29
Which of the following is NOT an application of stacks in computer science?

A) implementation of a hash-based database search function
B) managing computer memory in support of function calls
C) supporting the undo feature in a text editor
D) maintaining a history of visited links by a web browser
فتح الحزمة
افتح القفل للوصول البطاقات البالغ عددها 50 في هذه المجموعة.
فتح الحزمة
k this deck
30
What is the first step in the algorithm to evaluate an arithmetic expression?

A) transform the expression from postfix form to infix form
B) calculate the result from the postfix expression
C) calculate the result from the infix expression
D) transform the expression from infix form to postfix form
فتح الحزمة
افتح القفل للوصول البطاقات البالغ عددها 50 في هذه المجموعة.
فتح الحزمة
k this deck
31
The Node class for use in the linked structure stack contains three fields: data, next, and previous.
فتح الحزمة
افتح القفل للوصول البطاقات البالغ عددها 50 في هذه المجموعة.
فتح الحزمة
k this deck
32
In the algorithm that checks for a balanced expression, which of the following is true if a closing bracket is encountered?

A) if the stack is empty, the brackets balance
B) if the item on the top of the stack is a closing bracket of the same type, the brackets balance
C) if the stack is empty or the item on the top of the stack is not an opening bracket of the same type, the brackets don't balance
D) if the stack is empty or the item on the bottom of the stack is an opening bracket of the same type, the brackets balance
فتح الحزمة
افتح القفل للوصول البطاقات البالغ عددها 50 في هذه المجموعة.
فتح الحزمة
k this deck
33
When using a stack to evaluate the balance of brackets and parentheses in an expression, what is the final step?

A) at the end of the expression, if a final closing bracket is found, the brackets balance
B) at the end of the expression, if the stack is empty, the brackets do not balance
C) at the end of the expression, if the stack is full, the brackets balance
D) at the end of the expression, if the stack is empty, the brackets balance
فتح الحزمة
افتح القفل للوصول البطاقات البالغ عددها 50 في هذه المجموعة.
فتح الحزمة
k this deck
34
In the algorithm to evaluate a postfix expression, what does the algorithm do when an operator is encountered?

A) pop the resulting value from the stack
B) push the preceding operands onto the stack
C) apply the operator to the two preceding operands
D) push the operator onto the stack
فتح الحزمة
افتح القفل للوصول البطاقات البالغ عددها 50 في هذه المجموعة.
فتح الحزمة
k this deck
35
Which of the following is NOT an example of a stack in everyday life?

A) a spindle of blank DVDs
B) a stack of plates in a cafeteria line
C) a pile of napkins
D) a jar of jellybeans
فتح الحزمة
افتح القفل للوصول البطاقات البالغ عددها 50 في هذه المجموعة.
فتح الحزمة
k this deck
36
Addition and subtraction have higher precedence when evaluating an infix expression.
فتح الحزمة
افتح القفل للوصول البطاقات البالغ عددها 50 في هذه المجموعة.
فتح الحزمة
k this deck
37
If the current state of the stack is [ x, y, z ] where x is the bottom of the stack and z is the top of the stack, what is the state of the stack and the value returned after a pop operation?

A) the state is [ x, y ]; z is returned
B) the state is [ x, y, z ]; z is returned
C) the state is [ y, z ]; x is returned
D) the state is [ x, y, z ]; x is returned
فتح الحزمة
افتح القفل للوصول البطاقات البالغ عددها 50 في هذه المجموعة.
فتح الحزمة
k this deck
38
What is the function of the peek method in a stack implementation?

A) to return the bottom item without removing it
B) to return the top item without removing it
C) to return the top item and remove it from the stack
D) to return the bottom item and remove it from the stack
فتح الحزمة
افتح القفل للوصول البطاقات البالغ عددها 50 في هذه المجموعة.
فتح الحزمة
k this deck
39
Which of the following is NOT an operation supported by a stack interface?

A) push
B) insert
C) clear
D) peek
فتح الحزمة
افتح القفل للوصول البطاقات البالغ عددها 50 في هذه المجموعة.
فتح الحزمة
k this deck
40
In what way doesn't the Python list data structure accurately emulate a stack?

A) the append method pushes elements onto the stack
B) the pop method removes and returns the top element
C) a list uses an array as the underlying data structure
D) list methods allow manipulation of items at any position
فتح الحزمة
افتح القفل للوصول البطاقات البالغ عددها 50 في هذه المجموعة.
فتح الحزمة
k this deck
41
Which of the following begins in a predefined starting state and then moves from state to state in search of a desired ending state?

A) backtracking algorithm
B) memory management algorithm
C) infix to postfix converter
D) postfix to infix converter
فتح الحزمة
افتح القفل للوصول البطاقات البالغ عددها 50 في هذه المجموعة.
فتح الحزمة
k this deck
42
In the linked implementation of a stack, what type of helper function simplifies the __iter__ method?

A) binary
B) sequential
C) recursive
D) random
فتح الحزمة
افتح القفل للوصول البطاقات البالغ عددها 50 في هذه المجموعة.
فتح الحزمة
k this deck
43
If the portion of the postfix expression scanned so far is 7 6 2 +, what is the result when the operator is applied to the operands?

A) 8
B) 15
C) 13
D) 9
فتح الحزمة
افتح القفل للوصول البطاقات البالغ عددها 50 في هذه المجموعة.
فتح الحزمة
k this deck
44
In the following code that defines the push method for the array-based stack, what is the missing code? def push (self, item):
< missing code >
Self.size += 1

A) self.items += 1
B) self.items[ len(self) ] = item
C) items[ size ] = len(self.item)
D) item = self.items[ self.size + 1 ]
فتح الحزمة
افتح القفل للوصول البطاقات البالغ عددها 50 في هذه المجموعة.
فتح الحزمة
k this deck
45
In the algorithm to evaluate a postfix expression, what does the algorithm do when an operand is encountered?

A) pop the operand from the stack
B) push the operand onto the stack
C) pop the operator from the stack
D) push an operator onto the stack
فتح الحزمة
افتح القفل للوصول البطاقات البالغ عددها 50 في هذه المجموعة.
فتح الحزمة
k this deck
46
What is the resulting infix expression from the following postfix expression? 17 4 - 6 + 8 *

A) 17 - (4 + 6 * 8)
B) 17 - (4 + 6) * 8
C) (17 - 4) + (6 * 8)
D) (17 - 4 + 6) * 8
فتح الحزمة
افتح القفل للوصول البطاقات البالغ عددها 50 في هذه المجموعة.
فتح الحزمة
k this deck
47
If the entire postfix expression is 9 1 4 + - 2 *, what is the final value?

A) 12
B) 8
C) 17
D) 10
فتح الحزمة
افتح القفل للوصول البطاقات البالغ عددها 50 في هذه المجموعة.
فتح الحزمة
k this deck
48
What is the function of the PVM?

A) converts methods to subroutines
B) executes a python program from bytecodes
C) compiles Python code into assembly language
D) links a Python program to imported modules
فتح الحزمة
افتح القفل للوصول البطاقات البالغ عددها 50 في هذه المجموعة.
فتح الحزمة
k this deck
49
What is the resulting postfix expression from the following infix expression? (12 + 5) * 2 - 3

A) 12 5 2 + * 3 -
B) 12 5 + 2 3 * -
C) 12 5 + 2 * 3 -
D) 12 5 2 + 3 - *
فتح الحزمة
افتح القفل للوصول البطاقات البالغ عددها 50 في هذه المجموعة.
فتح الحزمة
k this deck
50
What are the two fields required by the Node class in the linked implementation of a stack?

A) prev, items
B) prev, data
C) items, next
D) data, next
فتح الحزمة
افتح القفل للوصول البطاقات البالغ عددها 50 في هذه المجموعة.
فتح الحزمة
k this deck
locked card icon
فتح الحزمة
افتح القفل للوصول البطاقات البالغ عددها 50 في هذه المجموعة.