ITSC 1213 - Working with ArrayLists Part 2 Introduction The goal of this lab is to...
Fantastic news! We've Found the answer you've been seeking!
Question:
Transcribed Image Text:
ITSC 1213 - Working with ArrayLists Part 2 Introduction The goal of this lab is to practice working with algorithms to search and sort an ArrayList of objects. Concepts covered in this lab: Using search algorithms to find a specific element in an ArrayList Using sort algorithms to rearrange elements in an ArrayList Required files or links This lab assumes you have successfully completed the Working with ArrayLists Part 1 lab. Consult with the instructional team if you need guidance This lab assumes you have successfully completed sections 7.5 and 7.6 in the CS Awesome textbook Part A: Implement a method that uses sequential search to find a specific order in a list of burger orders. 1. Open the NetBeans Project you called Fast Food kitchen created in the previous lab. 2. Open the Fast FoodKitchen class file and add the following method. The bullet points under the method signature tell you what the method must do. public int findorderSeq(int orderID) Using the value of the parameter orderID, find the position of this order in the list using sequential search algorithm (refer to section 7.5 if you need a refresher) Return the position of the order If an order does not exist in the list that matches order ID, return -1 3. Time to test your new method. Rather than using the main class we used in the previous lab let's create a new class with a main method and give it a unique name (e.g., Module3 Test). Now add the following code to the main method to test your new findOrderSeq method: public static void main(String[] args) { FastFoodKitchen Kitchen new FastfoodKitchen(); int orderPosition kitchen. findrderse (211 System.out.println("Using sequential search order position is + orderPosition; 4. Now, run your program to test the newly added method. Verify that the list of order is now sorted based on the order size not on how/when orders were added to the list. 5. When your program works and you are satisfied with the result, show your work to the instructional team and proceed to Part C. Part C: Implement a method that uses insertion sort to rearrange the elements in an array In this part we will add a method to our Fast FoodKitchen class that implements insertion sort to rearrange the orders in the list of burger orders based on the total number of burgers. 1. Add the following method. The bullet points under the method signature tell you what the method must do: public void insertionsort() Sorts orderList using insertion sort algorithm. The algorithm should perform the sorting based on the total number of burgers in each order, regardless of their type (e.g. if on order has 2 cheeseburgers and 1 veggieburger the total would be 3) 2. Switch over to the main method to test your new method. Comment the line from Part C that calls the selectionsort method and add a statement to call your new insertionsort method // Part C kitchen.insertionSort(); 3. Now, run your program and verify that the list of order is now sorted based on the order size not on how/when orders were added to the list. 4. When your program works and you are satisfied with the result, show your work to the instructional team and proceed to Part D. Part D: Implement a method that uses binary search to find a specific order in a list of burger orders. 1. Now that we can ensure we have a sorted list we can try another search algorithm that works only with sorted arrays/lists. 2. Let's add a new method to our Fast FoodKitchen class that performs a binary search on our order list. The bullet points under the method signature tell you what the method must do. public int findorderBin(int orderID) Using the value of the parameter orderID, find the position of this order in the list using binary search algorithm Return the position of the order If an order does not exist in the list that matches order ID, return -1 3. To test your new method. Switch over to the class you used in Part A to test the search method and add the following code to the main method to test your new findOrderBin method (if you comment any code make sure to keep the call one of the sort methods before you test your new method): // Part D orderPosition = kitchen. findOrderBin (2); System.out.println("Using binary search order position is " + orderPosition); 4. Now, run your program to test the newly added method. Remember to test your code with different values. If you encounter any issues use the debugger tool to inspect your code during execution. This is a great way to reinforce your learning and can help you fix any bugs you might encounter. 5. When your program works and you are satisfied with the result and JavaDoc, show your work to the instructional team to be checked off for this lab. ITSC 1213 - Working with ArrayLists Part 2 Introduction The goal of this lab is to practice working with algorithms to search and sort an ArrayList of objects. Concepts covered in this lab: Using search algorithms to find a specific element in an ArrayList Using sort algorithms to rearrange elements in an ArrayList Required files or links This lab assumes you have successfully completed the Working with ArrayLists Part 1 lab. Consult with the instructional team if you need guidance This lab assumes you have successfully completed sections 7.5 and 7.6 in the CS Awesome textbook Part A: Implement a method that uses sequential search to find a specific order in a list of burger orders. 1. Open the NetBeans Project you called Fast Food kitchen created in the previous lab. 2. Open the Fast FoodKitchen class file and add the following method. The bullet points under the method signature tell you what the method must do. public int findorderSeq(int orderID) Using the value of the parameter orderID, find the position of this order in the list using sequential search algorithm (refer to section 7.5 if you need a refresher) Return the position of the order If an order does not exist in the list that matches order ID, return -1 3. Time to test your new method. Rather than using the main class we used in the previous lab let's create a new class with a main method and give it a unique name (e.g., Module3 Test). Now add the following code to the main method to test your new findOrderSeq method: public static void main(String[] args) { FastFoodKitchen Kitchen new FastfoodKitchen(); int orderPosition kitchen. findrderse (211 System.out.println("Using sequential search order position is + orderPosition; 4. Now, run your program to test the newly added method. Verify that the list of order is now sorted based on the order size not on how/when orders were added to the list. 5. When your program works and you are satisfied with the result, show your work to the instructional team and proceed to Part C. Part C: Implement a method that uses insertion sort to rearrange the elements in an array In this part we will add a method to our Fast FoodKitchen class that implements insertion sort to rearrange the orders in the list of burger orders based on the total number of burgers. 1. Add the following method. The bullet points under the method signature tell you what the method must do: public void insertionsort() Sorts orderList using insertion sort algorithm. The algorithm should perform the sorting based on the total number of burgers in each order, regardless of their type (e.g. if on order has 2 cheeseburgers and 1 veggieburger the total would be 3) 2. Switch over to the main method to test your new method. Comment the line from Part C that calls the selectionsort method and add a statement to call your new insertionsort method // Part C kitchen.insertionSort(); 3. Now, run your program and verify that the list of order is now sorted based on the order size not on how/when orders were added to the list. 4. When your program works and you are satisfied with the result, show your work to the instructional team and proceed to Part D. Part D: Implement a method that uses binary search to find a specific order in a list of burger orders. 1. Now that we can ensure we have a sorted list we can try another search algorithm that works only with sorted arrays/lists. 2. Let's add a new method to our Fast FoodKitchen class that performs a binary search on our order list. The bullet points under the method signature tell you what the method must do. public int findorderBin(int orderID) Using the value of the parameter orderID, find the position of this order in the list using binary search algorithm Return the position of the order If an order does not exist in the list that matches order ID, return -1 3. To test your new method. Switch over to the class you used in Part A to test the search method and add the following code to the main method to test your new findOrderBin method (if you comment any code make sure to keep the call one of the sort methods before you test your new method): // Part D orderPosition = kitchen. findOrderBin (2); System.out.println("Using binary search order position is " + orderPosition); 4. Now, run your program to test the newly added method. Remember to test your code with different values. If you encounter any issues use the debugger tool to inspect your code during execution. This is a great way to reinforce your learning and can help you fix any bugs you might encounter. 5. When your program works and you are satisfied with the result and JavaDoc, show your work to the instructional team to be checked off for this lab.
Expert Answer:
Related Book For
Posted Date:
Students also viewed these programming questions
-
Skip to main content Lab 11: A Web Server The goal of this lab is to write a simple, but functional, web server that is capable of sending files to a web browser on request. The web server must...
-
Marta purchased a home with an adjustable rate mortgage. The margin on an adjustable-rate mortgage is 5.5% and the rate cap is 6.5% over the life of the loan. If the current index rate is 8.9%, find...
-
The accounting records of Brillhart Foods, Inc., include the following items at December 31, 2016: Requirements 1. Show how each relevant item would be reported on the Brillhart Foods, Inc.,...
-
What is the loan balance after 5 years for a $4,700,000annual payment loan at 10.06% interest amortized over 15years? Please show math
-
Research a past California case in which you believe a removal would have changed the outcome of the case. Using your knowledge of the potential advantages of transferring a case already filed in the...
-
Refer to the Auditing in Practice feature, "Professional Skepticism." a. What is professional skepticism? b. Why is professional skepticism necessary to detecting fraud? c. What are the key behaviors...
-
A trailer manufactor has multiple products designed to be towed by a pickup (Ford F-150, Toyota Tacoma, etc). The production of one of their products - the XL7 5x10 trailer - referred to as XL7510...
-
You are a financial analyst at a firm that has been returning cash to shareholders through stock repurchases. You want to determine how the level of repurchases will vary as a function of the sales...
-
Here are data on two stocks, both of which have discount rates of 16%: Stock A 16% Return on equity Earnings per share. Dividends per share Dividend payout ratios a. What are the dividend payout...
-
why is the inflow of cash from receiving dividends is considered an operating activity while the outflow of cash from paying dividends to stockholders is considered a financing activity. why aren't...
-
3. The springs (k25 lb/ft) are un- stretched when s = 0. The 50-lb weight is released from rest in the position s = 0. (a) (b) When the weight has fallen 1 ft, how much work has been done on it by...
-
what are the advantages of dual model as per ASC 8 4 2 leases . How is 8 4 2 dual model is better than IFRS 1 6
-
What ways does the unreliable narrator serve as a narrative device to challenge traditional notions of truth and reality in contemporary fiction ?
-
The requirements specify which entities and data are important to the business. Here are the requirements for this database. manager monitors employee data: e mployee name, salary, and addresses...
-
A politician claims that the mean salary for managers in his state is more than the national mean, $85,000. Assume the the population is normally distributed and the population standard deviation is...
-
On January 1, 2017, McIlroy, Inc., acquired a 60 percent interest in the common stock of Stinson, Inc., for $340,200. Stinson's book value on that date consisted of common stock of $100,000 and...
-
Santos Industries manufactures a variety of custom products. The company has traditionally used a plantwide manufacturing overhead rate based on machine hours to allocate manufacturing overhead...
-
The annual data that follow pertain to Flannery Water Optics, a manufacturer of swimming goggles (the company had no beginning inventories): Sales...
-
Three Brothers Catering uses the high- low method to predict its total overhead costs. Past records show that total overhead cost was $ 25,600 when 810 hours were worked and $ 27,700 when 910 hours...
-
Discuss the physical meaning of the small-signal circuit parameter \(r_{o}\).
-
Discuss, using the concept of a load line, how a simple common-source circuit can amplify a time-varying signal.
-
Sketch a simple source-follower amplifier circuit and discuss the general ac circuit characteristics (voltage gain and output resistance).
Study smarter with the SolutionInn App