Implement a recursive function evalPolish(expression) that shall evaluate (calculate) an expression written in the prefix (“Polish”) notation. The expression shall be defined recursively in the Backus-Naur form (BNF):
- expression ::= integer_or_floating_point_number # A number is an expression; its value is the number itself
- expression ::= (operator, expression, expression) # A 3-element tuple of an operator and another two expressions is also an expression; its value is the operator applied to the values of the expressions
- operator ::= “+” | “-” | “*” | “/” # The list of supported operators; feel free to extend it
Here is a sample expression and its evaluation:
>>> good = ("+", ("-", 3, 1), ("*", ("/", 3, 4), 7)) # Same as
// ~ Overview ~ //
This exercise will familiarize you with structures, dynamic memory allocation, and
// ~ Learning Goals ~ //
(1) To learn to read and write a structure into a file
(2) To learn to manipulate arrays
// ~ Submitting Your Assignment ~ //
You must submit one zip file to blackboard. This zip file must
You create the zip file using the following command.
> zip pe07.zip pe07.c bmp.c
// ~ Overview ~ //
The main purpose of this exercise is to familiarize you with
structures. It will also give you more practice with file operations
and memory allocation.
This exercise (and the next one) will gear you up for PA04, which
deals with an image format called BMP, which is commonly used in the Windows
operating system. Most web browsers are also able to read and display BMP files.
It is a modification of the exercise that Prof. Yung-Hsiang Lu gave to
In this exercise, you will read in a BMP file, and depending on the option
1.6 – The Preprocessor
All exercises in this Level must be coded exclusively in C syntax (no
<iostream>, cout, cin, classes, etc.)
Write a C-program that contains two print macro calls. The first prints the variable a, the
second prints the variables a and b. Printing happens by the use of the PRINT1 and
PRINT2 macros that accept arguments. These macros must be defined in an include-file.
The variables a and b gets their value in the function main().
Name the program “Macro.c” and the include-file “Defs.h”. Don’t forget to implement
the mechanism to avoid multiple inclusion of the header file.
Create the two macros MAX2(x,y) and MAX3(x,y,z). These macros must return the
maximum value of the given arguments. Let the macro MAX3 make use of the macro
MAX2. Add these macros to the file “Defs.h”.
1.7 – Pointers and Arrays
Try to create a function Swap(). This function must exchange the value of two variables.
For example: if i=123 and j=456, then i=456
CS 136 Assignment 10
Due Monday, April 6 at 11:59 AM sharp (noon).
Please read the preamble in Assignment 1.
Only the C language features introduced in this course are allowed.
In your code, you do NOT have to check that the value returned from malloc (or realloc) is invalid (NULL).
You may assume that all C strings are null terminated: you do not have to assert this.
If a requires statement specifies that a structure is “valid”, you may assume this, and you do not have to assert it.
Assignment 10 Problem 1. [15 Marks for correctness and efficiency.]
Write a C module mmstack.c that implements a Min/Max Stack ADT (MMStack) as described in mmstack.h.
We have provided a simple <
This semester you will be writing a program that models elements of recognizing and creating characters. Optical character recognition is an important area of research that allows photographs or printed documents to be digitized; by doing so, these documents are made available for machine-based searching. On the flip side,http://en.wikipedia.org/wiki/CAPTCHA is a system for differentiating between humans and computers: the goal here is to generate a non-machine readable image that a human could identify. CAPTCHA helps reduce the amount of spam on the Internet.
We will implement a highly limited type of image matching, processing, and creation this semester. Rather than write this project at once, we will break the proj