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

(1) To remove a specified entry of a bag that is implemented with a linked chain

ID: 3870722 • Letter: #

Question

(1) To remove a specified entry of a bag that is implemented with a linked chain, first get a reference to the node to remove, then the most efficient approach is to:

a) move the data in the first node to the referenced node , then remove the first node

b) search through the chain again and find the previous node, have its next reference jump over the node to remove

c) shift the nodes down in reverse order

d) move the data in the last node to the referenced node , then remove the last node

(2)

Which bag behavior(s) would need to be modified when implementing a set?

(for this problem, answer can be more than 1.)

  

a) add()

  

b) clear()

  

c) contains()

  

d) toArray()

Explanation / Answer

Ans 1) The most efficient approach is to:

a) move the data in first node to the referenced node, then remove the first node.

Ans 2) add() and contains() bag behaviours would need to be modified when implementing a set.Firstly we will add a string object to the set,and then verify that the set contains the element which was added initially.

Thanks :)