CSE310 Programming Project 01
OUT: Wednesday, 08/28/2013
DUE: Monday, 09/09/2013 (at the beginning of class)
The objectives of this project are making sure you (1) can implement an algorithm on general.asu.edu;
(2) can program in C+; (3) know how to use d
QUICKSORT
also uses divide-and-conquer approach. For sorting a
subarray A[ p . r ]
Sorting in place (unlike Merge Sort, like Insertion Sort).
Divide: The array A[p . r] is rearranged into two non-empty
subarrays A[p . q] and A[q+1 . r] such that each el
Depth-First Search
There exists several algorithms for searching a graph, i.e. for
systematically exploring the edges and nodes of the graph
A node is discovered in a search the first time it is encountered (or
visited) during the search;
A node is expl
Graphs
A graph G = (V, E) (or simply G(V, E) is given by
- set of nodes V
- set of edges E, where E V x V
b
f
h
e
Example:
a
i
j
g
d
c
Undirected graphs:
V = cfw_a, b, c, d, e, f, g, h, i, j
E = cfw_ (a, b), (a, c), (a, e), (b,d),
(c, d), (e, f), (f, g
Binary Search Trees
Search Trees:
Support dynamic-set operations, including SEARCH,
MINIMUM, MAXIMUM, PREDECESSOR, SUCCESSOR,
INSERT, and DELETE. Thus, they can be used both as a
dictionary and as a priority queue.
What is a binary search tree?
y
x
Bina
AVL TREES
AVL named after Adelson-Velskii, and Landis (1962)
The first data structures to guarantee O(log2 n) running time for search,
insert, and delete in the worst case.
Main Idea: (as in most other tree structures that achieve the worst-case
(
O(log
CSCI 2410 Data Structures and Algorithms
COURSE INFORMATION
Instructor:
Office:
Office Phone:
email:
Office Hours:
Text:
References:
Course URL:
Dr. Y. Daniel Liang
Science Center 112
(912) 344 - 3264
y.daniel.liang@gmail.com
Click here
Introduction to Ja
NAME:
CSE 421
Introduction to Algorithms
Sample Midterm Exam Autumn 2013 (Solved)
Anup Rao
30 October 2013
DIRECTIONS:
Answer the problems on the exam paper.
You are allowed one cheat sheet.
Justify all answers with proofs, unless the facts you
need ha
ARIZONA STATE UNIVERSITY
CSE 310, All Sections Data Structures and Algorithms Fall 2015
Assignment #1
Available Monday, 08/24/2015; due electronically Friday, 09/11/2015
This assignment covers Chapters 2, 3, and 4 of the text [100 marks total].
Submit ele
CSE 310
Data Structures and Algorithms
Heaps, Heap Sort, Priority Queue
The Heap data structure
Definition, properties
Building a heap; complexity
Heap sort: the algorithm and its complexity
Application of heap: priority queue
1
The Heap Data Structure
CSE 310
Data Structures and Algorithms
QUICKSORT
Another algorithm based on the divide-and-conquer approach
Analyzing Quicksort
1
The Divide/Conquer/Combine Steps of
Quicksort
For sorting a subarray A[p . r]
Divide: The array A[p . r] is rearranged into
CSE 310
Data Structures and Algorithms
Instructor: Jingrui He
Assistant Professor
CIDSE
Course materials available through Blackboard on MyASU
Fall, 2015
1
Lecture Overview
Discussion on syllabus and logistics
Course information, prerequisites, evaluati
Introduction to Parallelism
CSE 310, Fall 2015
Based on work by S. Wolfman, D. Grossman,
A. Hu, L. Snyder, M. Stepp
Everyday Parallelism
Some examples of everyday parallelism
House construction: parallel tasks, wiring and
plumbing performed at once
Ass
Hash Tables
-Many applications require a dynamic set that supports only the dictionary operations
Many
INSERT, SEARCH, and DELETE.
Example symbol table used by a compiler.
-Hash Table: an efficient data structure for implementing dictionaries,
a generaliz
Longest Common Subsequence
a subsequence of a given sequence is just the given sequence with some
elements (possibly none) left out. More formally, given a sequence X =
<x1, x2, , xm>, another sequence Z = <z1, z2, , zk> is a subsequence
of X if a strict
Asymptotic Notations
1
= ALGORITHMS =
Websters: or broadly, a step-by-step procedure for solving a
problem or accomplishing some end.
well-defined computational procedure that takes some input and
produces some output. (e.g., searching, sorting)
pseudo
MERGE-SORT
Insertion-Sort: incremental approach
Many useful algorithms (including Merge-Sort):
recursive in structure,
moreover, follow a divide-and-conquer approach.
Divide-and-Conquer Steps at each level of recursion:
1. Divide the problem into smaller
Data Structures for Disjoint Sets
some applications involve grouping n distinct elements into a collection
of disjoint sets. Two important operations are
FIND: finding which set an element belongs to
UNION: uniting two sets
disjoint set data structure:
MINIMUM SPANNING TREES
Application: in the design of electronic circuits, it is often desired to
interconnect the pins of several components using the least amount of
wiring.
Problem: we can model this problem with a connected, undirected
ggraph
p G(V,
Breadth-First Search (BFS)
Expands the frontier between discovered and undiscovered nodes
uniformly across the breadth of the frontier. That is, the algorithm
discovers all nodes at distance k from a source (or root) node s before
discovering any nodes a
Optimal Polygon Triangulation (using Dynamic Programming
approach)
A polygon is a piecewise-linear, closed curve in the plane.
A polygon is simple if it does not cross itself.
A simple polygon is convex if given any two points on its boundary or
in its in
SINGLE-SOURCE SHORTEST PATHS
A driver wants to find the best (shortest) possible route from Chicago to
Boston. Given a road map of the US on which the distances between
adjacent intersections are marked, how can we determine this shortest
route?
How can
ARIZONA STATE UNIVERSITY
CSE 310 Data Structures and Algorithms Spring 2016
Solution to Assignment #1
Pn
1. We are required to prove that for all n 1, i=1 1/2i = 11/2n . The claim is true
n = 1 because in
Pfor
n
this case, both sides of the equation are e
Topological Sort
A topological sort of a dag (directed acyclic graph) G(V, E) is a linear
ordering of all its vertices such that if G contains an edge (u, v) then u
appears before v in the ordering. (If the graph is not acyclic then no
linear ordering is
Red-Black Trees:
Red-Black Tree: a binary search tree with one extra bit of storage per
node; its color which can be either RED or BLACK.
It has the following properties:
1. Every node is either red or black
2. Every leaf node (nil) is black
3. If a node
Matrix Multiplication (using Dynamic Programming approach)
Given n matrices A1, A2, An,
Compute the product A1A2A3 An efficiently.
(Note: matrix multiplication is associative)
A
B =
p0 x p1 p1 x p2
C
p0 x p2
rows[A] = p0, columns[A] = rows[B] = p1, colum
CSE 310
Data Structures and Algorithms
Merge-Sort, Divide-and-conquer, Recurrences
Another algorithm for sorting: Merge Sort
The intuition and the algorithm
The divide-and-conquer approach in general
Analyzing Merge Sort
Analyzing recurrences
1
Lets
CSE 310
Data Structures and Algorithms
Asymptotic Notations
Time complexity of an algorithm revisited
Worst-case running time
Asymptotic running time
Asymptotic notations
Review of commonly-used functions & notations
1
Time complexity of an algorithm
= Graphs =
A graph G = (V, E) (or simply G(V, E) is given by
- set of nodes V
- set of edges E, where E VxV
b
Example:
h
e
a
g
i
j
d
c
Undirected graphs:
no orientation associated with the edges
u
f
v
edge(u, v)
Directed graphs:
each (u, v) E is oriente
= Data Structures for Disjoint Sets =
some applications involve grouping n distinct elements into a
collection of disjoint sets. Two important operations are
FIND: finding which set an element belongs to
UNION: uniting two sets
disjoint set data structu