# Register now to access 7 million high quality study materials (What's Course Hero?) Course Hero is the premier provider of high quality online educational resources. With millions of study documents, online tutors, digital flashcards and free courseware, Course Hero is helping students learn more efficiently and effectively. Whether you're interested in exploring new subjects or mastering key topics for your next exam, Course Hero has the tools you need to achieve your goals.

3 Pages

### 26S-Section-Solution

Course: CS 106, Fall 2009
School: Stanford
Rating:

Word Count: 323

#### Document Preview

Spring CS106X 2009 Handout 26S Section Solution May 6 8, 2009 Solution 1: The Sparse String Vector a. Present implementations for the constructor and destructor. SparseStringVector::SparseStringVector(int arrayLength, int groupSize) { this-&gt;arrayLength = arrayLength; this-&gt;groupSize = groupSize; numGroups = arrayLength / groupSize; groups = new group[numGroups]; for (int i = 0; i &lt;...

Register Now

#### Unformatted Document Excerpt

Coursehero >> California >> Stanford >> CS 106

Course Hero has millions of student submitted documents similar to the one
below including study guides, practice problems, reference materials, practice exams, textbook help and tutor support.

Course Hero has millions of student submitted documents similar to the one below including study guides, practice problems, reference materials, practice exams, textbook help and tutor support.
Spring CS106X 2009 Handout 26S Section Solution May 6 8, 2009 Solution 1: The Sparse String Vector a. Present implementations for the constructor and destructor. SparseStringVector::SparseStringVector(int arrayLength, int groupSize) { this->arrayLength = arrayLength; this->groupSize = groupSize; numGroups = arrayLength / groupSize; groups = new group[numGroups]; for (int i = 0; i < numGroups; i++) { groups[i].bitmap = new bool[this->groupSize]; for (int j = 0; j < this->groupSize; j++) { groups[i].bitmap[j] = false; } } } SparseStringVector::~SparseStringVector() { for (int i = 0; i < numGroups; i++) { delete[] groups[i].bitmap; } delete[] groups; } b. Now implement the more involved insert function, which ensures that the string received as str stored in the proper Vector<string> within the proper group and that the proper bool in the bitmap is set. bool SparseStringVector::insert(int index, string str) { int group = index / groupSize; int indexWithinBitmap = index % groupSize; int indexWithinVector = 0; for (int i = 0; i < indexWithinBitmap; i++) { if (groups[group].bitmap[i]) indexWithinVector++; } bool previouslyInserted = groups[group].bitmap[indexWithinBitmap]; if (previouslyInserted) groups[group].strings[indexWithinVector] = str; else groups[group].strings.insertAt(indexWithinVector, groups[group].bitmap[indexWithinBitmap] str); = true; return !previouslyInserted; } 2 c. Finally, implement the serialize method, which returns the ordered concatenation of every single string held by the SparseStringVector. string SparseStringVector::serialization() { string str = ""; for (int i = 0; i < numGroups; i++) { for (int j = 0; j < groups[i].strings.size(); j++) { str += groups[i].strings.getAt(j); } } return str; } Solution 2: Removing Duplicates void RemoveDuplicates(node *list) { for (node *cur = list; cur != NULL; cur = cur->next) { if (cur->next != NULL && cur->value == cur->next->value) { // match? node *duplicate = cur->next; // remember cur->next = cur->next->next; // circumvent delete duplicate; // dispose ...

Find millions of documents on Course Hero - Study Guides, Lecture Notes, Reference Materials, Practice Exams and more. Course Hero has millions of course specific materials providing students with the best way to expand their education.

Below is a small sample set of documents:

Washington - M - 124
%!PS-Adobe-2.0 %Creator: dvips(k) 5.86 Copyright 1999 Radical Eye Software %Title: ws7c.dvi %Pages: 4 %PageOrder: Ascend %BoundingBox: 0 0 612 792 %DocumentFonts: Courier %EndComments %DVIPSWebPage: (www.radicaleye.com) %DVIPSCommandLine: dvips ws7c.
Washington - M - 124
%!PSAdobe2.0 %Creator: dvips(k) 5.86 Copyright 1999 Radical Eye Software %Title: junk.dvi %Pages: 2 %PageOrder: Ascend %BoundingBox: 0 0 612 792 %EndComments %DVIPSWebPage: (www.radicaleye.com) %DVIPSCommandLine: dvips junk.dvi o junk.ps %DVIPSParame
Washington - M - 124
Georgia Tech - PHYSICS - 2211
FUNDAMENTAL PHYSICAL LAWS Principle of relativity: Physical laws work in the same way for observers in uniform motion as for observers at rest. The superposition principle: the effective force on an object is the &quot;net&quot; force, the vector sum of all fo
Georgia Tech - PHYSICS - 2211
Thursday, April 12, 2007 5:02 PMLecture 34 Page 1Lecture 34 Page 2Lecture 34 Page 3Lecture 34 Page 4Lecture 34 Page 5Lecture 34 Page 6Lecture 34 Page 7
Georgia Tech - PHYSICS - 2211
Lecture 37 Page 1Friday, April 20, 2007 12:36 AMLecture 37 Page 2Lecture 37 Page 3Lecture 37 Page 4Lecture 37 Page 5Lecture 37 Page 6Lecture 37 Page 7Lecture 37 Page 8Lecture 37 Page 9Lecture 37 Page 10Lecture 37 Page 11Lectur
Georgia Tech - PHYSICS - 2211
Lecture 18 Page 1Thursday, February 22, 2007 7:11 PMLecture 18 Page 2Lecture 18 Page 3Lecture 18 Page 4lLecture 18 Page 5Lecture 18 Page 6Lecture 18 Page 7Lecture 18 Page 8Lecture 18 Page 9Lecture 18 Page 10Lecture 18 Page 11
Georgia Tech - PHYSICS - 2211
Tuesday, February 20, 2007 7:07 PMYou bring a boat toward the dock by pulling on a rope with a force of 110 newtons through a distance of 6 meters. How much work do you do? (Include the appropriate sign.)Then you slow the boat down by pushing aga
Georgia Tech - PHYSICS - 2211
Tuesday, MarcLecture 29 Page 1h 27, 2007 5:41 PMLecture 29 Page 2Lecture 29 Page 3Lecture 29 Page 4Lecture 29 Page 5Lecture 29 Page 6Lecture 29 Page 7Lecture 29 Page 8bbbbbbbbb bbbbLecture 29 Page 9Lecture 29 Page 10Lecture
Georgia Tech - PHYSICS - 2211
Thursday, March 08, 2007 11:10 AMNew Section 5 Page 1New Section 5 Page 2New Section 5 Page 3New Section 5 Page 4New Section 5 Page 5New Section 5 Page 6New Section 5 Page 7New Section 5 Page 8New Section 5 Page 9New Section 5 Pag
Georgia Tech - PHYSICS - 2211
Lecture 30 Page 1Lecture 30 Page 3Lecture 30 Page 5Lecture 30 Page 7Lecture 30 Page 9Lecture 30 Page 11Lecture 30 Page 13Lecture 30 Page 15
Georgia Tech - PHYSICS - 2211
Thursday, March 15, 2007 8:19 PMLecture 27 Page 1Lecture 27 Page 2Lecture 27 Page 3Lecture 27 Page 4Lecture 27 Page 5Lecture 27 Page 6Lecture 27 Page 7
Georgia Tech - PHYSICS - 2211
Tuesday, March 13, 2007 11:58 PMLecture 26 Page 1Lecture 26 Page 2Lecture 26 Page 3Lecture 26 Page 4Lecture 26 Page 5Lecture 26 Page 6Lecture 26 Page 7Lecture 26 Page 8
Georgia Tech - PHYSICS - 2211
Wednesday, April 18, 2007 5:48 AMhttp:/www.coursesurvey.gatech.eduLecture 36 Page 1Lecture 36 Page 2Lecture 36 Page 3Lecture 36 Page 4Lecture 36 Page 5Lecture 36 Page 6Lecture 36 Page 7
Georgia Tech - PHYSICS - 2211
Wednesday, February 28, 2007 8:31 AMNew Section 3 Page 1New Section 3 Page 2New Section 3 Page 3New Section 3 Page 4New Section 3 Page 5New Section 3 Page 6New Section 3 Page 7
Georgia Tech - PHYSICS - 2211
Saturday, February 17, 2007 5:47 PMEnergy Lecture Page 1Energy Lecture Page 2Energy Lecture Page 3Energy Lecture Page 4Energy Lecture Page 5Energy Lecture Page 6Energy Lecture Page 7Energy Lecture Page 8Energy Lecture Page 9Energy
Georgia Tech - PHYSICS - 2211
Sunday, March 11, 2007 8:58 PMNew Section 6 Page 1New Section 6 Page 2New Section 6 Page 3New Section 6 Page 4New Section 6 Page 5New Section 6 Page 6New Section 6 Page 7New Section 6 Page 8New Section 6 Page 9New Section 6 Page 1
Richmond - ACCT - 305
Washington - OCEAN - 200
Stanford - ENVY - 1001
US District Court Civil Docket as of 04/25/2005 Retrieved from the court on Friday, July 15, 2005U.S. District Court Middle District of Tennessee (Nashville)CIVIL DOCKET FOR CASE #: 3:98-cv-00760Castillo, et al v. Envoy Corporation, et al Assign
Stanford - WGRD - 1034
Case 2:05-cv-00678-JLRDocument 68Filed 10/12/2006Page 1 of 201 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28UNITED STATES DISTRICT COURT WESTERN DISTRICT OF WASHINGTON AT SEATTLE IN RE WATCHGUARD SECURITIES LITIGA
Georgia Tech - CS - 8803
%!PS-Adobe-2.0 %Creator: dvips(k) 5.86 Copyright 1999 Radical Eye Software %Title: syllabus.dvi %Pages: 2 %PageOrder: Ascend %BoundingBox: 0 0 612 792 %DocumentFonts: CMR10 CMBX10 CMTT10 CMTI10 %EndComments %DVIPSWebPage: (www.radicaleye.com) %DVIPSC
Georgia Tech - CS - 8803
%!PS-Adobe-2.0 %Creator: dvips(k) 5.86 Copyright 1999 Radical Eye Software %Title: project1.dvi %Pages: 7 %PageOrder: Ascend %BoundingBox: 0 0 612 792 %DocumentFonts: CMR10 CMBX10 CMTI10 CMTT10 CMTT9 CMSY10 %EndComments %DVIPSWebPage: (www.radicaleye
Georgia Tech - CS - 8803
%!PS-Adobe-2.0 %Creator: dvips(k) 5.86 Copyright 1999 Radical Eye Software %Title: project2.dvi %Pages: 2 %PageOrder: Ascend %BoundingBox: 0 0 612 792 %DocumentFonts: CMR10 CMBX10 CMTT10 CMTI10 CMSY10 CMMI10 %EndComments %DVIPSWebPage: (www.radicaley
Georgia Tech - CS - 8803
%!PS-Adobe-2.0 %Creator: dvips(k) 5.86 Copyright 1999 Radical Eye Software %Title: project3.dvi %Pages: 2 %PageOrder: Ascend %BoundingBox: 0 0 612 792 %DocumentFonts: CMR10 CMBX10 CMMI10 CMTI10 CMTT10 CMSY10 %EndComments %DVIPSWebPage: (www.radicaley
Richmond - PS - 358
Richmond - ES - 201
Mar 28, 2006 Name: Pledge (sign):Env Studies 201 Test #2Point Total: 100 pts possible20 pts1. Pick four of the following items, and define each in 1 sentence. (a) weak sustainability(b) environmental Kuznets curve(c) common pool resource(
Washington - B - 111
Forensic statistics: extreme numbers and the Birthday ProblemBruce Weir bsweir@u.washington.eduJonBenet Ramsey DNA tests clear JonBenet Ramsey's family of her 1996 killing Results point to 'unexplained third party,' prosecutor says Last U
East Los Angeles College - MBA - 248
Management Analysis Session Summary SheetSession 4: Framing decision problems (Stefan Scholtes) Before the session you should have installed the student version of Palisade's Decision Tools Suite on your notebook. This software is included with the
East Los Angeles College - MBA - 248
S. Scholtes Judge Institute of Management University of Cambridge14. April 2003S. Scholtes Judge Institute of Management 9.00 9.30 Introduction to Modelling 9.30 10.00 Monty Hall Game 10.00 10.15 Coffee Break 10.15 11.00 SciTools
East Los Angeles College - MBA - 248
S. Scholtes Judge Institute of Management University of Cambridge14. April 2003S. Scholtes Judge Institute of ManagementGraphical tool for analysing decisions under risk Helps to structure the decisions to be made Shows the dependency of th