Assessment of Programming Skills of First Year CS Students: Problem Set

Similar documents
09 STACK APPLICATION DATA STRUCTURES AND ALGORITHMS REVERSE POLISH NOTATION

Project 3: RPN Calculator

Some Applications of Stack. Spring Semester 2007 Programming and Data Structure 1

STACKS. A stack is defined in terms of its behavior. The common operations associated with a stack are as follows:

Lecture 3 Tao Wang 1

Prefix/Infix/Postfix Notation

12 Abstract Data Types

SimpleCalc. which can be entered into a TI calculator, like the one on the right, like this:

Lab 7 1 Due Thu., 6 Apr. 2017

Unit 3. Operators. School of Science and Technology INTRODUCTION

CS 206 Introduction to Computer Science II

Stating the obvious, people and computers do not speak the same language.

CS W3134: Data Structures in Java

Chapter 1: Foundations for Algebra

CDA 3103 Computer Organization Homework #7 Solution Set

Will introduce various operators supported by C language Identify supported operations Present some of terms characterizing operators

Formal Languages and Automata Theory, SS Project (due Week 14)

CS 2604 Minor Project 1 Summer 2000

Only to be used for arranged hours. Order of Operations

An algorithm may be expressed in a number of ways:

Supplemental Materials: Grammars, Parsing, and Expressions. Topics. Grammars 10/11/2017. CS2: Data Structures and Algorithms Colorado State University

CSc 10200! Introduction to Computing. Lecture 2-3 Edgardo Molina Fall 2013 City College of New York

CS 2604 Minor Project 1 DRAFT Fall 2000

CS2383 Programming Assignment 3

Any Integer Can Be Written as a Fraction

This book is licensed under a Creative Commons Attribution 3.0 License

CS Introduction to Data Structures How to Parse Arithmetic Expressions

CS 211 Programming Practicum Spring 2017

10 Using the PCFL Editor In this chapter

Operators. Lecture 3 COP 3014 Spring January 16, 2018

Programming Lecture 3

Language Basics. /* The NUMBER GAME - User tries to guess a number between 1 and 10 */ /* Generate a random number between 1 and 10 */

Stacks Calculator Application. Alexandra Stefan

Computer Programming CS F111

Lab copy. Do not remove! Mathematics 152 Spring 1999 Notes on the course calculator. 1. The calculator VC. The web page

Problem with Scanning an Infix Expression

MATVEC: MATRIX-VECTOR COMPUTATION LANGUAGE REFERENCE MANUAL. John C. Murphy jcm2105 Programming Languages and Translators Professor Stephen Edwards

STACKS AND QUEUES. Problem Solving with Computers-II

Full file at

Project 1: Implementation of the Stack ADT and Its Application

Stacks (Section 2) By: Pramod Parajuli, Department of Computer Science, St. Xavier s College, Nepal.

F453 Module 7: Programming Techniques. 7.2: Methods for defining syntax

LECTURE 3 C++ Basics Part 2

2. Numbers In, Numbers Out

hp calculators HP 33S Using RPN and Algebraic Modes Calculation modes A simple example in RPN Functions of a single number in RPN

Welcome to CS 135 (Winter 2018)

This is an individual assignment and carries 100% of the final CPS 1000 grade.

CS102: Variables and Expressions

Assignment 5. Introduction

CS 171: Introduction to Computer Science II. Stacks. Li Xiong

Evaluating Expressions Using the Order of Operations

Table of Contents. Introduction to the Math Practice Series...iv Common Mathematics Symbols and Terms...1

Chapter 2 Using Data. Instructor s Manual Table of Contents. At a Glance. Overview. Objectives. Teaching Tips. Quick Quizzes. Class Discussion Topics

2.2 Syntax Definition

Chapter 2 Using Data. Instructor s Manual Table of Contents. At a Glance. A Guide to this Instructor s Manual:

Graphics calculator instructions

Assignment 4 Publication date: 27/12/2015 Submission date: 17/01/ :59 People in-charge: R. Mairon and Y. Twitto

Examples of attributes: values of evaluated subtrees, type information, source file coordinates,

Programming Logic and Design Seventh Edition Chapter 2 Elements of High-Quality Programs

The Stack and Queue Types

Basic Arithmetic Operations

CSE 214 Computer Science II Stack

hp calculators HP 50g Algebraic and RPN Operating Modes Calculation Modes A simple example - the area of a piece of carpet Setting the mode

Overview of C, Part 2. CSE 130: Introduction to Programming in C Stony Brook University

Chapter 2: Using Data

Exponential Notation

Numerical Analysis First Term Dr. Selcuk CANKURT

2. Numbers In, Numbers Out

Our Strategy for Learning Fortran 90

CS 211 Programming Practicum Spring 2018

C++ Programming Language Lecture 2 Problem Analysis and Solution Representation

Data Types and the while Statement

Algebraic Expressions

Welcome to CS 115 (Winter 2018)

Professor: Sana Odeh Lecture 3 Python 3.1 Variables, Primitive Data Types & arithmetic operators

