<?xml version="1.0" encoding="UTF-8"?>
<rss version="2.0"
	xmlns:content="http://purl.org/rss/1.0/modules/content/"
	xmlns:wfw="http://wellformedweb.org/CommentAPI/"
	xmlns:dc="http://purl.org/dc/elements/1.1/"
	xmlns:atom="http://www.w3.org/2005/Atom"
	xmlns:sy="http://purl.org/rss/1.0/modules/syndication/"
	xmlns:slash="http://purl.org/rss/1.0/modules/slash/"
	xmlns:georss="http://www.georss.org/georss" xmlns:geo="http://www.w3.org/2003/01/geo/wgs84_pos#" xmlns:media="http://search.yahoo.com/mrss/"
	>

<channel>
	<title>Chad Salinas C++</title>
	<atom:link href="http://programmingabstractions.wordpress.com/feed/" rel="self" type="application/rss+xml" />
	<link>http://programmingabstractions.wordpress.com</link>
	<description>Chad Salinas CS106x</description>
	<lastBuildDate>Wed, 10 Dec 2008 04:10:50 +0000</lastBuildDate>
	<generator>http://wordpress.com/</generator>
	<language>en</language>
	<sy:updatePeriod>hourly</sy:updatePeriod>
	<sy:updateFrequency>1</sy:updateFrequency>
	<cloud domain='programmingabstractions.wordpress.com' port='80' path='/?rsscloud=notify' registerProcedure='' protocol='http-post' />
