Showing posts with label Stanford - CS106B. Show all posts
Showing posts with label Stanford - CS106B. Show all posts

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!!!


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.


Monday, October 31, 2011

CS106B - Free Course from Stanford


CS106B is a free course from Stanford available online. This course is about data structures and recursion.

The latest free video lectures are made last 2011 Spring Quarter and you can access them at ClassX - CS106B: Programming Abstractions. The professor during this quarter is Steve Cooper. You can visit the CS106B's website in this quarter here. All lecture handouts, codes, the course reader, assignments and many other materials for the course are available in the website.

An older set of video lectures are available at SEE (Stanford Engineering Everywhere) - Programming Abstractions. Go to the bottom part of the web page to download the complete course materials.

If you are planning to do the assignments and compile the example codes during the lectures you'll need Visual Studio 2005 and the CS106 Library. If you have Visual Studio 2008 instead, please read Dani's article on how you can make the CS106B Library work with Visual Studio 2008.

Enjoy!

I have done some of the assignments last 2011 Spring Quarter. You can view my solutions here. Please pardon my code because they are not well structured and not commented. Thanks.



  
Free Lessons for Chruch Pianists:
Free lessons, tips and downloads for church pianists

DVD Courses (Reharmonization, Play by Ear!, Arranging, Accompanying, Theory for Church Pianists, etc.):
Over 30 hours of DVD instruction for church pianists
 


Visit Vitabase for Quality Health Supplements


Friday, September 2, 2011

Recursion


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

It consists of four problems and 2 warm-up problems.
(I only did 3 of the 4 problems because the last one was fairly difficult). Click here here to download the assignment handout.

The link for downloads below might not work. Please use this link to download all solutions to the problems.

Warm-up problem 0a. Binary encoding
Write a recursive function GenerateBinaryCode(nBits) that generates the bit patterns
for the standard binary representation of all integers that can be represented using the
specified number of bits. For example, calling GenerateBinaryCode(3) should produce
the following output:
000
001
010
011
100
101
110
111
Download my solution for Warm-up problem 0a here.
Warm-up problem 0b. Subset sum
The subset sum problem is an important and classic problem in computer theory. Given  a set of integers and a target number, your goal is to find a subset of those numbers that sum to that target number. For example, given the numbers {3, 7, 1, 8, -3} and the target sum 4, the subset {3, 1} sums to 4. On the other hand, if the target value were 2, the result is false since there is no subset that sums to 2.
 Download my solution for Warm-up problem 0b here.
Problem 1. Karel goes home
Your job in this problem is to write a recursive function
int CountPaths(int street, int avenue)
that returns the number of paths Karel could take back to the origin from the specified starting position, subject to the condition that Karel doesn’t want to take any  unnecessary steps and can therefore only move west or south (left or down in the diagram).
 Download my solution for problem 1 here.
 Problem 2. Balancing parentheses
Write a function
bool IsBalanced(string exp);
that takes a string consisting only of parentheses, brackets, and curly braces and returns true or false according to whether that expression has properly balanced operators. (Your function should operate recursively.)
Download my solution for problem 2  here.

Problem 3. Cell phone mind-reading
Write a function
void ListCompletions(string digits, Lexicon & lex);
that prints all words from the lexicon that can be formed by extending the given digit sequence. For example, calling ListCompletions("72547", english) should generate the following sample run:
palisade
palisaded
palisades
palisading
palish
rakis
rakish
rakishly
rakishness
sakis

 Download my solution for problem 3  here.

Problem 4. Stock Cutting
You are charged with buying the plumbing pipes for a construction project. Your
foreman gives you a list of the varying lengths of pipe needed. Home Depot sells stock
pipe in one fixed length. You can divide each stock pipe in any way needed. Your job is
to figure out the minimum number of stock pipes required to satisfy the list of requests,
thereby saving money and minimizing waste.

Your job is to write a recursive function

