A 15pts Write A Method Boolean Replace Int Item Int New Item That Replaces All Occurrences Of Item In A List With N 1 (44.07 KiB) Viewed 30 times
A 15pts Write A Method Boolean Replace Int Item Int New Item That Replaces All Occurrences Of Item In A List With N 2 (38.7 KiB) Viewed 30 times
a. [15pts] Write a method boolean Replace(int item, int new_item) that replaces all occurrences of item in a list with new_item and return false if new_item is not found. For example, if item is "3" new_item is 5, then the method should replace all nodes that contain 3 with 5. b. [15pts] Write a method void merge(LinkedList LL, boolean append) that takes another linked list as a parameter, merges it with current linked list adding it after the original linked list if append is true, else the new list should be added before the original linked list. The below figures demonstrates the concept: Append is true Append is false Original new Last Last First First new Original Question 2: Queues and Stacks [50 points] a. Write a class called hyprid that uses linked lists to represent a queue and stack. As you can recall that the only difference in between the stack and the queue is that the stack uses the addHead method to push items and the queue uses the addTail method to insert items. The class should be implemented using LinkedLists. The class should contain the following methods: a. boolean empty() to check if the underlying list is empty b. void push(int item) to add the item using addFirst c. void insert (int item) to add the item using addLast d. int remove() to remove an item from the beginning of the list e. int pop() the same as above but with name changed
Join a community of subject matter experts. Register for FREE to view solutions, replies, and use search function. Request answer by replying!