CMPSCI 187 Midterm 1 (Feb 17, 2016)
Instructions:
This is a closed book, closed notes exam. You have 120 minutes to
complete the exam.
The exam has 10 pages printed on double sides. Be sure to check both
sides of each paper.
Please write down your name
CmpSci 187: Programming with Data Structures
Spring 2015
Lecture #24, More on Selection
John Ridgway
April 28, 2015
The Selection Problem Revisited
The selection problem can be restated in this way: given a key, we wish
to nd some value associated with i
CmpSci 187: Programming with Data Structures
Spring 2015
Lecture #4
John Ridgway
February 5, 2015
1
Abstract Data Types
Abstract Data Types (ADTs)
Abstraction.
Information hiding.
Data abstraction.
We deal with data at three dierent levels: applicatio
CmpSci 187: Programming with Data Structures
Spring 2015
Lecture #1
John Ridgway
January 20, 2015
Contents
1 Introduction
1
2 Administrative Stu
1
3 Software Engineering
2
1
Introduction
About the Course
What is CmpSci 187?
Programming Maturity?
Data S
Programming with
Data Structures
CMPSCI 187
Fall 2016
Please find a seat
Try to sit close to the center (the room will be pretty full!)
Turn off or silence your mobile phone
Turn off your other internet-enabled devices
1
Topics
Implement List ADT using L
Reminders and Topics
Heap Queues due this Friday 4pm
This lecture:
Depth-First Search in Graphs
Breadth-First Search in Graphs
Search Applications
1
Graph Search / Traversal
Graph search / traversal is a fundamental operation:
Is there a path from vertex
Programming With Data Structures
Introduction to Graphs
Reminders and Topics
Priority Queues due this Friday 4pm
This and next lectures:
Graphs
Representation of Graphs
Search in Graphs
2
Graphs
Similar to trees, graphs are made up of vertices
(nodes) and
Programming with
Data Structures
CMPSCI 187
Fall 2016
Please find a seat
Try to sit close to the center (the room will be pretty full!)
Turn off or silence your mobile phone
Turn off your other internet-enabled devices
1
Abstract and Array-Based Lists
Co
Programming with
Data Structures
CMPSCI 187
Fall 2016
Please find a seat
Try to sit close to the center (the room will be pretty full!)
Turn off or silence your mobile phone
Turn off your other internet-enabled devices
1
Reminders and Topics
Sets project
Reminders and Topics
Search is due this Friday
This lecture:
Simple Sorting O(N2)
Bubble Sort, Selection Sort, Insertion Sort
Merge Sort O(N logN)
1
A Familiar Example
Sorting
Given an array of comparable objects, sort them in
ascending (default) or desce
Programming with
Data Structures
CMPSCI 187
Fall 2016
Please find a seat
Try to sit close to the center (the room will be pretty full!)
Turn off or silence your mobile phone
Turn off your other internet-enabled devices
1
Reminders and Topics
Midterm 2 is
Programming with
Data Structures
CMPSCI 187
Fall 2016
Please find a seat
Try to sit close to the center (the room will be pretty full!)
Turn off or silence your mobile phone
Turn off your other internet-enabled devices
1
Reminders and Topics
recursive-li
Programming with
Data Structures
CMPSCI 187
Fall 2016
Please find a seat
Try to sit close to the center (the room will be pretty full!)
Turn off or silence your mobile phone
Turn off your other internet-enabled devices
1
Reminders and Topics
BST due this
1
First Exam Study Sheet
Chem 111 Sections 2 and 3, Spring 2017
-No units other than scientific ones will be used (i.e., no ounces, gallons, or other units not used
in scientific research). Students should know all conversion factors between scientific un
An Unbounded Array Queue
DJW implement an unbounded array-based queue
class. As with the standard Java class
ArrayList, the main idea is to increase the size of
the array when it becomes full, copying the
contents into a new larger array and replacing the
CmpSci 187: Programming with Data Structures
Spring 2015
Lecture #6
John Ridgway
February 12, 2015
Administrivia
Collect papers for discussions 2 and 3.
First exam Feb 19 at 7:00pm in Marcus 131. If you cant do it then
(documented excuse) let me know TO
CmpSci 187: Programming with Data Structures
Spring 2015
Lecture #2
John Ridgway
January 22, 2015
1
Administrivia
Administrivia
Clickers
Lecture shopping
Exam schedule: February 19, March 25, April 23, evenings!
2
Last thoughts on Software Engineering
CmpSci 187: Programming with Data Structures
Spring 2015
Lecture #5
John Ridgway
February 10, 2015
Administrivia
No discussion: homework posted instead
First exam Feb 19 at 7:00pm in Marcus 131.
Grades on Moodle
Assignment 02 due Thursday due at 8:30
CmpSci 187: Programming with Data Structures
Spring 2015
Lecture #23, More Sorting Algorithms
John Ridgway
April 23, 2015
1
Ecient Sorting Algorithms
Merge Sort Review
Code for mergeSort
void mergeSort ( int first , int last ) cfw_
if ( first < last ) cfw
CmpSci 187: Programming with Data Structures
Spring 2015
Lecture #22, More Graph Searches, Some Sorting, and Ecient Sorting
Algorithms
John Ridgway
April 21, 2015
1
Review of Uniform-cost Search
Uniform-Cost Search
This method from DJW makes a priority q
CmpSci 187: Programming with Data Structures
Spring 2015
Lecture #21, Searching in Graphs
John Ridgway
April 16, 2015
1
Errata
Errors in Balancing a Binary Search Tree
The code given in DJW to balance a binary search tree works well in the
absence of dup
CmpSci 187: Programming with Data Structures
Spring 2015
Lecture #20, Introduction to Graphs
John Ridgway
April 14, 2015
1
Introduction to Graphs
Graphs and their Vocabulary
Linear lists and trees are two ways to make objects out of nodes and
connections
CmpSci 187: Programming with Data Structures
Spring 2015
Lecture #18, Using Binary Search Trees
John Ridgway
April 7, 2015
1
Using Binary Search Trees
Review: Balancing a BST
As weve discussed, nding an element in a binary search tree takes worstcase tim
CmpSci 187: Programming with Data Structures
Spring 2015
Lecture #19, Heaps and Priority Queues
John Ridgway
April 9, 2015
1
Heaps
Review: The Idea of a Heap
A heap is a data structure that keeps some comparable elements in a
semi-sorted state.
The larg
CmpSci 187: Programming with Data Structures
Spring 2015
Lecture #17, Implementing Binary Search Trees
John Ridgway
April 2, 2015
1
Implementing Binary Search Trees
Review: The BST Interface
Binary search trees store objects in nodes, arranged according
CmpSci 187: Programming with Data Structures
Spring 2015
Lecture #14, Lists: The Abstraction and Array Implementation
John Ridgway
March 24, 2015
1
Comparing Objects in Java
Comparing Objects in Java
We are going to look at lists, one of the most general