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

As a preparation for this lab it would be a good idea to review your code for yo

ID: 3703466 • Letter: A

Question


As a preparation for this lab it would be a good idea to review your code for your LinkedStack andLinkedQueue classes 1. Hand trace an ordered list X through the following operations. Operation X.add(new Integer(4) X add (new Integer(7) Object Y X.first0) Kadd(newlnteger(3))i X.add(new Integer(2): X.add(new Integer(5)) Object Y = X. removeLasto Object Y X.remove(new Integer/7): X.add(new Integer(9) List 2. Given the resulting list X from Exercise 1, what would be the result of each of the following? Operation Result z = x.contains(new Integer(3)); X.f Y X.remove(new Integer(2)); X.f 3. What would be the time complexity of the size operation for the linked implementation if there were not a count variable? 4. In the linked implementation, under what circumstances could the head and tail references be equal?

Explanation / Answer

Q 1.

Q 2.

z = X.contains(new Integer(3));

X.first();

z = True,

2 (result of X.first())

Y = X.remove(new Integer(2));

X.first();

Y = True,

3 (result of X.first())

Operation List X.add(new Integer(4); X = {4} X.add(new Integer(7); X = {4,7} Object Y = X.first(); Y = 4, X = {4,7} X.add(new Integer(3); X = {3,4,7} X.add(new Integer(2); X = {2,3,4,7} X.add(new Integer(5); X = {2,3,4,5,7} Object Y = X.removeLast(); Y = 7, X = {2,3,4,5} Object Y = X.remove(new Integer(7)); Y = False, X = {2,3,4,5} X.add(new Integer(9); X = {2,3,4,5,9}
Hire Me For All Your Tutoring Needs
Integrity-first tutoring: clear explanations, guidance, and feedback.
Drop an Email at
drjack9650@gmail.com
Chat Now And Get Quote