Develop an algorithm using the Java programming language that implements a basic stack data structure. Your...
Fantastic news! We've Found the answer you've been seeking!
Question:
Transcribed Image Text:
Develop an algorithm using the Java programming language that implements a basic stack data structure. Your stack must have the ability to push entries on the stack. Your stack must also have the ability to pop entries off of the stack. By the end of the week, you must submit your work to the Assignment Unit 3 link located on the course home page. For this assignment, assume that you are developing a system for a manufacturing assembly line that builds automobiles. There are three stations in the manufacturing line where an inspector will visually inspect the vehicle. Your program must keep track of these inspections as they occur. You decided to develop your program using a stack data structure. As your vehicle begins the line you will push the number 0, which indicates that an inspection has not yet occurred, onto the stack three subsequent times. At each station in the line, you will pop one of the items off of the stack. Each time your algorithm pops an item from the stack you must print it out to the console using the System.out.println function. Your algorithm should perform the functions of the stack as illustrated in the above diagram. You will develop your algorithm using Java code, and by using the Jeliot tool as a development environment. Jeliot can be executed directly from the following website (http://cs.joensuu.fi/jeliot/javaws/jeliot.jnlp). Instructions for using Jeliot can be found at http://cs.joensuu.fi/jeliot/index.php. You can use the example files provided with the course as a reference for developing a simple algorithm and for examples of implementing a structure as either an array or link implementation. You can select to implement your stack as either an array or linked list implementation. When you post your algorithm, you should compare the efficiency of your algorithm with those of your peers to determine what approach provides the most efficient and elegant solution to the problem. As part of your assignment, you must submit both a description of the assignment and how your algorithm works including an Asymptotic analysis of your algorithm. Your analysis must include the efficiency of your algorithm expressed in Big Oh notation. As part of your assignment, you must include the code of your algorithm. All of these elements of this assignment must be completed and posted to the assignment for Unit 3 by the end of the week for unit 3. The following week, you must review the work of at least three of your peers. As part of your review, you must copy and paste your peer's code into the Jeliot tool and execute it. If the code does not function properly you should make suggestions on how to correct the problems (if possible). If the efficiency of the algorithm can be improved you should make these suggestions. You should coordinate with your fellow student and follow up on any corrections they make by re-running the code and providing additional feedback. As you review your own algorithm and those of your peers, you should be looking for the following characteristics that our text outlined as being requirements of a 'good' algorithm. It must provide the correct output based upon the input It must be composed of concrete steps There can be NO ambiguity of the flow of the algorithm The algorithm must have a finite number of steps that is determinable The algorithm must terminate or complete If either your algorithm or the algorithms of your peers that you are reviewing do not exhibit these characteristics, you should collaboratively determine why the algorithm does not exhibit these characteristics and offer suggestions to correct the algorithm such that it does exhibit these characteristics. Addendum: Linked List Example If you need an example of the code that can be used to implement a linked list, you can look at the following and perhaps should animate it in the Jeliot environment. The following implements a simple linked list and then prints the list out after it has been created. The data structure implemented in this example is a LIFO (last in first out) structure, which we know from this unit's learning, is known as a stack. We could have implemented the code to add items to the list as a method in this example, but did not, to simplify the code. class Node { Node ptr; int value; } public Node(int value) { this.value = value; } public class CreateLinkedList { public static void main(String[] args) { Node link, plink; // root will be the beginning of the linked list Node root = new Node(5); // each additional node will link to preceeding one link = new Node(1); link.ptr = root; plink link; = link = new Node(8); link.ptr = plink; plink = link; link = new Node(6); link.ptr = plink; plink = link; link = new Node(3); } } link.ptr = plink; plink = link; public static void printList(Node node) { if (node != null) { } // Move through the list and print out each value printList(link); System.out.println(" Value: " + node.value); printList(node.ptr); } Assignment Grading Rubric Algorithm implements a stack data structure algorithm that includes each of the following: . O O o Includes method (or equivalent code) to push items onto the stack Includes method (or equivalent code) to pop items off of the stack Algorithm pushes three items on to the stack Algorithm pops three items off of the stack and reports each time it does so by writing a message to the console. Stack is implemented as either an array or linked list Is Source code (that can be loaded into the Jeliot tool) for the algorithm is included in the assignment post? Does the source code execute (within Jeliot) and provide the appropriate output? Does the assignment post includes a description of the operation of the algorithm and the description includes an Asymptotic analysis of the algorithm expressed in Big O notation? Is the Asymptotic analysis is correct (does it match the example provided by the instructor)? Develop an algorithm using the Java programming language that implements a basic stack data structure. Your stack must have the ability to push entries on the stack. Your stack must also have the ability to pop entries off of the stack. By the end of the week, you must submit your work to the Assignment Unit 3 link located on the course home page. For this assignment, assume that you are developing a system for a manufacturing assembly line that builds automobiles. There are three stations in the manufacturing line where an inspector will visually inspect the vehicle. Your program must keep track of these inspections as they occur. You decided to develop your program using a stack data structure. As your vehicle begins the line you will push the number 0, which indicates that an inspection has not yet occurred, onto the stack three subsequent times. At each station in the line, you will pop one of the items off of the stack. Each time your algorithm pops an item from the stack you must print it out to the console using the System.out.println function. Your algorithm should perform the functions of the stack as illustrated in the above diagram. You will develop your algorithm using Java code, and by using the Jeliot tool as a development environment. Jeliot can be executed directly from the following website (http://cs.joensuu.fi/jeliot/javaws/jeliot.jnlp). Instructions for using Jeliot can be found at http://cs.joensuu.fi/jeliot/index.php. You can use the example files provided with the course as a reference for developing a simple algorithm and for examples of implementing a structure as either an array or link implementation. You can select to implement your stack as either an array or linked list implementation. When you post your algorithm, you should compare the efficiency of your algorithm with those of your peers to determine what approach provides the most efficient and elegant solution to the problem. As part of your assignment, you must submit both a description of the assignment and how your algorithm works including an Asymptotic analysis of your algorithm. Your analysis must include the efficiency of your algorithm expressed in Big Oh notation. As part of your assignment, you must include the code of your algorithm. All of these elements of this assignment must be completed and posted to the assignment for Unit 3 by the end of the week for unit 3. The following week, you must review the work of at least three of your peers. As part of your review, you must copy and paste your peer's code into the Jeliot tool and execute it. If the code does not function properly you should make suggestions on how to correct the problems (if possible). If the efficiency of the algorithm can be improved you should make these suggestions. You should coordinate with your fellow student and follow up on any corrections they make by re-running the code and providing additional feedback. As you review your own algorithm and those of your peers, you should be looking for the following characteristics that our text outlined as being requirements of a 'good' algorithm. It must provide the correct output based upon the input It must be composed of concrete steps There can be NO ambiguity of the flow of the algorithm The algorithm must have a finite number of steps that is determinable The algorithm must terminate or complete If either your algorithm or the algorithms of your peers that you are reviewing do not exhibit these characteristics, you should collaboratively determine why the algorithm does not exhibit these characteristics and offer suggestions to correct the algorithm such that it does exhibit these characteristics. Addendum: Linked List Example If you need an example of the code that can be used to implement a linked list, you can look at the following and perhaps should animate it in the Jeliot environment. The following implements a simple linked list and then prints the list out after it has been created. The data structure implemented in this example is a LIFO (last in first out) structure, which we know from this unit's learning, is known as a stack. We could have implemented the code to add items to the list as a method in this example, but did not, to simplify the code. class Node { Node ptr; int value; } public Node(int value) { this.value = value; } public class CreateLinkedList { public static void main(String[] args) { Node link, plink; // root will be the beginning of the linked list Node root = new Node(5); // each additional node will link to preceeding one link = new Node(1); link.ptr = root; plink link; = link = new Node(8); link.ptr = plink; plink = link; link = new Node(6); link.ptr = plink; plink = link; link = new Node(3); } } link.ptr = plink; plink = link; public static void printList(Node node) { if (node != null) { } // Move through the list and print out each value printList(link); System.out.println(" Value: " + node.value); printList(node.ptr); } Assignment Grading Rubric Algorithm implements a stack data structure algorithm that includes each of the following: . O O o Includes method (or equivalent code) to push items onto the stack Includes method (or equivalent code) to pop items off of the stack Algorithm pushes three items on to the stack Algorithm pops three items off of the stack and reports each time it does so by writing a message to the console. Stack is implemented as either an array or linked list Is Source code (that can be loaded into the Jeliot tool) for the algorithm is included in the assignment post? Does the source code execute (within Jeliot) and provide the appropriate output? Does the assignment post includes a description of the operation of the algorithm and the description includes an Asymptotic analysis of the algorithm expressed in Big O notation? Is the Asymptotic analysis is correct (does it match the example provided by the instructor)?
Expert Answer:
Answer rating: 100% (QA)
import javautilStack public class InspectionStack public static void mainStr... View the full answer
Related Book For
Business Data Communications Infrastructure Networking and Security
ISBN: 978-0133023893
7th edition
Authors: William Stallings, Tom Case
Posted Date:
Students also viewed these programming questions
-
= (7750 r) r N/C (here r is the unit vector in the radial direction). Course Contents >> HM2-PHYS250-SP21 P2: charged sphere. calc.... A spherically symmetric charge distribution produces an electric...
-
Planning is one of the most important management functions in any business. A front office managers first step in planning should involve determine the departments goals. Planning also includes...
-
Design a Java class that represents a cache with a fixed size. It should support operations like add, retrieve, and remove, and it should evict the least recently used item when it reaches capacity.
-
Given the observed yields below, what is the 1-year forward rate, 4 years from now? [Hint: This is the 1-year return that will take you from the 4-year average annualized return (yield) to the 5-year...
-
Study the restaurant transactions for the month of March 2006 shown in the following list (a to i). Record the necessary journal entries, skipping a line between each entry. Journal entries and...
-
Sam Johnson inherited $85,000 from his father. Sam is considering investing the money in a house, which he will then rent to tenants. The $85,000 cost of the property, consists of $17,500 for the...
-
One of the key features of CSF use is making the implicit into explicit, explain what this means in an operational context.
-
Chipcity Inc. is a fast-growing manufacturer of computer chips. Direct materials are added at the start of the production process. Conversion costs are added evenly during the process. Some units of...
-
The standard material required manufacturing one unit of product P is 5 Kg and the price per Kg of material is RO 3.00. The cost accounts record however, reveal that 16,000 Kgs of material costing...
-
Part of Glo's strategic plan is to capture market segments that are traditionally underserved. Glo's management believes that the market for men's care products is underserved and would be an...
-
. Assignment #1 ?? Value 5% On December 1, 2021, George and Myra started a corporation called Caper Rental Equipment. The new corporation began operations immediately as they were able to purchase ...
-
John and Rita are house hunting. They have found a place that they intend to purchase, it requires a mortgage amount of $130,400. Their banker has presented them with two options: 30 year fixed rate...
-
Project X has a cost of $100,000 and provides the following annual earnings: year 1 $35,000; year 2 $25,000; year 3 $175,000; and year 4 $12,000. What is your internal rate of return?
-
Troy Engines, Ltd., manufactures a variety of engines for use in heavy equipment. The company has always produced all of the necessary parts for its engines, including all of the carburetors,. An...
-
35-40 Find the functions (a) fog, (b) gof, (c) fof, and (d) gog and their domains. 35. f(x)=x+5, g(x) = x 36. f(x) = g(x) = 2x + 1 37. f(x) = g(x)=x+1 x 38. f(x) = g(x) = 2x - 1 39. f(x)= x+1' 2 =...
-
Can you explain how Apple's supply chain supports its products, services and processes?
-
plshelp...will upvote Calvin reviewed his canceled checks and receipts this year (2022) for charitable contributions, which included an antique painting and IBM stock. He has owned the IBM stock and...
-
Sheldon and Leonard had a million-dollar idea. In order to make it happen, they have to do special research first. Only Kripke can help them in this matter. But Kripke is known to be the first-class...
-
Briefly describe the major characteristics of data centers.
-
Do some Internet research on the Mobile Web. Locate information that compares the Mobile Web to traditional Internet resources. Identify examples of Mobile Web applications that are especially...
-
Briefly describe the role of a forwarding equivalence class (FEC) in MPLS.
-
In preparing monthly financial statements, overapplied overhead is rep orated in the balance sheet as a(an): (a) prepaid expense. (b) unearned revenue. (c) noncurrent asset. navigator (d) noncurrent...
-
Hal Adelman is studying for an accounting midterm examination. What should Hal know about how management may use job cost data?
-
What are the major differences in measurement principles between the Anglo-Saxon, Nordic, Germanic, Latin, and Asian countries?
Study smarter with the SolutionInn App