×

### Let's log you in.

or

Don't have a StudySoup account? Create one here!

×

or

## COMP SCI 11 WITH C++

by: Mr. Molly Kessler

8

0

4

# COMP SCI 11 WITH C++ CSC 1254

Mr. Molly Kessler
LSU
GPA 3.62

W. Duncan

These notes were just uploaded, and will be ready to view shortly.

Either way, we'll remind you when they're ready :)

Get a free preview of these Notes, just enter your email below.

×
Unlock Preview

COURSE
PROF.
W. Duncan
TYPE
Class Notes
PAGES
4
WORDS
KARMA
25 ?

## Popular in ComputerScienence

This 4 page Class Notes was uploaded by Mr. Molly Kessler on Tuesday October 13, 2015. The Class Notes belongs to CSC 1254 at Louisiana State University taught by W. Duncan in Fall. Since its upload, it has received 8 views. For similar materials see /class/222858/csc-1254-louisiana-state-university in ComputerScienence at Louisiana State University.

×

## Reviews for COMP SCI 11 WITH C++

×

×

### What is Karma?

#### You can buy or earn more Karma at anytime and redeem it for class notes, study guides, flashcards, and more!

Date Created: 10/13/15
CBC 1254 Lecture 16 An Application Using The Stack ADT Operations October 27 2009 0 Designing a Simple Calculator 0 Evaluating Post x Expressions 0 Converting ln x to Post x Expressions 0 APPENDIX The Calculator Code 1 Designing a Simple Calculator In this lecture we will use the ADT stack operations to solve the problem of evaluating simple arithmetic expressions As is the case with using any ADT7 we are not going to make any assumptions regarding the ADT7s implemen tation The strategy we will employ is to rst convert the in x arithmetic expression to a post x expression The stack operations work more naturally with post x expressions Evaluating in x expression is a more involved prob lem For the purpose of this lecture we will restrict ourselves to the following binary operations 7 7 7 and Exponentiation and unary operators will be disallowed to make our lives somewhat easyl Here is a summary of our simplifying assumptions 0 The input is a syntactically correct post x expression 0 No unary operators are present 0 No exponentiation is allowed 0 Operands are positive integers 2 Evaluating Post X Expressions Here is the pseudocode algorithm that evaluates post x expressions for each token Ch in the expression if Ch is an operand Push value that operand Ch represents onto stack else Ch is an operator named Up evaluate and push the result Uperand2 top of stack Pop the stack Uperandl top of stack Pop the stack Result Uperandl Up Uperand2 Push Result onto stack Upon termination of the algorithm7 the value ofthe expression will be on the top of the stack 3 Converting In X to Post X Expressions Here is a high level description of what we must do to convert an expression written in in x notation to one written in post x notation H When you encounter an operand7 append it to the output expression PE 3 Push each 77 77 onto the stack S 00 When you encounter an operator7 if S is empty7 push the operator onto the S However7 if S is not empty7 pop operators of greater or equal precedence off S and append them to PE Stop when you encounter 77 77 or an operator of lower precedence 4 When you encounter 77777 pop operators off the stack and append them to the end of PE7 until you encounter the matching 7777 2 5 When you reach the end of the PE7 you append the remaining contents of the stack to PE Here is a pseudocode algorithm that converts an in x expression to post x mnr for each Ch in the infix form switchCh case operand append operand to the end of PE PE PE Ch represents appending break case quotquot2 push Ch onto S break case quotquot while top of S is not quotquot PE PEtop of S pop S pop S break case operator while S is not empty AND top of S is not quotquot AND PrecedenceCh lt Precedencetop of stack PE PEtop of S pop S push Ch onto S break append to PE the operators remaining in the stack while S is not empty PE PEtop of S pop S

×

×

### BOOM! Enjoy Your Free Notes!

×

Looks like you've already subscribed to StudySoup, you won't need to purchase another subscription to get this material. To access this material simply click 'View Full Document'

## Why people love StudySoup

Steve Martinelli UC Los Angeles

#### "There's no way I would have passed my Organic Chemistry class this semester without the notes and study guides I got from StudySoup."

Jennifer McGill UCSF Med School

#### "Selling my MCAT study guides and notes has been a great source of side revenue while I'm in school. Some months I'm making over \$500! Plus, it makes me happy knowing that I'm helping future med students with their MCAT."

Jim McGreen Ohio University

#### "Knowing I can count on the Elite Notetaker in my class allows me to focus on what the professor is saying instead of just scribbling notes the whole time and falling behind."

Parker Thompson 500 Startups

#### "It's a great way for students to improve their educational experience and it seemed like a product that everybody wants, so all the people participating are winning."

Become an Elite Notetaker and start selling your notes online!
×

### Refund Policy

#### STUDYSOUP CANCELLATION POLICY

All subscriptions to StudySoup are paid in full at the time of subscribing. To change your credit card information or to cancel your subscription, go to "Edit Settings". All credit card information will be available there. If you should decide to cancel your subscription, it will continue to be valid until the next payment period, as all payments for the current period were made in advance. For special circumstances, please email support@studysoup.com

#### STUDYSOUP REFUND POLICY

StudySoup has more than 1 million course-specific study resources to help students study smarter. If you’re having trouble finding what you’re looking for, our customer support team can help you find what you need! Feel free to contact them here: support@studysoup.com

Recurring Subscriptions: If you have canceled your recurring subscription on the day of renewal and have not downloaded any documents, you may request a refund by submitting an email to support@studysoup.com