Prelim exam will be on July 31, 2011. 3:00PM-5:00PM. Sunday.
The coverage for the exam will be the following:
- Stack and Queues
- plus Inheritance
- plus Polymoprhism
Note:
Bring your own yellow paper, books, slides and other form of notes. No borrowing of resources.
If you have some questions, do not hesitate to ask me.
This is an elementary course on algorithms and data structures. These include: (1) Overview of OOP concepts; (2) Basic data structures, such as arrays, tables, stacks, queues, trees, and graphs; (3) Abstract data types; (4) Complexity analysis using the big Oh notation; (5) Practical problem-solving strategies, with large case studies.
Wednesday, July 20, 2011
Final Project - Interactive Expression Evaluator
To all sections:
[Download Project Case Study]
Your partner for the final project is the same with your partner I assigned to you. See your partner.
Your final project is to complete the Interactive Expression Evaluator. Complete the missing functions and methods and implement the graphing program.
On the day of submission bring the following:
1. Laptop
2. Hard-copy of your source code
3. Presentation of your project (PowerPoint)
Requirements of the defense:
-Working solution.
-Original source code.
The project presentation/defense will be held one week before the final exam.
[Download Project Case Study]
Your partner for the final project is the same with your partner I assigned to you. See your partner.
Your final project is to complete the Interactive Expression Evaluator. Complete the missing functions and methods and implement the graphing program.
On the day of submission bring the following:
1. Laptop
2. Hard-copy of your source code
3. Presentation of your project (PowerPoint)
Requirements of the defense:
-Working solution.
-Original source code.
The project presentation/defense will be held one week before the final exam.
Take Home Prelim Exam
To all sections:
-Take home prelim problem exercise with a follow up defense next week (July 26, 27).
-This will serves as 40% of your prelim grade.
-Grading will be based on your answers and the correctness of your solution.
-A group of two.
On the day of submission bring the following:
1. Laptop
2. Hard-copy of your source code
Requirements of the defense:
-Working solution.
-Original source code.
PROBLEM:
Parsing Arithmetic Expressions
This problem involves the usage of Stack and Queue.
This application is parsing (that is, analyzing) arithmetic expressions like 2+3 or 2*(3+4) or ((2+4)*7)+3*(9–5), and the storage structure it uses is the stack.
It's easier for the algorithm to use a two-step process:
1. Transform the arithmetic expression into a different format, called postfix notation.
2. Evaluate the postfix expression.
Step 1 is a bit involved, but step 2 is easy. In any case, this two-step approach results in a simpler algorithm than trying to parse the arithmetic expression directly.
-----
Groupings
Agal:
ABREU, Chester Duane G.
AMANTIAD, Jan Rhais L.
Cacs:
CABILI, SHERWIN A.
CANO, Rommel John S.
Depo:
DUMORAN, Gel Dante E.
PAYLAGA, Jon Paolo J.
Saac:
SUDARIA, CYRUS ALLAN C.
AMBOLODE, Von Michael C.
Agam:
ANDAYA, Princess Cecile G.
Araña, Dale Brian M.
Acea:
ARCAMO, Anthea Izza C.
ECHAVEZ, Marie Beth A.
Esen:
EDAROS, NAIDA S.
FABRICANTE, Zarah Mae N.
Lemo:
LEOPOLDO, June Karl P.
MERCADO, Nel Ian O.
Mopa:
MODEQUILLO, Charles Mathius M.
PONCE, April Rose A.
Resad:
RABE, ANGELA PEARL E.
SALOMSON, Ederlina D.
Sate:
SY, Chrissan G.
TAMSE, Lady Jane G.
Usel:
UMPA, Al-Mohajerani S.
ENRIQUEZ, John Daniel
Asal:
ADRAQUE, Honey Grace S.
APAL, Joren Ezra L.
Bocas:
BONCALES, Ergelie L.
CANOY, Juñel S.
Jeam:
JERUSALEM, JAYSON A.
MALALES, Vincent Q.
Miquiem:
MILA, VERCILLIUS JR. A.
Quiamco, Thor Wendel M.
Sebs:
SERATE, Silver Gems B.
SUMINGUIT, Dexter Lyn M.
Tab:
TALABA, Mark Sunday C.
APAS, CARLO JOEL B.
Baba:
BAGUIO, Kristopher Joseph C.
BASHER, HANAN T.
-Take home prelim problem exercise with a follow up defense next week (July 26, 27).
-This will serves as 40% of your prelim grade.
-Grading will be based on your answers and the correctness of your solution.
-A group of two.
On the day of submission bring the following:
1. Laptop
2. Hard-copy of your source code
Requirements of the defense:
-Working solution.
-Original source code.
PROBLEM:
Parsing Arithmetic Expressions
This problem involves the usage of Stack and Queue.
This application is parsing (that is, analyzing) arithmetic expressions like 2+3 or 2*(3+4) or ((2+4)*7)+3*(9–5), and the storage structure it uses is the stack.
It's easier for the algorithm to use a two-step process:
1. Transform the arithmetic expression into a different format, called postfix notation.
2. Evaluate the postfix expression.
Step 1 is a bit involved, but step 2 is easy. In any case, this two-step approach results in a simpler algorithm than trying to parse the arithmetic expression directly.
-----
Groupings
Agal:
ABREU, Chester Duane G.
AMANTIAD, Jan Rhais L.
Cacs:
CABILI, SHERWIN A.
CANO, Rommel John S.
Depo:
DUMORAN, Gel Dante E.
PAYLAGA, Jon Paolo J.
Saac:
SUDARIA, CYRUS ALLAN C.
AMBOLODE, Von Michael C.
Agam:
ANDAYA, Princess Cecile G.
Araña, Dale Brian M.
Acea:
ARCAMO, Anthea Izza C.
ECHAVEZ, Marie Beth A.
Esen:
EDAROS, NAIDA S.
FABRICANTE, Zarah Mae N.
Lemo:
LEOPOLDO, June Karl P.
MERCADO, Nel Ian O.
Mopa:
MODEQUILLO, Charles Mathius M.
PONCE, April Rose A.
Resad:
RABE, ANGELA PEARL E.
SALOMSON, Ederlina D.
Sate:
SY, Chrissan G.
TAMSE, Lady Jane G.
Usel:
UMPA, Al-Mohajerani S.
ENRIQUEZ, John Daniel
Asal:
ADRAQUE, Honey Grace S.
APAL, Joren Ezra L.
Bocas:
BONCALES, Ergelie L.
CANOY, Juñel S.
Jeam:
JERUSALEM, JAYSON A.
MALALES, Vincent Q.
Miquiem:
MILA, VERCILLIUS JR. A.
Quiamco, Thor Wendel M.
Sebs:
SERATE, Silver Gems B.
SUMINGUIT, Dexter Lyn M.
Tab:
TALABA, Mark Sunday C.
APAS, CARLO JOEL B.
Baba:
BAGUIO, Kristopher Joseph C.
BASHER, HANAN T.
Saturday, July 16, 2011
Assignment: Stack & Project Proposal
Download the slide.
Study the Stack class.
Experiment the applications of stack that were presented in the class.
Submit a written report that also includes your output (printscreen of the window) next meeting.
Research what are the other applications that also uses stack.
Submit a project proposal next meeting. Please refer to your syllabus that can be also downloaded in the site.
Study the Stack class.
Experiment the applications of stack that were presented in the class.
Submit a written report that also includes your output (printscreen of the window) next meeting.
Research what are the other applications that also uses stack.
Submit a project proposal next meeting. Please refer to your syllabus that can be also downloaded in the site.
Thursday, July 7, 2011
Laboratory II: Graphics System
Note: This machine problem needs an understanding of inheritance and polymorphism. For a clearer problem definition please refer to page 659 of the book given by Mr. Sy in our Facebook group.
Deadline: Thursday, July, 14, 2011. NO EXTENSION. NO WORK IN THE LAB, NO SCORE (0).
1. Consider a graphics system that has classes for various figures, say rectangles, squares, triangles, circles, and so on. For example, a rectangle might have data members height, width, and center point, while a square and circle might have only a center point and an edge length or radius, respectively. In a well-designed system these would be derived from a common class, Figure. You are to implement such a system. The class Figure is the base class. You should add only Rectangle and Triangle classes derived from Figure. Each class has stubs for member functions erase and draw. Each of these member functions outputs a message telling what function has been called and what the class of the calling object is. Since these are just stubs, they do nothing more than output this message. The member function center calls erase and draw to erase and redraw the figure at the center. Because you have only stubs for erase and draw, center will not do any “centering” but will call the member functions erase and draw. Also, add an output message in the member function center that announces that center is being called. The member functions should take no arguments. There are three parts to this project:
a. Do the class definitions using no virtual functions. Compile and test.
b. Make the base class member functions virtual. Compile and test.
c. Explain the difference in results.
For a real example, you would have to replace the definition of each of these member functions with code to do the actual drawing. You will be asked to do this in Programming Project 2.
Use the following main function for all testing:
//This program tests Programming Problem 1.
#include <iostream>
#include "figure.h"
#include "rectangle.h"
#include "triangle.h"
using std::cout;
int main( )
{
Triangle tri;
tri.draw( );
cout <<
"\nDerived class Triangle object calling center( ).\n";
tri.center( ); //Calls draw and center
Rectangle rect;
rect.draw( );
cout <<
"\nDerived class Rectangle object calling center().\n";
rect.center( ); //Calls draw and center
return 0;
}
2. Flesh out Programming Problem 1. Give new definitions for the various constructors and
member functions Figure::center, Figure::draw, Figure::erase, Triangle::draw, Triangle::erase, Rectangle::draw and Rectangle::erase so that the draw functions actually draw figures on the screen by placing the character ’*’ at suitable locations on the screen. For the erase functions, you can simply clear the screen (by outputting
blank lines or by doing something more sophisticated). There are a lot of details in this and
you will have to decide on some of them on your own.
Deadline: Thursday, July, 14, 2011. NO EXTENSION. NO WORK IN THE LAB, NO SCORE (0).
1. Consider a graphics system that has classes for various figures, say rectangles, squares, triangles, circles, and so on. For example, a rectangle might have data members height, width, and center point, while a square and circle might have only a center point and an edge length or radius, respectively. In a well-designed system these would be derived from a common class, Figure. You are to implement such a system. The class Figure is the base class. You should add only Rectangle and Triangle classes derived from Figure. Each class has stubs for member functions erase and draw. Each of these member functions outputs a message telling what function has been called and what the class of the calling object is. Since these are just stubs, they do nothing more than output this message. The member function center calls erase and draw to erase and redraw the figure at the center. Because you have only stubs for erase and draw, center will not do any “centering” but will call the member functions erase and draw. Also, add an output message in the member function center that announces that center is being called. The member functions should take no arguments. There are three parts to this project:
a. Do the class definitions using no virtual functions. Compile and test.
b. Make the base class member functions virtual. Compile and test.
c. Explain the difference in results.
For a real example, you would have to replace the definition of each of these member functions with code to do the actual drawing. You will be asked to do this in Programming Project 2.
Use the following main function for all testing:
//This program tests Programming Problem 1.
#include <iostream>
#include "figure.h"
#include "rectangle.h"
#include "triangle.h"
using std::cout;
int main( )
{
Triangle tri;
tri.draw( );
cout <<
"\nDerived class Triangle object calling center( ).\n";
tri.center( ); //Calls draw and center
Rectangle rect;
rect.draw( );
cout <<
"\nDerived class Rectangle object calling center().\n";
rect.center( ); //Calls draw and center
return 0;
}
2. Flesh out Programming Problem 1. Give new definitions for the various constructors and
member functions Figure::center, Figure::draw, Figure::erase, Triangle::draw, Triangle::erase, Rectangle::draw and Rectangle::erase so that the draw functions actually draw figures on the screen by placing the character ’*’ at suitable locations on the screen. For the erase functions, you can simply clear the screen (by outputting
blank lines or by doing something more sophisticated). There are a lot of details in this and
you will have to decide on some of them on your own.
Thursday, June 30, 2011
Tuesday, June 28, 2011
First Long Quiz on OOP Concepts Using C++
Dear Class, we will have a very long quiz next week on Object-oriented Concepts using C++.
Section DS1: July 5, 2011
Section C2S/C2S.1: July 6, 2011
First Part: Closed Notes
Second Part: Open Book
Study from the very beginning...
Section DS1: July 5, 2011
Section C2S/C2S.1: July 6, 2011
First Part: Closed Notes
Second Part: Open Book
Study from the very beginning...
Thursday, June 23, 2011
Guidelines for Laboratory 1: LogBook Abstract Data Type (ADT)
Note: This is only for my laboratory class.
Download the manual for Laboratory 1: LogBook ADT.
Laboratory 1 will be done with at most 3 members. Prepare a one-page report by submitting your work. You will be handing (1) a one-page report of your work, (2) the printed COVER SHEET found in your laboratory manual, and (3) the SOURCE CODE. Fill up the cover sheet of the name of the members that was assigned to them and the status of their work. As usual, NO COPYING since every member is given a certain task. The deadline for this will be on Friday, July 1, 2011, 3PM.
NO LATE SUBMISSION WILL BE ACCEPTED.
Download the manual for Laboratory 1: LogBook ADT.
Laboratory 1 will be done with at most 3 members. Prepare a one-page report by submitting your work. You will be handing (1) a one-page report of your work, (2) the printed COVER SHEET found in your laboratory manual, and (3) the SOURCE CODE. Fill up the cover sheet of the name of the members that was assigned to them and the status of their work. As usual, NO COPYING since every member is given a certain task. The deadline for this will be on Friday, July 1, 2011, 3PM.
NO LATE SUBMISSION WILL BE ACCEPTED.
Fraction Example
Here is an example of the partial Fraction ADT. Unzip MyFraction.zip and open it in Code::Blocks.
This assignment will be done in pairs. Just look for your partner and prepare a one-page report. No duplicate work. Deadline for this homework will be on Monday, June 27, 2011, 3PM. See me in my office or leave it on my table.
NO LATE SUBMISSION WILL BE ACCEPTED.
This assignment will be done in pairs. Just look for your partner and prepare a one-page report. No duplicate work. Deadline for this homework will be on Monday, June 27, 2011, 3PM. See me in my office or leave it on my table.
NO LATE SUBMISSION WILL BE ACCEPTED.
Saturday, June 18, 2011
Thursday, June 16, 2011
C++ Additional Materials
Here are some C++ materials that you can refer:
Wednesday, June 15, 2011
Announcement: C2S, C2S.1
To all students (Sections C2S and C2S.1):
I would like to inform everybody that our classes every WF 1:30-3:00PM will be moved to WF 1:00-2:30PM. Please come ON TIME.
Please inform me if you have problem with the new schedule. You can add our Facebook account.
Cyrus Gabilla / CSc 121 INSTRUCTOR
I would like to inform everybody that our classes every WF 1:30-3:00PM will be moved to WF 1:00-2:30PM. Please come ON TIME.
Please inform me if you have problem with the new schedule. You can add our Facebook account.
Cyrus Gabilla / CSc 121 INSTRUCTOR
Announcement: Class Facebook
I would like to inform everybody that the class has a Facebook account. We could use Facebook to raise questions and other matter regarding about the course. Please add if you are interested.
Click HERE to visit the group.
Click HERE to visit the group.
Monday, June 13, 2011
Lecture 2/Reading Assignment: OOP in C++
As a part of the course, you must read the following materials in order to fully understand the concept of the object-oriented programming. Every details in OOP will not be discussed in the class.
2. Introduction to OOP Concepts II (pdf)
3. Introduction to OOP Concepts II (pdf)
4. Introduction to OOP Concepts IV (OpenOffice file/sxi)
Download Foxit Reader to view a .pdf file format and OpenOffice to open a .sxi file format.
Download Foxit Reader to view a .pdf file format and OpenOffice to open a .sxi file format.
Sunday, June 12, 2011
Homework 3: OOP in C++ (100 points)
1. Write a class Fraction which defines adding, subtracting, multiplying, and dividing fractions by overloading standard operators for these operations. Write a function member for reducing factors and overload I/O operators to input and output fractions.
2. Write a driver program to test your class.
----
A fraction number is the ratio of two integers and is typically represented in the manner a/b. The basic arithmetic operations have the following definitions:
Refer to this link on how to operate on fractions.
Reducing a fraction involves finding the Greatest Common Divisor, and then dividing all the terms by that amount.
Euclid’s Algorithm:
if x < y, then swap x and y
While y is not zero
remainder = x mod y
x = y
y = remainder
When you’re done, x is the GCD.
----
----
A fraction number is the ratio of two integers and is typically represented in the manner a/b. The basic arithmetic operations have the following definitions:
Refer to this link on how to operate on fractions.
Reducing a fraction involves finding the Greatest Common Divisor, and then dividing all the terms by that amount.
Euclid’s Algorithm:
if x < y, then swap x and y
While y is not zero
remainder = x mod y
x = y
y = remainder
When you’re done, x is the GCD.
----
//In fraction.h
class Fraction {
public: // member functions
// default constructor
Fraction();
// a second constructor
Fraction(int number, int denom=1);
// destructor
~Fraction();
// copy constructor
Fraction(const Fraction &r);
// member assignment
Fraction& operator=(const Fraction &r);
// can it be: void operator=(const Fraction &r); ?????
// some arithmetic and stream facilitators
Fraction Add(const Fraction &r) const;
Fraction Sub(const Fraction &r) const;
Fraction Multiply(const Fraction &r) const;
Fraction Divide(const Fraction &r) const;
void Insert(ostream &sout) const;
void Extract(istream &sin);
protected:
// inspectors
int GetNumerator() const;
int GetDenominator() const;
// mutators
void SetNumerator(int numer);
void SetDenominator(int denom);
private:
// data members
int NumeratorValue;
int DenominatorValue;
};
// Fraction ADT: auxiliary operator description
Fraction operator+(const Fraction &r, const Fraction &s);
Fraction operator-(const Fraction &r, const Fraction &s);
Fraction operator*(const Fraction &r, const Fraction &s);
Fraction operator/(const Fraction &r, const Fraction &s);
ostream& operator<<(ostream &sout, const Fraction &s);
istream& operator>>(istream &sin, Fraction &r);// can they be: void operator<<(ostream &sout, const Fraction &); ?????
//In fraction.cpp
<insert your answer here...>
//In driver_program.cpp
...
int main() {
Fraction r;
Fraction s;
cout << "Enter 1st rational number (a/b): ";
cin >> r;
cout << "Enter 2nd rational number (a/b): ";
cin >> s;
Fraction tr(r);
Fraction ts = s;
Fraction tts;
tts = s;
ts = tts = r;
Fraction Sum = r + s;
Fraction Difference = r - s;
Fraction Product = r * s;
Fraction Ratio = r / s;
cout << r << " + " << s << " = " << Sum << endl;
cout << r << " - " << s << " = " << Difference << endl;
cout << r << " * " << s << " = " << Product << endl;
cout << r << " / " << s << " = " << Ratio << endl;
return 0;
}
Friday, June 10, 2011
Homework 2: The Game of Life in C++ (100 points)
Complete the code snippets of "The Game of Life" found in the Lecture 1 transparency.
To run the c++ source codes, download the Code::Blocks Integrated Development Environment (IDE).
Submit the working code in C++. Include sample configurations and generations at most the level of 5.
Printed source code and a sample output in a short bond paper, courier new, 10 points, will only be accepted.
Tuesday, June 7, 2011
Homework 1: The Game of Life (100 points)
Rules for the Game of Life
Life is really a simulation, not a game with players. It takes place on an unbounded
rectangular grid in which each cell can either be occupied by an organism or not.
Occupied cells are called alive; unoccupied cells are called dead. Which cells are
alive changes from generation to generation according to the number of neighbor-
ing cells that are alive, as follows:
1. The neighbors of a given cell are the eight cells that touch it vertically, horizontally or diagonally.
2. If a cell is alive but either has no neighboring cells alive or only one alive, then
in the next generation the cell dies of loneliness.
3. If a cell is alive and has four or more neighboring cells also alive, then in the
next generation the cell dies of overcrowding.
4. A living cell with either two or three living neighbors remains alive in the next
generation.
5. If a cell is dead, then in the next generation it will become alive if it has exactly
three neighboring cells, no more or fewer, that are already alive. All other dead
cells remain dead in the next generation.
6. All births and deaths take place at exactly the same time, so that dying cells
can help to give birth to another, but cannot prevent the death of others by
reducing overcrowding; nor can cells being born either preserve or kill cells
living in the previous generation.
A particular arrangement of living and dead cells in a grid is called a configuration.
The preceding rules explain how one configuration changes to another at each
generation.
rectangular grid in which each cell can either be occupied by an organism or not.
Occupied cells are called alive; unoccupied cells are called dead. Which cells are
alive changes from generation to generation according to the number of neighbor-
ing cells that are alive, as follows:
1. The neighbors of a given cell are the eight cells that touch it vertically, horizontally or diagonally.
2. If a cell is alive but either has no neighboring cells alive or only one alive, then
in the next generation the cell dies of loneliness.
3. If a cell is alive and has four or more neighboring cells also alive, then in the
next generation the cell dies of overcrowding.
4. A living cell with either two or three living neighbors remains alive in the next
generation.
5. If a cell is dead, then in the next generation it will become alive if it has exactly
three neighboring cells, no more or fewer, that are already alive. All other dead
cells remain dead in the next generation.
6. All births and deaths take place at exactly the same time, so that dying cells
can help to give birth to another, but cannot prevent the death of others by
reducing overcrowding; nor can cells being born either preserve or kill cells
living in the previous generation.
A particular arrangement of living and dead cells in a grid is called a configuration.
The preceding rules explain how one configuration changes to another at each
generation.
Implement the "The Game of Life" in your programming language of choice.
Please try the following simple life configurations:
Please try the following simple life configurations:
Sunday, June 5, 2011
Class Schedule
- CSC 121- CS C2S
01:30PM-03:00PM, WF
SCS-LR1
- CSC 121- CS C2S.1 (LAB)
04:30PM-07:30PM, Th
IDS-DVT-CNTR
Subscribe to:
Posts (Atom)