9/10/10. Arithmetic Operators. Today. Assigning floats to ints. Arithmetic Operators & Expressions. What do you think is the output?

Stack Abstract Data Type

Stack Applications. Lecture 27 Sections Robb T. Koether. Hampden-Sydney College. Wed, Mar 29, 2017

Learning Log Title: CHAPTER 3: ARITHMETIC PROPERTIES. Date: Lesson: Chapter 3: Arithmetic Properties

Microsoft Office Excel 2007

download instant at Introduction to C++

-The Hacker's Dictionary. Friedrich L. Bauer German computer scientist who proposed "stack method of expression evaluation" in 1955.

Introduction to C++ General Rules, Conventions and Styles CS 16: Solving Problems with Computers I Lecture #2

hp calculators HP 35s Using Algebraic Mode Calculation modes Functions of a single number in algebraic A simple example in algebraic

I Year MCA I Semester L T P To C FOUNDATIONS OF INFORMATION TECHNOLOGY

UNIT-II. Part-2: CENTRAL PROCESSING UNIT

MAT 003 Brian Killough s Instructor Notes Saint Leo University

CS 211 Programming Practicum Fall 2018

Introduction to Computers. Laboratory Manual. Experiment #3. Elementary Programming, II

VARIABLES. Aim Understanding how computer programs store values, and how they are accessed and used in computer programs.

Full file at

Expressions, Input, Output and Data Type Conversions

Using Basic Formulas 4

Welcome to CS 135 (Fall 2018) Themes of the course. Lectures. cs135/

Rational Numbers CHAPTER Introduction

CS & IT Conversions. Magnitude 10,000 1,

Jython. secondary. memory

Chapter 04: Instruction Sets and the Processor organizations. Lesson 18: Stack-based processor Organisation

CSCE 156 Computer Science II

March 13/2003 Jayakanth Srinivasan,

Transcription:

Assessment of Programming Skills of First Year CS Students: Problem Set Notes to the working group participants. Enclosed in this file are the three problems. They are in ascending order of difficulty. As a baseline, we think our second semester students should be able to do problem 3 in 1.5 hours. To maintain consistency, the problems (no matter which you choose) should be given in the following manner. This is individual work. The work is to be done in a closed lab (meaning proctored with the students doing the work in the allotted time). The student's job is to produce a working, tested, etc., program in the time allotted. This is a programming exercise, the expectations are that the students will produce a program. Any design documentation, though important to solving the problem, is not important to this assessment. What follows can be cut and pasted as the assignment. Note the introduction is applicable to all three problems.

Introduction ( 10 minutes to read and understand ) There are two main notations for entering information into hand-held calculators; Hewlett Packard calculators for the most part implement a Reverse Polish Notation (RPN), or post-fix notation, whereas Texas Instruments calculators implement the traditional infix notation. The major difference in the two styles is the order in which the mathematical operations are entered and executed. RPN is a stack-based method of processing input. Numbers are read in and processed in the reverse order in which they are entered, while the operations themselves are read in and processed sequentially. Infix notation is the traditional method that most modern textbooks have adopted. It is mainly a symbol-based method of processing mathematical expressions, making use of a set of precedence rules defining the order in which values are processed by encapsulating operators and symbols. RPN has a clear advantage over infix notation because RPN offers a simple implementation, naturally avoids ambiguity, and does not require parentheses. However, unless the user is well practiced in the art of RPN, it is not automatically intuitive in its use. For example, the infix notation for a particular formula is: -( 4 + ( 6 * (-2) ) - 15 ) (1) However, in RPN, the same expression yields the following formula: 4 6 2 ~ * + 15 - ~ (2) In RPN, the numbers on the bottom of the stack are processed first, and then work their way up as the values are reduced toward the top. Clearly, the more intuitive format from an academic standpoint is infix notation (Equ. 1). However, you must deal with issues of precedence; in general, this is not as easy to program as the RPN-style of input (Equ. 2). Other examples of infix and RPN style expression pairs are as follows: 4 * -( 4 + 10 / 2.5 8 ) (3) 4 4 10 2.5 / + 8 - ~ * (4) 17.2 + 21 * 3 / (-7) + 21 (5) 17.2 21 3 * 7 ~ / + 21 + (6) ( ( -( 2 + 3 * 8 ) ) ^ 4 ) * 7 (7) 2 3 8 * + ~ 4 ^ 7 * (8) 2

