lab7
Differences
This shows you the differences between two versions of the page.
Both sides previous revisionPrevious revisionNext revision | Previous revision | ||
lab7 [2017/02/18 20:31] – franck | lab7 [2018/03/11 23:19] (current) – franck | ||
---|---|---|---|
Line 1: | Line 1: | ||
- | The beam search strategy uses the breadth-first search strategy to build its state space. | + | ====== Lab 7 ====== |
- | {{: | + | In this lab, we consider a concurrent stack. We start from the following skeleton of a sequential stack. |
+ | <code java> | ||
+ | /** | ||
+ | * A stack. | ||
+ | * | ||
+ | * @author | ||
+ | */ | ||
+ | public class Stack { | ||
+ | private int[] content; | ||
+ | private int size; | ||
- | While traversing the state space, the beam search strategy will visit the states labelled A, B, C, E and F. | + | /* |
+ | * The maximal number of integers that can be stored in a stack. | ||
+ | */ | ||
+ | private final static int CAPACITY = 5; | ||
- | Create a search strategy, named BeamSearch, which implements the beam search strategy. | + | /** |
+ | * Initializes this stack to be empty. | ||
+ | */ | ||
+ | public Stack() { | ||
+ | this.content = new int[Stack.CAPACITY]; | ||
+ | this.size = 0; | ||
+ | } | ||
- | To receive feedback, submit your test case using the submit command | + | /** |
- | submit 4315 lab7 BeamSearch.java | + | * Pushes the given integer onto this stack. |
+ | * | ||
+ | * @param value the integer to be pushed onto this stack. | ||
+ | */ | ||
+ | public void push(int value) { | ||
+ | this.content[this.size] = value; | ||
+ | this.size++; | ||
+ | System.out.printf(" | ||
+ | } | ||
+ | |||
+ | /** | ||
+ | * Pops the top of this stack and returns the integer. | ||
+ | * | ||
+ | * @return the top of this stack. | ||
+ | */ | ||
+ | public int pop() { | ||
+ | this.size--; | ||
+ | int value = this.content[this.size]; | ||
+ | System.out.printf(" | ||
+ | return value; | ||
+ | } | ||
+ | } | ||
+ | </ | ||
+ | |||
+ | Implement the following classes. | ||
+ | * The class Pusher. | ||
+ | * The class Stack. | ||
+ | * The class Main. This class only contains a main method. | ||
+ | |||
+ | To receive feedback, submit your code using the submit command:\\ | ||
+ | < | ||
+ | submit 4315 lab7 <name of class>.java | ||
+ | </ | ||
lab7.1487449884.txt.gz · Last modified: 2017/02/18 20:31 by franck