<image>
		<url>http://www.gravatar.com/blavatar/d5e214d401bd7f2ae7597f3d419784f4?s=96&#038;d=http://s.wordpress.com/i/buttonw-com.png</url>
		<title>Chad Salinas C++</title>
		<link>http://programmingabstractions.wordpress.com</link>
	</image>
	<atom:link rel="search" type="application/opensearchdescription+xml" href="http://programmingabstractions.wordpress.com/osd.xml" title="Chad Salinas C++" />
		<item>
		<title>Recursion Examples</title>
		<link>http://programmingabstractions.wordpress.com/2008/11/20/recursion-examples/</link>
		<comments>http://programmingabstractions.wordpress.com/2008/11/20/recursion-examples/#comments</comments>
		<pubDate>Thu, 20 Nov 2008 19:23:50 +0000</pubDate>
		<dc:creator>Chad Salinas</dc:creator>
				<category><![CDATA[C++ Recursion Idioms]]></category>
		<category><![CDATA[Chad Salinas Canoncial Recursion Examples]]></category>

		<guid isPermaLink="false">http://programmingabstractions.wordpress.com/?p=19</guid>
		<description><![CDATA[So, allow me to ramble on in an unstructured form with the idea of capturing the different types of cannonical recursion examples.  When you hear beknighted C++ developers talk, much is made of multiple inheiritance or recursion.  Yet, on a daily basis neither really comes up too frequently.  The latter, however, when it does appear, [...]<img alt="" border="0" src="http://stats.wordpress.com/b.gif?host=programmingabstractions.wordpress.com&blog=5412140&post=19&subd=programmingabstractions&ref=&feed=1" />]]></description>
			<content:encoded><![CDATA[<div class='snap_preview'><br /><p>So, allow me to ramble on in an unstructured form with the idea of capturing the different types of cannonical recursion examples.  When you hear beknighted C++ developers talk, much is made of multiple inheiritance or recursion.  Yet, on a daily basis neither really comes up too frequently.  The latter, however, when it does appear, usually is the ONLY way to solve some problem.  Before I attmpt to topologically capture which recursion problems can be solved with which idioms, I want to consider the mathematical foundations behind a recursion.  How many people have an intuitive notion for the running time of Insertion sort without having to the formal inductive proof?  Who wants to continue this expansion?</p>
<div id="attachment_21" class="wp-caption alignnone" style="width: 478px"><a href="http://programmingabstractions.files.wordpress.com/2008/11/recursionforinsertionsort1.gif"><img class="size-full wp-image-21" title="recursionforinsertionsort1" src="http://programmingabstractions.files.wordpress.com/2008/11/recursionforinsertionsort1.gif?w=468&#038;h=235" alt="Chad Salinas Recursion for Insertion Sort Example" width="468" height="235" /></a><p class="wp-caption-text">Chad Salinas Recursion for Insertion Sort Example</p></div>
<p>Need idiomatic recursion examples for:</p>
<ul>
<li>Exhaustive Permutation</li>
<li>Exhaustive Subset</li>
<li>Recursive Backtracking</li>
<li>Others???</li>
</ul>
<p>I have only Julie Zelenski at Stanford to thank for any of the following 2 C++ code examples:</p>
<p>1.  Exhaustive Permutation example</p>
<p>void RecPermute(string soFar, string rest)<br />
{<br />
if (rest.empty()) {<br />
cout &lt;&lt; soFar &lt;&lt; endl;<br />
} else {<br />
for (int i = 0; i &lt; rest.length(); i++) {<br />
string remaining = rest.substr(0, i)<br />
+ rest.substr(i+1);</p>
<p>RecPermute(soFar + rest[i], remaining);<br />
}<br />
}<br />
}</p>
<p>2.  Exhaustive Subset example</p>
<p>void RecSubsets(string soFar, string rest)<br />
{<br />
if (rest.empty())<br />
cout &lt;&lt; soFar &lt;&lt; endl;<br />
else {<br />
RecSubsets(soFar + rest[0], rest.substr(1)); // include first char<br />
RecSubsets(soFar, rest.substr(1)); // exclude first char<br />
}<br />
}</p>
<p>Chad Salinas</p>
  <a rel="nofollow" href="http://feeds.wordpress.com/1.0/gocomments/programmingabstractions.wordpress.com/19/"><img alt="" border="0" src="http://feeds.wordpress.com/1.0/comments/programmingabstractions.wordpress.com/19/" /></a> <a rel="nofollow" href="http://feeds.wordpress.com/1.0/godelicious/programmingabstractions.wordpress.com/19/"><img alt="" border="0" src="http://feeds.wordpress.com/1.0/delicious/programmingabstractions.wordpress.com/19/" /></a> <a rel="nofollow" href="http://feeds.wordpress.com/1.0/gostumble/programmingabstractions.wordpress.com/19/"><img alt="" border="0" src="http://feeds.wordpress.com/1.0/stumble/programmingabstractions.wordpress.com/19/" /></a> <a rel="nofollow" href="http://feeds.wordpress.com/1.0/godigg/programmingabstractions.wordpress.com/19/"><img alt="" border="0" src="http://feeds.wordpress.com/1.0/digg/programmingabstractions.wordpress.com/19/" /></a> <a rel="nofollow" href="http://feeds.wordpress.com/1.0/goreddit/programmingabstractions.wordpress.com/19/"><img alt="" border="0" src="http://feeds.wordpress.com/1.0/reddit/programmingabstractions.wordpress.com/19/" /></a> <img alt="" border="0" src="http://stats.wordpress.com/b.gif?host=programmingabstractions.wordpress.com&blog=5412140&post=19&subd=programmingabstractions&ref=&feed=1" /></div>]]></content:encoded>
			<wfw:commentRss>http://programmingabstractions.wordpress.com/2008/11/20/recursion-examples/feed/</wfw:commentRss>
		<slash:comments>0</slash:comments>
	
		<media:content url="http://1.gravatar.com/avatar/190ac54724b8818d413b704f93271483?s=96&#38;d=identicon" medium="image">
			<media:title type="html">chadsalinas</media:title>
		</media:content>

		<media:content url="http://programmingabstractions.files.wordpress.com/2008/11/recursionforinsertionsort1.gif" medium="image">
			<media:title type="html">recursionforinsertionsort1</media:title>
		</media:content>
	</item>
		<item>
		<title>Let&#8217;s Create a Memory Leak</title>
		<link>http://programmingabstractions.wordpress.com/2008/11/11/lets-create-a-memory-leak/</link>
		<comments>http://programmingabstractions.wordpress.com/2008/11/11/lets-create-a-memory-leak/#comments</comments>
		<pubDate>Tue, 11 Nov 2008 05:18:14 +0000</pubDate>
		<dc:creator>Chad Salinas</dc:creator>
				<category><![CDATA[Uncategorized]]></category>
		<category><![CDATA[C++]]></category>
		<category><![CDATA[memory leak]]></category>

		<guid isPermaLink="false">http://programmingabstractions.wordpress.com/?p=16</guid>
		<description><![CDATA[Doing due diligence of VC-baked software startups, I get to see a lot of code like this:
SalesOrder * Order = new[100]; &#8230;
delete Order;
The developer has just created a memory leak.  The destructor ~SalesOrder() will only delete the first order, orphaning the remaining 99 on the heap.  The correct call to release all the memory of [...]<img alt="" border="0" src="http://stats.wordpress.com/b.gif?host=programmingabstractions.wordpress.com&blog=5412140&post=16&subd=programmingabstractions&ref=&feed=1" />]]></description>
			<content:encoded><![CDATA[<div class='snap_preview'><br /><p>Doing due diligence of VC-baked software startups, I get to see a lot of code like this:</p>
<p>SalesOrder * Order = new[100]; &#8230;</p>
<p>delete Order;</p>
<p>The developer has just created a memory leak.  The destructor ~SalesOrder() will only delete the first order, orphaning the remaining 99 on the heap.  The correct call to release all the memory of the 100 orders is as follows:</p>
<p>delete [] Order;</p>
<p>You can confirm this by simply inserting a cout statement in the destructor.</p>
<p>Chad Salinas</p>
  <a rel="nofollow" href="http://feeds.wordpress.com/1.0/gocomments/programmingabstractions.wordpress.com/16/"><img alt="" border="0" src="http://feeds.wordpress.com/1.0/comments/programmingabstractions.wordpress.com/16/" /></a> <a rel="nofollow" href="http://feeds.wordpress.com/1.0/godelicious/programmingabstractions.wordpress.com/16/"><img alt="" border="0" src="http://feeds.wordpress.com/1.0/delicious/programmingabstractions.wordpress.com/16/" /></a> <a rel="nofollow" href="http://feeds.wordpress.com/1.0/gostumble/programmingabstractions.wordpress.com/16/"><img alt="" border="0" src="http://feeds.wordpress.com/1.0/stumble/programmingabstractions.wordpress.com/16/" /></a> <a rel="nofollow" href="http://feeds.wordpress.com/1.0/godigg/programmingabstractions.wordpress.com/16/"><img alt="" border="0" src="http://feeds.wordpress.com/1.0/digg/programmingabstractions.wordpress.com/16/" /></a> <a rel="nofollow" href="http://feeds.wordpress.com/1.0/goreddit/programmingabstractions.wordpress.com/16/"><img alt="" border="0" src="http://feeds.wordpress.com/1.0/reddit/programmingabstractions.wordpress.com/16/" /></a> <img alt="" border="0" src="http://stats.wordpress.com/b.gif?host=programmingabstractions.wordpress.com&blog=5412140&post=16&subd=programmingabstractions&ref=&feed=1" /></div>]]></content:encoded>
			<wfw:commentRss>http://programmingabstractions.wordpress.com/2008/11/11/lets-create-a-memory-leak/feed/</wfw:commentRss>
		<slash:comments>0</slash:comments>
	
		<media:content url="http://1.gravatar.com/avatar/190ac54724b8818d413b704f93271483?s=96&#38;d=identicon" medium="image">
			<media:title type="html">chadsalinas</media:title>
		</media:content>
	</item>
		<item>
		<title>Pointer to an Array versus an Array of Pointers</title>
		<link>http://programmingabstractions.wordpress.com/2008/11/08/pointer-to-an-array-versus-an-array-of-pointers/</link>
		<comments>http://programmingabstractions.wordpress.com/2008/11/08/pointer-to-an-array-versus-an-array-of-pointers/#comments</comments>
		<pubDate>Sat, 08 Nov 2008 21:13:17 +0000</pubDate>
		<dc:creator>Chad Salinas</dc:creator>
				<category><![CDATA[Uncategorized]]></category>
		<category><![CDATA[Array]]></category>
		<category><![CDATA[pointers]]></category>

		<guid isPermaLink="false">http://programmingabstractions.wordpress.com/?p=14</guid>
		<description><![CDATA[Motivated by Liberty &#38; Jones
Consider the following declarations:

Cat FamilyOne[500]
Cat * FamilyTwo[500]
Cat * FamilyThree = new Cat[500]

FamilyOne is a simple array of 500 Cat objects on the stack &#8212; no &#8220;new&#8221; going on here.
FamilyTwo is an array of 500 pointers to Cat objects, still on the stack.
FamilyThree is a pointer to an array of 500 Cat [...]<img alt="" border="0" src="http://stats.wordpress.com/b.gif?host=programmingabstractions.wordpress.com&blog=5412140&post=14&subd=programmingabstractions&ref=&feed=1" />]]></description>
			<content:encoded><![CDATA[<div class='snap_preview'><br /><p>Motivated by Liberty &amp; Jones</p>
<p>Consider the following declarations:</p>
<ol>
<li>Cat FamilyOne[500]</li>
<li>Cat * FamilyTwo[500]</li>
<li>Cat * FamilyThree = new Cat[500]</li>
</ol>
<p>FamilyOne is a simple array of 500 Cat objects on the stack &#8212; no &#8220;new&#8221; going on here.</p>
<p>FamilyTwo is an array of 500 pointers to Cat objects, still on the stack.</p>
<p>FamilyThree is a pointer to an array of 500 Cat objects which are on the heap.</p>
<p>Chad Salinas</p>
  <a rel="nofollow" href="http://feeds.wordpress.com/1.0/gocomments/programmingabstractions.wordpress.com/14/"><img alt="" border="0" src="http://feeds.wordpress.com/1.0/comments/programmingabstractions.wordpress.com/14/" /></a> <a rel="nofollow" href="http://feeds.wordpress.com/1.0/godelicious/programmingabstractions.wordpress.com/14/"><img alt="" border="0" src="http://feeds.wordpress.com/1.0/delicious/programmingabstractions.wordpress.com/14/" /></a> <a rel="nofollow" href="http://feeds.wordpress.com/1.0/gostumble/programmingabstractions.wordpress.com/14/"><img alt="" border="0" src="http://feeds.wordpress.com/1.0/stumble/programmingabstractions.wordpress.com/14/" /></a> <a rel="nofollow" href="http://feeds.wordpress.com/1.0/godigg/programmingabstractions.wordpress.com/14/"><img alt="" border="0" src="http://feeds.wordpress.com/1.0/digg/programmingabstractions.wordpress.com/14/" /></a> <a rel="nofollow" href="http://feeds.wordpress.com/1.0/goreddit/programmingabstractions.wordpress.com/14/"><img alt="" border="0" src="http://feeds.wordpress.com/1.0/reddit/programmingabstractions.wordpress.com/14/" /></a> <img alt="" border="0" src="http://stats.wordpress.com/b.gif?host=programmingabstractions.wordpress.com&blog=5412140&post=14&subd=programmingabstractions&ref=&feed=1" /></div>]]></content:encoded>
			<wfw:commentRss>http://programmingabstractions.wordpress.com/2008/11/08/pointer-to-an-array-versus-an-array-of-pointers/feed/</wfw:commentRss>
		<slash:comments>0</slash:comments>
	
		<media:content url="http://1.gravatar.com/avatar/190ac54724b8818d413b704f93271483?s=96&#38;d=identicon" medium="image">
			<media:title type="html">chadsalinas</media:title>
		</media:content>
	</item>
		<item>
		<title>C++ Pointer Arithmetic</title>
		<link>http://programmingabstractions.wordpress.com/2008/11/08/c-pointer-arithmetic/</link>
		<comments>http://programmingabstractions.wordpress.com/2008/11/08/c-pointer-arithmetic/#comments</comments>
		<pubDate>Sat, 08 Nov 2008 21:01:15 +0000</pubDate>
		<dc:creator>Chad Salinas</dc:creator>
				<category><![CDATA[Uncategorized]]></category>
		<category><![CDATA[C++]]></category>
		<category><![CDATA[Pointer arithmetic]]></category>

		<guid isPermaLink="false">http://programmingabstractions.wordpress.com/?p=8</guid>
		<description><![CDATA[Idea: Take 2 pointers and an array.  Point the 2 pointers at different elements in the array.  Taking the difference between the pointers yields the number of elements separating the 2 pointers.
Motivated by Liberty &#38; Jones
Do you like this signature?  bool GetWord(char * theString, char* word, int&#38; wordOffset)
check edge case of being at the end [...]<img alt="" border="0" src="http://stats.wordpress.com/b.gif?host=programmingabstractions.wordpress.com&blog=5412140&post=8&subd=programmingabstractions&ref=&feed=1" />]]></description>
			<content:encoded><![CDATA[<div class='snap_preview'><br /><p>Idea: Take 2 pointers and an array.  Point the 2 pointers at different elements in the array.  Taking the difference between the pointers yields the number of elements separating the 2 pointers.</p>
<p>Motivated by Liberty &amp; Jones</p>
<p>Do you like this signature?  bool GetWord(char * theString, char* word, int&amp; wordOffset)</p>
<p>check edge case of being at the end of string</p>
<p>work:  char * p1, *p2;</p>
<p>p1 = p2 = theString+wordOffset;</p>
<p>trim the leading spaces</p>
<p>determine whether you really have a word</p>
<p>p1 &amp; p2 are at the beginning of same word, so move p2 to the end of the word</p>
<p>get the length by the diff of p2 &amp; p1</p>
<p>&#8230;</p>
<p>Chad Salinas</p>
  <a rel="nofollow" href="http://feeds.wordpress.com/1.0/gocomments/programmingabstractions.wordpress.com/8/"><img alt="" border="0" src="http://feeds.wordpress.com/1.0/comments/programmingabstractions.wordpress.com/8/" /></a> <a rel="nofollow" href="http://feeds.wordpress.com/1.0/godelicious/programmingabstractions.wordpress.com/8/"><img alt="" border="0" src="http://feeds.wordpress.com/1.0/delicious/programmingabstractions.wordpress.com/8/" /></a> <a rel="nofollow" href="http://feeds.wordpress.com/1.0/gostumble/programmingabstractions.wordpress.com/8/"><img alt="" border="0" src="http://feeds.wordpress.com/1.0/stumble/programmingabstractions.wordpress.com/8/" /></a> <a rel="nofollow" href="http://feeds.wordpress.com/1.0/godigg/programmingabstractions.wordpress.com/8/"><img alt="" border="0" src="http://feeds.wordpress.com/1.0/digg/programmingabstractions.wordpress.com/8/" /></a> <a rel="nofollow" href="http://feeds.wordpress.com/1.0/goreddit/programmingabstractions.wordpress.com/8/"><img alt="" border="0" src="http://feeds.wordpress.com/1.0/reddit/programmingabstractions.wordpress.com/8/" /></a> <img alt="" border="0" src="http://stats.wordpress.com/b.gif?host=programmingabstractions.wordpress.com&blog=5412140&post=8&subd=programmingabstractions&ref=&feed=1" /></div>]]></content:encoded>
			<wfw:commentRss>http://programmingabstractions.wordpress.com/2008/11/08/c-pointer-arithmetic/feed/</wfw:commentRss>
		<slash:comments>0</slash:comments>
	
		<media:content url="http://1.gravatar.com/avatar/190ac54724b8818d413b704f93271483?s=96&#38;d=identicon" medium="image">
			<media:title type="html">chadsalinas</media:title>
		</media:content>
	</item>
		<item>
		<title>Building an Array of Pointers</title>
		<link>http://programmingabstractions.wordpress.com/2008/11/05/building-an-array-of-pointers/</link>
		<comments>http://programmingabstractions.wordpress.com/2008/11/05/building-an-array-of-pointers/#comments</comments>
		<pubDate>Wed, 05 Nov 2008 06:13:37 +0000</pubDate>
		<dc:creator>Chad Salinas</dc:creator>
				<category><![CDATA[Uncategorized]]></category>
		<category><![CDATA[heap]]></category>
		<category><![CDATA[pointers]]></category>
		<category><![CDATA[stack]]></category>

		<guid isPermaLink="false">http://programmingabstractions.wordpress.com/?p=3</guid>
		<description><![CDATA[Idea: since stack memory is limited and heap memory more abundant, declare objects on the heap.  Thereafter, store only a pointer to the object in the array.
Code Snippet from Liberty Jones&#8217; C++
#include &#60;iostream&#62;
using namespace std;
class Cat
{
public:
Cat() { itsAge = 1; itsWeight = 5; }
~Cat() {}
int GetAge() const { return itsAge; }
int GetWeight() const { return [...]<img alt="" border="0" src="http://stats.wordpress.com/b.gif?host=programmingabstractions.wordpress.com&blog=5412140&post=3&subd=programmingabstractions&ref=&feed=1" />]]></description>
			<content:encoded><![CDATA[<div class='snap_preview'><br /><p>Idea: since stack memory is limited and heap memory more abundant, declare objects on the heap.  Thereafter, store only a pointer to the object in the array.</p>
<p>Code Snippet from Liberty Jones&#8217; C++</p>
<p>#include &lt;iostream&gt;</p>
<p>using namespace std;</p>
<p>class Cat</p>
<p>{</p>
<p>public:</p>
<p>Cat() { itsAge = 1; itsWeight = 5; }</p>
<p>~Cat() {}</p>
<p>int GetAge() const { return itsAge; }</p>
<p>int GetWeight() const { return itsWeight; }</p>
<p>void SetAge(int age) { itsAge = age; }</p>
<p>private:</p>
<p>int itsAge;</p>
<p>int itsWeight;</p>
<p>};</p>
<p>int main()</p>
<p>{</p>
<p>Cat * Family[500];</p>
<p>int i;</p>
<p>Cat * pCat;</p>
<p>for (i = 0; i &lt; 500; i++)</p>
<p>{</p>
<p>pCat = new Cat;</p>
<p>pCat-&gt;SetAge(2*i + 1);</p>
<p>Family[i] = pCat;</p>
<p>}</p>
<p>for (i = 0; i &lt; 500; i++)</p>
<p>{</p>
<p>cout &lt;&lt; &#8220;Cat #&#8221; &lt;&lt; i+1 &lt;&lt; &#8220;: &#8220;;</p>
<p>cout &lt;&lt; Family[i]-&gt;GetAge() &lt;&lt; endl;</p>
<p>}</p>
<p>return 0;</p>
<p>}</p>
<p>Family is declared to hold 500 pointers to Cat objects.  500 Cats are created on the heap.  The pointers to each cat are assigned to the array of pointers vis-a-vis Family[i] = pCat 500 times.</p>
<p>Chad Salinas</p>
  <a rel="nofollow" href="http://feeds.wordpress.com/1.0/gocomments/programmingabstractions.wordpress.com/3/"><img alt="" border="0" src="http://feeds.wordpress.com/1.0/comments/programmingabstractions.wordpress.com/3/" /></a> <a rel="nofollow" href="http://feeds.wordpress.com/1.0/godelicious/programmingabstractions.wordpress.com/3/"><img alt="" border="0" src="http://feeds.wordpress.com/1.0/delicious/programmingabstractions.wordpress.com/3/" /></a> <a rel="nofollow" href="http://feeds.wordpress.com/1.0/gostumble/programmingabstractions.wordpress.com/3/"><img alt="" border="0" src="http://feeds.wordpress.com/1.0/stumble/programmingabstractions.wordpress.com/3/" /></a> <a rel="nofollow" href="http://feeds.wordpress.com/1.0/godigg/programmingabstractions.wordpress.com/3/"><img alt="" border="0" src="http://feeds.wordpress.com/1.0/digg/programmingabstractions.wordpress.com/3/" /></a> <a rel="nofollow" href="http://feeds.wordpress.com/1.0/goreddit/programmingabstractions.wordpress.com/3/"><img alt="" border="0" src="http://feeds.wordpress.com/1.0/reddit/programmingabstractions.wordpress.com/3/" /></a> <img alt="" border="0" src="http://stats.wordpress.com/b.gif?host=programmingabstractions.wordpress.com&blog=5412140&post=3&subd=programmingabstractions&ref=&feed=1" /></div>]]></content:encoded>
			<wfw:commentRss>http://programmingabstractions.wordpress.com/2008/11/05/building-an-array-of-pointers/feed/</wfw:commentRss>
		<slash:comments>0</slash:comments>
	
		<media:content url="http://1.gravatar.com/avatar/190ac54724b8818d413b704f93271483?s=96&#38;d=identicon" medium="image">
			<media:title type="html">chadsalinas</media:title>
		</media:content>
	</item>
	</channel>
</rss>