Question 1: Assume that you have a Queue that is implemented using an array, where front (an int) is the index of the first item in the queue, and end (an int) is the index of the empty position immediately following the last item in the queue. For example, front=2 and end=4 would mean that there are items at index 2 and index 3, but NOT at index 4. Also assume that in addition to front and end the Queue class contains an array named theArray to store the items. The queue is allowed to wrap around from the end of the array to the start of the array, as seen in the Week 6 slides (slide #76 to #79). Write a private method named enlargeQueue, that would be part of the Queue class, which will double the size of the array, copy items from the original array into the new array, and update the Queue instance variables (front, end, theArray) to refer to the new array. Hint: Place the items starting at index o in the new array. Question 2: Assume you have an ordinary linked list (singly-linked, no dummy nodes) comprised of Nodes defined as below, and a pointer to the first node in the linked list (named top). class Node { public int data; public Node next; public Node (int d, Node n) { data = d; next = n; } } Write a method (named modifyList) to modify the given list in the following way. If the data in a given node is an even number, insert a second copy of that node into the list. If the data in a given node is an odd number, remove that node from the list. For example, if the initial list contains 147528 then the modified list would be 442288 From a main method, this method might be called as in LinkedList test = new LinkedList( (); code to fill the list test.modifyList() ; That is, the modifyList method is part of the LinkedList class. Write only the modifyList method. Do not write a complete LinkedList class or a main class.
Recent Posts
- A6001C17 Advances in Animal Production Science Assignment Brief 2026 | HAU
- SOCI5270 Contemporary Sociological Theory Essay Assessment 2026 | UOK
- 4BE002 The Innovative Business Assignment Brief 2026 | University of Wolverhampton
- NURS427 Assignment Two Brief NURS427 Long-term Conditions: Pathophysiology and Management / NĀHI 427 Mate Mauroa – Mātai Tukumate- Whaiaroaro me te Whakahaere Assignment
- Question 1 Read this fictitious scenario before answering the questions. Atlantis is a small country located in the middle of the Indian Ocean. Situated along a busy international shipping route, it is a major port of call for ships traversing
Recent Comments
No comments to show.
Archives
- February 2026
- January 2026
- December 2025
- November 2025
- October 2025
- September 2025
- August 2025
- July 2025
- June 2025
- May 2025
- April 2025
- March 2025
- February 2025
- January 2025
- December 2024
- November 2024
- October 2024
- September 2024
- August 2024
- July 2024
- June 2024
- May 2024
- April 2024
- March 2024
- February 2024
- January 2024
