CSC 115 - Lab#6 Stacks

Posted welhoa

tags:

篇首语:本文由小常识网(cha138.com)小编为大家整理,主要介绍了CSC 115 - Lab#6 Stacks相关的知识,希望对你有一定的参考价值。


CSC 115 - Lab#6 Stacks
Objectives
During Lab#6, week, you will be completing a programming exercise that you will hand in
through conneX. You will learn:
How to implement common operations related to Stacks based on a singly-linked list.
How to solve a practical problem using a Stack.
How to build a tester and debug your codes in Java.
Required files
You will need to hand in two java files that you complete:
Stack.java
BracketBalance.java
The following files are provided as helper files:
Node.java
Tester.java
Stack Review
Though we usually line up as a Queue to pay our groceries in stores, we use Stack unconsciously
daily: surfing the internet using browsers, when we go back to the previous page, we
click on the <= button. The websites that we have just visited are actually stored in a Stack.
A Stack is an abstract data type which is used to store a collection of data. It has the property
that the last item placed on the stack will be the first item removed. The property is referred
to as Last-in, first-out (LIFO). Common operations related to Stack are:
empty - check if the stack is empty

CSC 115作业代写
push (item) - push the item on to the stack
peek - check what is on top of the stack. The stack is not changed.
pop - remove the item at the top of the stack. The stack is reduced by one.
Your Task: Download Stack.java and implement the methods. Notice that the Node class
Page 1 of 2
will be used in Stack class and you should download this file as well.
Stack Application - Bracket Balancing
Stack is very useful to check if braces are balanced in mathematic expressions. The algorithm
can be:
For a sequence of characters
If there is an open brace “{”, or bracket “(”, or square bracket “[”, then push it onto the stack;
If there is an closing brace “}”, or bracket “)”, or square bracket “]”, then:
If the stack is empty, then it is not balanced
Else
Pop the stack;
If the popped character is not the matching open brace/bracket/square-bracket, then
the sequence is not balanced.
After the sequence is processed, it is safe to say that it is balanced.
Your Task: Download BracketBalance.java and finish the implementation.
The Test.java program will give a Pass or Fail depending on the automated test results. Note
that a Pass is not an indication that everything is perfect, the intention is to reward effort, and
give enough feedback so you can seek guidance if you see that you can benefit from it.
Document created by: Tianming Wei on February 25, 2019

因为专业,所以值得信赖。如有需要,请加QQ99515681 或邮箱:[email protected] 

微信:codinghelp

以上是关于CSC 115 - Lab#6 Stacks的主要内容,如果未能解决你的问题,请参考以下文章

来自仙守博友记录的hinton教授的本科生课程CSC321-机器学习中的神经网的笔记

[6][lab] lab1: map reduce

Lab 6-4

计算系统概论实验Lab 6——C重写Lab1-5

6. Lab: Multithreading

ICC_lab总结——ICC_lab6:版图完成