Wednesday, November 16, 2011

Pathfinder


This is Assignment #6 of Stanford's CS106B class last Spring Quarter 2011.

This is an assignment on graphs. It includes an implementation of Dijkstra's shortest path algorithm and of Kruskal's minimum spanning tree algorithm.

Here is a screen-shot of the minimum spanning tree of the graph data in the file "USA.txt" (included in the project).


You can play with this app by downloading the .exe file along with the other files here.

You can download the source files here.

You can download my code here.

You can download my code here.

You can download the problem specification here here.

Have fun!!!


Monday, November 7, 2011

Some Quotes from "The Magic of Thinking Big"


When I believe I can do it,
the how to do it develops.

A person is a product of his own thoughts.

How to develop the power of belief:
1. Think Success, don't think failure
2. Remind yourself that you are better than you think you are
3. Believe big

The more successful an individual the less inclined he is to make excuses

The right attitude and one arm will beat the wrong attitude and two arms every time

What you can do to lick health excusitis:
1. Refuse to talk about your health
2. Refuse to worry about your health
3. Be genuinely grateful that your health is as good as it is
4. Remind yourself often, "It is better to wear out than to rust out."

The thinking that guides your intelligence is much more important than how much intelligence you have.

Stick with one thing until it's over.

Stickability is 95% ability.
You must like everybody: your subjects, proffessors, fellow students, etc.
Gain respect by cooperating

Knowledge is only potential power.
Knowledge is power only when put to use
--and then only when the use made of it is constructive.
It is more important to use your mind to think than to use it as a warehouse of facts.
The ability to knot how to get information is more important than using the mind as a garage for facts.
Be a person who can solve problems and can think up ideas.
A fact man cannot make up money.

To Cure Intelligence Excusitis:

1. Never underestimate your intelligence and
never overestimate the intelligence of others.

--It's not how many brains you've got;
but how you use your brain that counts.

--Mange your brains instead of worrying
about how much IQ you've got.

2. Remind yourself -
"My attitudes
are more important than my intelligence."

