University of California, Santa Barbara
Computer Science Department
Data Structures and Algorithms
CMPSC 130A (Fall 2008)

In what follows I use [HS], [Sa], [AHU], etc. These refer to the books listed in the class WEB page (first handout).



Solutions to Quiz 1 (f09) (PDF File)


Solutions to Quiz 2 (f09) (PDF File)


Solution to MT 1 (part 1) (f09) (PDF File)


Solution to MT 1 (part 2) (f09) (PDF File)


Solution to MT 2 (f09) (PDF File)


Turnin Instructions
Instructions to Turnin electronically your program Part I.


Programming Project (Preliminary Version) (f09) (PDF File)

Python program (created by the TA) to emulate the project behaviour. To run it in CSIL type the command: python project.py inputfilename
Where project.py is the file you create by clicking above. Please report to the TA and Instructor if you suspect the program generates incorrect output lines.

Sample input file(Text File)

Sample output file (Text File)

Internal represention of the data for the input file given above (Text File)

Sample Main Program (Text File)

Sample Code (PART I) (works only for SOME inputs. These inputs are not valid inputs to the project. These inputs were created to test the sample code)

Input for sample code (PART I) (This is not valid input for the project)

Sample Code (PART I) WITH CHECK FUNCTION (works only for SOME inputs. These inputs are not valid inputs to the project. These inputs were created to test the sample code)

Sample Code (PART II) (works only for SOME inputs. These inputs are not valid inputs to the project. These inputs were created to test the sample code. The code includes the Check function. New version as of 11/07/09)

Input for sample code (PART II) (This is not valid input for the project)

Input for sample code WITH CHECK FUNCTION (This is not valid input for the project)

Output for sample code (This is the output when running th sample code with input for the sample code)


Slides from CMPSC 60 (virtual and pure virtual functions)

Example of how to partition definitions and member fuctions for classes into .h and .C files and defining a makefile for all the files

Part I of HW 1


Skew Heaps (Basic Definition + Analysis).

Similar material also appears in [W] Section 6.7. Material appears in paper by Sleator and Tarjan, Self-Adjusting Heaps, SIAM J. Comput., Vol 15 #1, Feb. 1986.



Time and Space Complexity (PDF File (read in CSIL with acroread))

Program Testing (PDF File)

The time and space complexity, and program testing was partially derived from the following sources: Textbooks ([W] Chapter 2 and [Sa] Chapters 1.9, 2, 3 and 4).

Dictionary on arrays and linked lists (PDF File)

The Dictionaly on arrays and link lists is CS 20 material. The only new thing may be the time complexity analysis. Chapters 2 and 3 in [W] and Chapter 3, 5 and 6 in [Sa] provide backgound for this material.

Tries (PDF File)

The code for tries is original (I developed it), but the idea is not new. Huffman codes ([W] Sec. 10.1.2 and [Sa] Sec. 12.6.3) are used to represent alphabet letters by strings of 0s and 1s. These strings over the alphabet {0,1} are represented by tries. Note that the way the strings are chosen is called Huffman coding, but the way the strings are represented is via tries. Arturo Gonzalez found the web page http://www.cs.mcgill.ca/~cs251/OldCourses/1997/topic7/ where tries are discussed under the name uncompressed tries. Their representation is slightly different than ours. Other pages talking about tries include: http://www.csse.monash.edu.au/~lloyd/tildeAlgDS/Tree/Trie/ and http://www.eecs.harvard.edu/~ellard/Q-97/HTML/root/node22.html Google (or other search engines) can help you find more information about tries.

LINUX (CSIL) Code for Dictionary on Tries discussed in class (text File)

Hashing and Compression (PDF File)
This material is from the textbook [Sa], Sections 10.5 and 10.5. The material on Hashing appears also in the textbook by [W] chapter 5.

A nice discussion about LZW appears in http://www.cs.sfu.ca/cs/CC/365/li/squeeze/LZW.html Note that the decompression algorithm there is different from the one we discussed in class and it has a small bug (this is what one gets from the net!). If you click in the ZLW Compression link in that page you will access a correct decompression algorithm and an article by Mark Nelson about all of this.

The material on Universal Hashing is taken from [CLR] pp. 229-232.

