Question
1) A) Hand trace an ordered list X through the following operations. For each add operation, give the contents of the list and indicate the
1)
A) Hand trace an ordered list X through the following operations. For each add operation, give the contents of the list and indicate the head. For first, removeLast, and remove, indicate the value of each variable.
X.add(new Integer(4));
X.add(new Integer(7));
Object Y = X.first();
X.add(new Integer(3));
X.add(new Integer(2));
X.add(new Integer(5));
Object Y = X.removeLast();
Object Y = X.remove(new Integer(7));
X.add(new Integer(9));
B) Given the resulting list X from Exercise 6.1, what would be the result for each of the following? For each, give the final list contents (with labeled front), and the value of the variables.
a. W = X.last();
b. Z = X.contains(new Integer(3));
X.first();
c. Y = X.remove(new Integer(2));
X.first();
C) What would be the time complexity of the size operation for the linked implementation if there were not a count variable?
D) In the array implementation, under what circumstances could the rear reference equal 0?
Step by Step Solution
There are 3 Steps involved in it
Step: 1
Get Instant Access to Expert-Tailored Solutions
See step-by-step solutions with expert insights and AI powered tools for academic success
Step: 2
Step: 3
Ace Your Homework with AI
Get the answers you need in no time with our AI-driven, step-by-step assistance
Get Started