3. The ability to think is of greater value
than the ability to memorize facts.
Conquer luck excusitis:
1. Accept the law of cause and effect.
2. Don't be a wishful thinker.
Build confidence and destroy fear:
All confidence is acquired, developed.
Action cures fear.
Indecision, postponement fertilize fear.
Hope is start. But hope needs action to win victories.
Deposit only positive thoughts in your memory bank.
Withdraw only positive thoughts from your memory bank.
It is easy to forget the unpleasant if we simply refuse to recall it.
2 ways to put people in proper perspective:
1. Get a balanced view of the other fellow-- both of you are important and have desires, problems,...
2. develop an understanding attitude.
Doing what's right keeps your conscience satisfied. And this builds confidence.
To think confidently, act confidently.
You can't act devoted for too long without feeling devoted.
We can change our attitudes by changing our physical actions.
Confident action produces confident thinking.
Confidence-building exercises:
1. Be a front seater.
2. Practice making eye-contact.
3. Walk 23% faster.
4. Practice speaking up.
5. Smile big.
To think big we must use words and phrases which produce big, positive mental images.
"Practice adding value" exercises:
1. Practice adding value to things.
2. Practice adding value to people.
3. Practice adding value to yourself.
A good speaker has knowledge of what he's going to talk about and an intense desire to tell it to other people.
To eliminate quarrels, eliminate petty thinking. before complaining..ask first,"Is it really important?"
Ways to develop and strengthen our creative thinking ability:
1. Believe it can be done.
When you believe, your mind find ways to do.
Where there is a will, there is a way.
Capacity is a state of mind. How much we can do depends on how much we think we can do.
The success combination is do what you do better (improve the quality of your output) and do more of what you do (increase the quantity of your output).
The fellow who has plenty of time makes an ineffective work partner.
The bigger the person, the more apt he is to encourage you to talk; the smaller the person, the more apt he is to preach to you.
Big people monopolize the listening. Small people monopolize the talking.
In reaching creative decisions, the raw materials are the ideas or suggestions of others.
Test your own views in the form of questions--what do you think of this suggestion?...
Ideas are fruits of your thinking. But they got to be harnessed and put to work to have value.
Harness and develop your ideas:
1. Don't let ideas escape.
2. Next, review your ideas.
3. Cultivate and fertilize your ideas.
Thinking regulates actions.
Your actions are controlled by your thoughts.
How you think determines how you act.
How you act in turn determines how others react to you.
Your appearance talks.
Look important because it helps you think important.
Look your best and you will think and act your best.
Pay twice as much and buy half as many.
The key to winning what you want lies in thinking positively toward yourself.
A person who thinks his job is important receives mental signals on hoe to do his job better. And a better job means more promotions, more money, more prestige, more happiness.
The way we think towards our job determines how our subordinates think toward their jobs.
Practice uplifting self-praise. Sell yourself to yourself.
Think like important people think.
Respect yourself.
Is this the way an important person does it? Use this question to make you a bigger, more successful person.
Mind food is your environment--all the countless things that influence your conscious and subconscious mind.
The kind of mind food we consume determines our habits, attitudes, and personalities.
You are a product of your own environment.
Companionship with people with big ideas raises the level of our thinking; close contact with ambitious people gives us ambition.
What we should do to make our future environment pay off in satisfaction and prosperity:
Step 1. Recondition yourself for success.
Step 2. Never surrender.
People who tell you it cannot be done almost always are unsuccessful people, are strictly average or mediocre at best in terms of accomplishments. Opinions of these people can be poison.
Don't let negative thinking people - "negators" - destroy your plan to think yourself to success.
Study negators. Be extra careful.
Be careful about your source of advice.
Make it a rule toa seek advice from people who know.
Go first class in everything you do. You can't afford to go any other way.
How we think shows through in how we act. Attitudes are mirror of the mind.
When our attitude is right, our abilities reach a maximum of effectiveness and good results inevitably follow.
Make these 3 attitudes you allies:
1. Grow the attitude of I'm activated.
2. Grow the attitude of You are important.
3. Grow the attitude of Service first.
Enthusiasm can make things 1100% better.
Develop the power of enthusiasm:
1. Dig into it deeper (and you dig up interest).
2. In everything you do, life it up -- "I feel great today!"
3. Broadcast good news.
How we feel is in large part determined by how we think we feel.
Give me a good word or none at all.
Give them a good word or none at all.
The desire to be important is man's strongest, most compelling non-biological hunger.
People do more for you when you make them feel important.
It pays to make little people feel like big people.
When you hwlp other people feel important, you help yourself fee important too.
You must feel important to succeed.
1. Practice appreciation.
2. Practice calling people by thier names.
3. Don't hug glory. Invest it instead.
Praise is power.
Get the family on your team. Give them planned attention.
You cannot harvest money unless you plant the seeds that grow money.
The seed of money is service.
"Put-service-first" is an attitude which creates wealth.
Put service first and money takes care of itself - always.
Think right toward people and they will like and support you.
Success depends on the support of other people.
In at least 9 out of 10 cases, the "likeability" factor is the 1st thing mentioned. And in an overwhelmingly large number of cases, the "likeability" factor is given far more weight than the technical factor.
Every friend you make lifts you just one notch higher. And being likeable makes you lighter to lift.

Some Cryptic ERROR Messages of the Visual Studio 2008 C++ Compiler


Error    1    error LNK2019: unresolved external symbol "void __cdecl ReadData(class PathfinderGraph,class std::basic_string,class std::allocator >)" (?ReadData@@YAXVPathfinderGraph@@V?$basic_string@DU?$char_traits@D@std@@V?$allocator@D@2@@std@@@Z) referenced in function "int __cdecl Main(void)" (?Main@@YAHXZ)    pathfinder.obj    assn-6-pathfinder-pc

Cause: The function prototype is not the same as the function implementation.

Example:

/* function prototype */
void ReadData(PathfinderGraph & graph, string filename);

/* function implementation*/
void ReadData(PathfinderGraph graph, string filename)
{




notice the & in the function prototype.

Tuesday, November 1, 2011

Minimal BASIC


I am finished coding Minimal Basic - Assignment #3 of Stanford's CS106B class last Spring Quarter 2011.

You can download the problem specification here here.



I think the most significant part of this assignment is finding the right data structure to use in the Program class.

I thought of using the BST introduced in Chapter 13 of the Course Reader. But it might cause me a lot of trouble (a lot of code to debug).


So I choose to use the map data structure of the C++ STL.


You can download my code here.

You can download a stand-alone executable here.

You can download my code here.

You can download my code here.


Happy coding.