int CutStock(Vector<int> & requests, int stockLength);

that takes two arguments—a vector of the lengths needed and the length of stock pipe
that Home Depot sells—and returns the minimum number of stock pipes needed to
service all requests in the vector. For example, if the vector contains [ 4, 3, 4, 1, 7, 8 ]
and the stock pipe length is 10, you can purchase three stock pipes and divide them as
follows:

Pipe 1: 4, 4, 1
Pipe 2: 3, 7
Pipe 3: 8

Doing so leaves you with two small remnants left over. There are other possible
arrangements that also fit into three stock pipes, but it cannot be done with fewer.

Download my solution for problem 4 here or  here.
Happy coding!!!

Wednesday, August 24, 2011

Random Language Generation & Markov models of language


"Well, that sounds like a good way; but that Saint Louis smarty that thinks he dresses so fine and is
aristocracy! Oh, all right, I'll keep still--because, said she had been taking no
note of time and "sniffing around, the very next morning, he won't think of the
knob, and
open comes the door and fell grateful breath. Tom whistled twice more. Tom saw the state his clothes, sobbing,
snuffling, now, so handsomely engraved and colored
frontispiece--a human figure, stark naked. At that moment, not twenty yards away, and stood by musing a minute. SHE won't
ever have of her child, and ordered him away. So he went
away; but he was
afraid he might possibly be counterfeited to its
injury is an impossible that the raftsmen were all ashamed of their beds, was a
ruin, now, blasted by the body from him with disgust. For frivolity and
jokes and spotted tights were an offense, when the little girl
was wending her way toward the village, and no guards were afforded for it; ten
red tickets equalled a yellow one; for ten yellow
tickets the superintendent gave a very plainly bound Bible (worth forty
cents in those easy times) to the pupils. To his left, back of the performance.
At last he
rose up sighing and departed were they, and then just see 'em look!"

The text above is a sample of what my solution to the Random Language Generation Problem generated. (Assignment 2: ADT Client Applications)

Random Language Generation is Problem 2 of Assignment #2 of the 2011 Spring Quarter CS106B course from Stanford.

You can download the problem specification here here. (Go to page 5 of the downloaded document)

Here is a screenshot of my solution:



You can download my code here.

You can download a runnable .exe file here.

You can download my code here.

You can download my code here.

Word Ladders


Word Ladders is Problem 1 of Assignment #2: ADT of the 2011 Spring Quarter CS106B course from Stanford.

The description below is taken from the assignment handout (you can download it here here).

A word ladder is a connection from one word to another formed by changing one letter at
a time with the constraint that at each step the sequence of letters still forms a valid word.
For example, here is a word ladder connecting "code" to "data".

code -> core -> care -> dare -> date -> data

That word ladder, however, is not the shortest possible one. Although the words may be
a little less familiar, the following ladder is one step shorter:

code -> cade -> cate -> date -> data


Here is a screenshot of my solution:


You can download my solution code here.

You can also download a runnable .exe file here.

You can download my solution here.

You can download my code here.

Sunday, August 21, 2011

Game Of Life


Here is my solution to the "Game of Life" Problem, a programming assignment from Stanford's CS106B class last Spring Quarter (2011)

Click here here to download the problem specification.



You can download my solution (source code) here.

If you want to play with it without compiling it, you can download a stand-alone .exe file here.

You can download my solutions here.

You can download my code here.

Have fun!

Boggle


I have been watching the 2011 Spring Quarter CS106B's videos by Steve Cooper from Stanford and have also done the assignments given in the class.

I have finished coding Boggle (assignment # 4) last night. You can download the problem specifications here here.

Here's a screenshot of my solution:




You can download my solution (code) here.

You can download my code here.

If you want a stand-alone .exe file you can download it here.

Pardon my code. I did not follow good style practices in coding this. I did not comment everything.

I hope I can be able to fix this next time.

Enjoy!