Problem Set #1: Programming an RPN Calculator DIFFICULTY LEVEL: 2 Problem Statement: You must write a program that reads, parses, and solves RPN-styled equations. You may assume that input will come directly from a terminal s standard input (keyboard or related device) and that the output should be directed to standard output for that terminal (monitor or related device). You may implement this program using only standard library routines provided by the language that is being used; no proprietary or other such libraries are allowed. Your RPN expressions should be able to read the following operators. These operators descriptions are provided for clarity. + Addition Operator. Adds two operands together. - Subtraction Operator. Subtracts two operands together. * Multiplication Operator. Multiplies two operands. / Division Operator. Divides two operands, in the order they are placed in the stack. ~ Inverse Operator (Negative Operator). Takes the inverse of the current value in the buffer. ^ Power Operator. Multiplies value in buffer by itself by a number of times specified by the operand that follows. Each line of input will be entered in the relative form of: { numbers } { operators } Each number and operator may be assumed to be separated by some form of whitespace to make parsing the input easier. This input should be entered on an input line non-interactively; In other words, the program can NOT query the user for any EXTRA information pertaining to the contents or makeup of the expression. The only interactive element the program may use in the expression input process is a prompt to indicate the program is ready for input. A sample session is below; the program should terminate when an input contains only the letter q. If there is an error with the input, the program should state such and begin accepting the next expression. At the end of each calculation, the calculator is considered to be cleared, and the stack should be emptied. Floating point arithmetic should be assumed and programs should allow non-integer expressions as valid input. {unix: user:!}./runprog > 2 2.00 3 * + ans = 8 > 4.00 5 2 ^ - ~ + ERROR: Expression Invalid. > 4 21 3 / - ~ ans = 3 > q 3

Problem Set #2: Programming an infix Calculator w/o precedence DIFFICULTY LEVEL: 1 Problem Statement: You must write a program that reads, parses, and solves infix -styled equations. You may assume that input will come directly from a terminal s standard input (keyboard or related device) and that the output should be directed to standard output for that terminal (monitor or related device). You may implement this program using only standard library routines provided by the language that is being used; no proprietary or other such libraries are allowed. Your infix expressions should be able to read the following operators. These operators descriptions are provided for clarity. + Addition Operator. Adds two operands together. - Subtraction Operator. Subtracts two operands together. * Multiplication Operator. Multiplies two operands. / Division Operator. Divides two operands, in the order they appear. ^ Power Operator. Multiplies value in by itself by a number of times specified by the operand that follows. Each line of input will be entered in the relative form of: NUM OP NUM OP NUM Where NUM and OP represent Numbers and Operators, respectively. Each number and operator may be assumed to be separated by some form of whitespace to make parsing the input easier. This input should be entered on an input line non-interactively; In other words, the program may NOT query the user for any EXTRA information pertaining to the contents or makeup of the expression. The only interactive element the program may use in the expression input process is a prompt to indicate the program is ready for input. A sample session is below; the program should terminate when an input contains only the letter q. If there is an error with the input, the program should state such and begin accepting the next expression. At the end of each calculation, the calculator is considered to be cleared, and the memory (if any) should be emptied. This program does NOT have to consider precedence, nor contain any parenthesis. This will lead to some mathematically incorrect answers, but to keep things simple we will not be enforcing precedence. Floating point arithmetic should be assumed and programs should allow non-integer expressions as valid input. A sample session is below: {unix: user:!}./prog > 2 + 3 * 4 5 ans = 15 > 2 + 3 ^ 2 * 4 * -1 ans = -100 >q 4

Problem Set #3: Infix Calculator with simple precedence DIFFICULTY LEVEL: 3 Problem Statement: You must write a program that reads, parses, and solves infix -styled equations. You may assume that input will come directly from a terminal s standard input (keyboard or related device) and that the output should be directed to standard output for that terminal (monitor or related device). You may implement this program using only standard library routines provided by the language that is being used; no proprietary or other such libraries are allowed. Your infix expressions should be able to read the following operators. These operators descriptions are provided for clarity: ( ) Parenthesis. Used to group numbers and operators to give a simple order of precedence. Expressions contained within parentheses must be evaluated before expressions outside of parenthesis. ^ Power Operator. Multiplies value in by itself by a number of times specified by the operand that follows. * Multiplication Operator. Multiplies two operands. / Division Operator. Divides two operands, in the order they appear. + Addition Operator. Adds two operands together. - Subtraction Operator. Subtracts two operands together. Each line of input will be entered in the relative form of the following examples: > ( 2.0 + 3 ) * ( 5 * 2.0 * -1 ) ans = -50 > ( 3 + 1.0 * 2 ) ^ ( 2 + 1 ) ans = 512 > ( ( 3 + 1 ) * 2 ) ^ ( 9.0 / 3 ) ans = 512 Each number, operator, and parentheses may be assumed to be separated by some form of whitespace to make parsing the input easier. This input should be entered on an input line noninteractively; In other words, the program can NOT query the user for any EXTRA information pertaining to the contents or makeup of the expression. The only interactive element the program may use in the expression input process is a prompt to indicate the program is ready for input. A sample session is below; the program should terminate when an input contains only the letter q. If there is an error with the input, the program should state such and begin accepting the next expression. Floating point arithmetic should be assumed and programs should allow non-integer expressions as valid input. {unix: user:!}./prog > ( 2 + 3 ) * ( 4 5 ) ans = -5 > ( ( 2 + 3 ) ^ 2 * ( 4 * -1 ) ans = -100 >q 5

At the end of each calculation, the calculator is considered to be cleared. This program does NOT have to consider operator precedence, but must consider parenthesis. This may still lead to some mathematically incorrect answers, but to keep things simple we will only be enforcing parenthesis precedence. 6