click below
click below
Normal Size Small Size show me how
DATA STRUCT MOD 3&4
| Question | Answer |
|---|---|
| What is the value of TOP when the STATIC STACK is FULL? | = to the (stack size-1) |
| What happens to the value of the TOP during a PUSH operation in a STATIC STACK? | increments by 1 |
| In a DYNAMIC STACK the pointer TOP stays at the HEAD after a PUSH operation. | FALSE; it gets updated to the newly added element |
| In a dynamic implementation of stack, the pointer TOP has an initial value of NULL. | True |
| In a dynamic stack, the pointer TOP is like the HEAD which always point to the first element of the linked list. | True |
| In a DYNAMIC STACK, the node that was POPPED is deleted. | TRUE |
| Below is a valid declaration of a dynamic stack implemented as a vector: stack< int > iStack | False |
| Below is a valid declaration of a dynamic stack implemented as a list: stack< int, list<int> > iStack; | True |
| The STL function push retrieves an element at the top of the stack. | False |
| The STL empty function will yield a value of true if the stack has elements. | FALSE; will yield false |
| In a multi-user system, a queue is used to hold print jobs submitted by users , while the printer services those jobs one at a time. | True |
| A queue, however, provides access to its elements in first-in, first-out (FIFO) order. | True |
| TRUE/FALSE: To dequeue means to insert an element at the rear of a queue. | False/ To dequeue means to remove an element from the front of a queue — not insert it. |
| Consider Program E: What is the output of the following inputs: 5 2 BGGBG | GGGBB |
| A deque (pronounced "deck" or "deek") is a double-ended queue. | True |
| Pop is a function in deque STL that removes the first element of the deque and discards it. | False |
| A deque is similar to an array, but allows efficient access to values at both the front and the rear. | False |
| By default, the queue container uses list as its base. | F |
| The following are 3 possible containers that can be used in implementing the STL Stack, except: | array |
| In a dynamic stack, pointer TOP points to a fixed value in the linked list and does not move. | FALSE; point to most recently added node / |
| Invoking the STL function top will automatically retrieve the element and move the pointer. | FALSE; top does not modify the stack or move the pointer |
| The STL function top returns a reference to the element at the top of the stack. | TRUE |
| Pop function will always retrieve the top. | TRUE |
| The two primary queue operations are push and pop. | False |
| C++ has an existing queue container. | True |
| TRUE/FALSE: In a static queue, elements are being deleted when you dequeue. | True |
| A static queue is fix in size. | True |
| When you perform enqueue in a dynamic queue, both the front and rear pointers move. | False |
| The queue container adapter can be built upon vectors, lists, or deques. | True |
| The queue version of push always inserts an element at the front of the queue. | False |
| The queue ADT is like the the stack ADT: it is actually a container adapter. | True |
| The following are stack operations except: | Clear |
| Using pop function automatically moves the top pointer to the next node without deleting the memory used. | FALSE; purpose of pop is to remove top element from stack / |
| A stack container that is used to adapt to different containers, it is often referred to as a container adapter. | TRUE |
| A queue has top and bottom pointers. | False |
| In a static queue the pointer front moves every time you dequeue. | True |
| Front is a function in deque STL that returns a reference to the first element of the deque. | True |
| The manner in which a stack behaves? | LIFO |
| Which of the following is an application of a stack? | Calculator |
| During a POP operation in a STATIC STACK, the elements are being moved one step up. | False |
| In a DYNAMIC STACK the pointer TOP stays at the HEAD after a PUSH operation. | false (iniba ni jear) |
| Given: Enqueue(1) Enqueue(2) Enqueue(3) The value stored in front of the queue is 3. | False Should be enqueue 1 |
| In a static stack, the variable stackSize will handle the total capacity of the stack. | True |
| Dynamic Stacks can be implemented using linked list. | True |
| The STL stack container may be implemented as a vector, a list, or a deque. | True |
| TRUE/FALSE: The pointer FRONT moves every time a new value is enqueued. | False |
| queue int x; Is a valid declaration of a queue container in C++. | False |
| TRUE/FALSE: The elements in a queue are processed like customers standing in a grocery check-out line: the first customer in line is the first one served. | True |
| Given: Enqueue(1) Enqueue(2) Enqueue(3) Dequeue() The value stored in front of the queue is 1. | False |
| A dynamic queue makes use of an array for implementation. | False |
| The initial value of index top in the static implementation of a stack is 0. | False |
| As each item is dequeued, the node pointed to by the front pointer is deleted, and front is made to point to the next node in the list. | true/ |
| Programs that use the deque ADT must include the deque header file. | true |
| A static stack is implemented using arrays. | false |
| Consider Program E: What is the data type of the user input? | int// |
| Below are characteristics of a dynamic stack, except: | Can be implemented with a dynamic array |
| Consider Program E: What is the output of the following inputs: 5 1 BGGBG | GBGGB ( |
| Consider Program E: What variable holds the length of the string that should be accepted? | n |
| The initial value of index top in the static implementation of a stack is 0. | False |
| As each item is dequeued, the node pointed to by the front pointer is deleted, and front is made to point to the next node in the list. | true/ |
| Programs that use the deque ADT must include the deque header file. | true |
| A static stack is implemented using arrays. | false |
| Consider Program E: What is the data type of the user input? | int// |
| Below are characteristics of a dynamic stack, except: | Can be implemented with a dynamic array |
| Consider Program E: What is the output of the following inputs: 5 1 BGGBG | GBGGB ( |
| Consider Program E: What variable holds the length of the string that should be accepted? | n |
| Below are characteristics of a dynamic stack, except: Group of answer choices Shrink in size as needed Can be implemented with a linked list Can be implemented with a dynamic array Grow in size as needed | shrink in size as needed |