ICode9

精准搜索请尝试: 精确搜索
首页 > 其他分享> 文章详细

CSC 115 - Lab#6 Stacks

2019-03-02 20:01:03  阅读:336  来源: 互联网

标签:will java CSC stack 115 item bracket Lab Stack



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

因为专业,所以值得信赖。如有需要,请加QQ:99515681 或邮箱:99515681@qq.com 

微信:codinghelp

标签:will,java,CSC,stack,115,item,bracket,Lab,Stack
来源: https://www.cnblogs.com/welhoa/p/10462631.html

本站声明: 1. iCode9 技术分享网(下文简称本站)提供的所有内容,仅供技术学习、探讨和分享;
2. 关于本站的所有留言、评论、转载及引用,纯属内容发起人的个人观点,与本站观点和立场无关;
3. 关于本站的所有言论和文字,纯属内容发起人的个人观点,与本站观点和立场无关;
4. 本站文章均是网友提供,不完全保证技术分享内容的完整性、准确性、时效性、风险性和版权归属;如您发现该文章侵犯了您的权益,可联系我们第一时间进行删除;
5. 本站为非盈利性的个人网站,所有内容不会用来进行牟利,也不会利用任何形式的广告来间接获益,纯粹是为了广大技术爱好者提供技术内容和技术思想的分享性交流网站。

专注分享技术,共同学习,共同进步。侵权联系[81616952@qq.com]

Copyright (C)ICode9.com, All Rights Reserved.

ICode9版权所有