Heaps (PDF File)
This material is from [Sa] Section 12.4 and [W] Section 6.3.

Height-Biased Leftest Trees (PDF File)
This is covered in the textboo [Sa] section 12.5. Wiki on Leftist Trees has some info too (but I am not so sure it is 100% correct).

Red-Black Trees (PDF File)
This material is from [Sa] Section 15.2 and [W] Section 12.2.

Red-Black Tree Insert (PDF File)
This material is from [Sa] Section 15.2 and [W] Section 12.2s Bottom-Up Insert. But the material best matches the one in [W]. But there is a difference. In [W] they do not apply color changes, in there a rotation is used instead of color change. Bottom-up Insert.

Red-Black Tree Delete, Concatenate and Split (PDF File)
This material is from [W] Section 12.2.3. Top-Down delete. Note that there is a little difference between the procedures discussed in class. Plus concatenate, split and other operations.

THE STUFF AFTER THIS POINT IS TENTATIVE. IT MAY CHANGE BEFORE WE PRESENT IT IN CLASS ...

Union-Find
This material is covered in chapter 8 in [W] (See section 8.7 for an application of union-find to generatre mazes. The material also appears in [Sa] Section 6.5.4. (See example 6.6 (from wires to nets)).

Sorting
This is from [W] chapter 7 and [Sa] Sections 6.5.1, 6.5.2, 12.6.1, 18.2.2, 18.2.3, and 18.4.2.

B-Trees
The B-tree algorithmic details are not in the textbook. It came from Horowitz and Sahni Fundamentals of DS (CS Press). But it is not exactly as it is there. The algorithms were modified by Prof. Gonzalez to be more OO. by Prof. The textbook [W] talks about B-trees, but they are actually B'-Trees accoring to out notation in the slides. THe textbook [Sa] section 15.4 talks about B-trees. They have examples, but not the code.

Basic Graph Material

Depth-First Search

Graph Algorithms

The material for graphs comes from [W] (9.1, 9.5.2, 9.6) and from [Sa] (16.1, 16.2, 16.5 16.6, 16.8.4, 16.8.5, 16.8.6, 16.9).

BFS

The material is also in the textbook [W] Section 9.3.1 and [Sa] Section 16.8.

Euler Circuit Program (Slides)

Euler Circuit C++ Program

Data Structure (Euler Circuit Program)

Euler Circuit Input 1

Euler Circuit Input 2

Skip Lists (in Project 2005 - 2006) [S] (Chapter 10.4)

Mergeable B'-Trees (in Project 2006-2007)

Ads

OLD STUFF

Idividual assignment 1 (Summer 08) (.pdf File)

Solutions to Quiz 1 (Summer 08) (.pdf File)

Solutions to Quiz 2 (Summer 08) (.pdf File)

Solutions to Mid-Term (Summer 08) (.pdf File)

Solution to Quiz 1 (W07) (PDF File)
Solution to Quiz 2 (W07) (PDF File)
Solution to Quiz 3 (W07) (PDF File)
Solution to Quiz 4 (W07) (PDF File)
Solution to Quiz 5 (W07) (PDF File)
Solution to Quiz 6 (W07) (PDF File)
Solution to Mid Term (W07) (PDF File)
Hw1 (W07) (PDF File)
Solution to HW 1 (W07) (PDF File)
HW 2 (W07) (PDF File)
Solution to HW 2 (W07) (PDF File)

TA Review
Homework 2 (W08) (PDF File)
Solutions to Homework 2 (W08) (PDF File)
Solution (Hw2 Problem 4) (W08) (PDF File)
Solution to Quiz 1 (W08) (PDF File)
Solution to Quiz 1.5 (extra) (W08) (PDF File)
Hw1 (W08) (PDF File)
Solution (Hw1) (W08) (PDF File)
Solution MT (W08) (PDF File)
Solution MT (W08) (PDF File)
Old MTs (PDF File)
Old MTs (PDF File)

OLD Project Related Files

Turnin Instructions
Instructions to Turnin electronically your program Part I.
Population
clock

Total number of visitors to this page, since 1/1/2001, is

sh.pdf rbd.pdf qz2.s.pdf uf.pdf