ReviewQuestions.docx

# A draw a picture of the stack using the standard

• Notes
• 11

This preview shows page 8 - 11 out of 11 pages.

Nodes A, B, and C are placed on a stack in the order first A, then B, and finally C. a. Draw a picture of the stack using the standard abstract graphic Node C Node B Node A b. What would be stored in the variable top? i. Reference to Node C c. A pop operation in performed. What node is returned? i. Node C 7. What error occurs if: a. A Pop operation is performed on an empty stack? i. Underflow b. A Push operation is performed on a full stack? i. Overflow 8. Describe the action of the stack Peek operation a. Pop a node from the stack without deleting it from the structure 9. In the implementation of the Stack operation presented in this chapter, what does the memory cell top store, the index of the array where the nextPush or the nextPop will perform?

Subscribe to view the full document.

10. Rewrite the stack Push algorithm presented in this chapter assuming that top was initialized to 0 instead of -1. a. If (top == size) Return false else data[top] = newNode.deepCopy() top = top + 1 return true 11. Rewrite the stack Pop algorithm presented in this chapter assuming that top was initialized to 0 instead of -1. a. If (top == 0) return null else topLocation = top top = top -1 return data[topLocation] 12. Give the line numbers of the code presented of the code presented in Figure 3.13 that perform the garbage collection for the structure Stack. a. Lines 28-31 13. Evaluate the following arithmetic expressions written in postfixed notation: a. 45 3 21 + - 10 * i. 210 b. 3 6 * 45 2 + * c. 12 3 * 2 / 14. Write the following arithmetic expressions in postfixed notation: a. 45 + 6/2 i. 4 * 5 + 6 / 2 b. (3 + 4 + 7) / 2 i. 3 4 7 + 2 / c. (b^2 – 4 * ac) / (2a) i. b * 2 – 4 * a * c 2 a / 15. Nodes A, B, and C are placed on an initialized queue in the order first A, then B, and finally C. a. Draw a picture of the queue using the standard abstract Node C Node B Node A b. Indicate the position of the rear of the queue i. 0- C c. Indicate the position of the front of the queue i. 2 - A d. A Dequeue operation is performed. What node is returned?
i. Node A 16. In the implementations of the structure Queue presented in this chapter, what is stored in the memory cells front and rear? a. 0 17. Give the integer range of the values that rear can assume after the statement: rear = x % 54; executes (assume x is an integer) a. 0-53 18. Give the line numbers of the code presented in Figure 3.26 that perform the garbage collection for the structure queue. a. Lines 35-39 Chapter 4 1. What is one advantage of a linked list structure over array-based structure?

Subscribe to view the full document.

a. Linked list doesn’t have the fixed size, whereas Array is fixed size. We can also easily add the new item into the list 2. What is ne advantage of array based structures over a linked list structure? a. Array structure has advantage over linked list when it comes to the index access. Searching elements at specific positions is much easier that linked lists 3. Explain the term “fragmented memory” a. Data is stored non-continuous, it’s not stored in any particular order which leaves it in bits and pieces of memory unused 4. What is “dynamic” about dynamic data structures?
You've reached the end of this preview.
• Spring '16
• Array data structure

{[ snackBarMessage ]}

### What students are saying

• As a current student on this bumpy collegiate pathway, I stumbled upon Course Hero, where I can find study resources for nearly all my courses, get online help from tutors 24/7, and even share my old projects, papers, and lecture notes with other students.

Kiran Temple University Fox School of Business ‘17, Course Hero Intern

• I cannot even describe how much Course Hero helped me this summer. It’s truly become something I can always rely on and help me. In the end, I was not only able to survive summer classes, but I was able to thrive thanks to Course Hero.

Dana University of Pennsylvania ‘17, Course Hero Intern

• The ability to access any university’s resources through Course Hero proved invaluable in my case. I was behind on Tulane coursework and actually used UCLA’s materials to help me move forward and get everything together on time.

Jill Tulane University ‘16, Course Hero Intern