Monday, May 11, 2009
Answer
INPUT A
STORE A
INPUT B
STORE B
INPUT C
STORE C
LOAD A
ADD B
STORE SUM
LOAD A
SUBT C
STORE DIFF
STORE DIFF2
LOAD DIFF
SUBT ONE
SKIPCOND 100
JUMP HERE
CLEAR
STORE ANS
JUMP SHOW
HERE, LOAD SUM
STORE ANS
LOOP, LOAD DIFF
SUBT ONE
STORE DIFF
SKIPCOND 800
JUMP SHOW
LOAD ANS
ADD SUM
STORE ANS
JUMP LOOP
SHOW, LOAD A
OUTPUT
LOAD B
OUTPUT
LOAD C
OUTPUT
LOAD SUM
OUTPUT
LOAD DIFF2
OUTPUT
LOAD ANS
OUTPUT
HALT
A, DEC 0
B, DEC 0
C, DEC 0
SUM, DEC 0
DIFF, DEC 0
DIFF2, DEC 0
ONE, DEC 1
ANS, DEC 0
Thursday, March 12, 2009
Schedule for Project Presentation
10:00 - 12:00 CS2
1:00 - 3:00 IT2B
3:00 - 4:00 IT2C
*I would not entertain late comers.
Tuesday, February 17, 2009
Final Project Group Topics
Group | Project |
1 | Trees Root, Siblings, External Node, Ancestors, Descendant, Depth, Height, Degree Operations: Insert, Remove, Search, Display |
2 | Traversal - Trees PreOrder Operations: Insert, Remove, Search, Display |
3 | Traversal - Trees InOrder Operations: Insert, Remove, Search, Display |
4 | Traversal - Trees PostOrder Operations: Insert, Remove, Search, Display |
5 | Tree Application Arithmetic Expression Tree Operations: Display |
6 | Binary Tree – Number of nodes, number of external nodes, number of internal nodes, height Operations: Insert, Remove, Search, Display |
7 | Directed Graph Operations make-graph(): graph Create a new graph, initially with no nodes or edges. make-vertex(graph G, element value): vertex Create a new vertex, with the given value. make-edge(vertex u, vertex v): edge Create an edge between u and v. In a directed graph, the edge will flow from u to v. get-edges(vertex v): edge-set Returns the set of edges flowing from v get-neighbors(vertex v): vertex-set Returns the set of vertexes connected to v |
8 | Undirected Graph Operations make-graph(): graph Create a new graph, initially with no nodes or edges. make-vertex(graph G, element value): vertex Create a new vertex, with the given value. make-edge(vertex u, vertex v): edge Create an edge between u and v. In a directed graph, the edge will flow from u to v. get-edges(vertex v): edge-set Returns the set of edges flowing from v get-neighbors(vertex v): vertex-set Returns the set of vertexes connected to v |
9 | Weighted Graph Operations (an extension of undirected/directed graph operations) make-edge(vertex u, vertex v, weight w): edge Create an edge between u and v with weight w. In a directed graph, the edge will flow from u to v. |
10 | Graph Traversal Depth – First Traversal |
11 | Graph Traversal Breadth-First Search |
12 | Weighted graphs: Dijkstra’s algorithm |
13 | Travelling Salesman Problem |
Friday, February 13, 2009
Reporting Update
IT2A - Thursday/February 19, 2009
IT2B - Thursday/February 19, 2009
IT2C - Wednesday/February 18, 2009
CS2 - Friday/February 20, 2009
The presentation of your topics will start according to the date specified above for your respective classes.
Saturday, January 31, 2009
Lab Exam
Saturday, January 24, 2009
Stack and Queue
Monday, January 12, 2009
Top Students for Prelim
2. PAASA, PATRICK ANGELO P. (BSIT2C) 93
3. LASAY, NORRIS LEMUEL C. (BSCS2) 90
4. ZABATE, MARVIN JOHN B. (BSCS2) 88
5. LUI, ADRIAN E.(BSCS2) 88
6. JAMIO, PAUL JOHN I. (BSIT2B) 88
7. MEDILLO, DARWIN I. (BSIT2A) 88
8. REANCHO, LIRALYN S.(BSIT2A) 88
9. AMARANTO, MAYLYN T. (BSIT2C) 88
10. BERNARDINO, JAMES CARL H. (BSIT2C) 88
11. CARILLO, RAFFY D. (BSCS2) 88
Saturday, January 3, 2009
Templates
Function templates are special functions that can operate with generic types. This allows us to create a function template whose functionality can be adapted to more than one type or class without repeating the entire code for each type.
In C++ this can be achieved using template parameters. A template parameter is a special kind of parameter that can be used to pass a type as argument: just like regular function parameters can be used to pass values to a function, template parameters allow to pass also types to a function. These function templates can use these parameters as if they were any other regular type.
The format for declaring function templates with type parameters is:
template
template
The only difference between both prototypes is the use of either the keyword class or the keyword typename. Its use is indistinct, since both expressions have exactly the same meaning and behave exactly the same way.
For example, to create a template function that returns the greater one of two objects we could use:
template <class myType>
myType GetMax (myType a, myType b) {
return (a>b?a:b);
}
Example
// function template
#include
using namespace std;
template <class T>
T GetMax (T a, T b) {
T result;
result = (a>b)? a : b;
return (result);
}
int main () {
int i=5, j=6, k;
long l=10, m=5, n;
k=GetMax<int>(i,j);
n=GetMax<long>(l,m);
cout <<>return 0;
}
Class templates
We also have the possibility to write class templates, so that a class can have members that use template parameters as types. For example:
template <class T>
class mypair {
T values [2];
public:
mypair (T first, T second)
{
values[0]=first; values[1]=second;
}
};
Example:
// class templates
#include
using namespace std;
template <class T>
class mypair {
T a, b;
public:
mypair (T first, T second)
{a=first; b=second;}
T getmax ();
};
template <class T>
T mypair::getmax ()
{
T retval;
retval = a>b? a : b;
return retval;
}
int main () {
mypair <int> myobject (100, 75);
cout <<>return 0;
}
Template Specialization
// template specializationObserve the results of the codes above. A short quiz will be given about this during lecture.
#include
using namespace std;
// class template:
template <class T>
class mycontainer {
T element;
public:
mycontainer (T arg) {element=arg;}
T increase () {return ++element;}
};
// class template specialization:
template <>
class mycontainer <char> {
char element;
public:
mycontainer (char arg) {element=arg;}
char uppercase ()
{
if ((element>='a')&&(element<='z'))
element+='A'-'a';
return element;
}
};
int main () {
mycontainer<int> myint (7);
mycontainer<char> mychar ('j');
cout <<>return 0;
}