Ve281 Data Structures and Algorithms
Written Assignment Three
This assignment is announced on Oct. 24th, 2015. It is due by 3:40 pm on
Nov. 6th, 2015. The assignment consists of six problems.
1. A full node in a binary tree is a node with two children. Pr
/
/
/
/
/
/
/
main.cpp
algorithm_dp2
Created by cxy on 2017/3/20.
Copyright 2017 cxy. All rights reserved.
#include <iostream>
#include <fstream>
using namespace std;
int main() cfw_
ifstream fin("data.txt");
int a[60],dp[60],maxx=0,tmp=0;
for(int i=1;i<=
/
/
/
/
/
/
/
main.cpp
dp-S
Created by cxy on 2017/3/21.
Copyright 2017 cxy. All rights reserved.
#include <iostream>
using namespace std;
int main() cfw_
int target=3,j=0;
int sum=0;
int a[30];
int n=11;
int i;
for(i=1;i<=n;i+)
cfw_
cin>a[i];
sum+=a[i];
VE281
Data Structures and Algorithms
Asymptotic Algorithm Analysis
Review
How to measure efficiency of an algorithm?
Wall-clock time
but it depends on processor, compiler, etc.
A key observation: the runtime of the algorithm depends on
the input size.
VE281
Data Structures and Algorithms
Analyze Program;
Sorting
Announcement
Written Assignment One Released
Find the description on Sakai.
Due time: 3:40 pm, Sep. 28th, 2015.
2
Review
Asymptotic Analysis: Big-Oh
Guiding principles on analyzing complex
VE281
Data Structures and Algorithms
Comparison Sort Summary;
Non-comparison Sort
Review
Quick sort: In-place partitioning
Quick sort time complexity
Worst case: ( 2 )
Best case: ( log )
Average case: ( log )
Assume randomly pick an element from the
Lab04-Dynamic Programming
CS214-Algorithm and Complexity, Xiaofeng Gao, Spring 2017
Please upload your assignment to website. Contact john [email protected] for any questions.
Name: Xinyi Chen Student ID:515030910156 Email: [email protected]
1. A Dyck path o
Project1
1. bitAnd(x,y)
description: x & y using only | and ~
solution: This is quite simple. x & y = ~(~x|~y).
Xinyi Chen
515030910156
email:[email protected]
2. getByte(x,n)
description: get byte n from x
solution:1. Do x>(n<3) to make x left shift n*
Ve281 Data Structures and Algorithms
Written Assignment Two
This assignment is announced on Oct. 10th, 2015. It is due by 3:40 pm on
Oct. 23rd, 2015. The assignment consists of five problems.
1. Sort 3, 7, 4, 1, 8, 9, 2, 6, 5, 10 using merge sort. Show th
Ve281 Data Structures and Algorithms
Written Assignment Five
This assignment is announced on Nov. 30th, 2015. It is due by 5:40 pm on
Dec. 9th, 2015. The assignment consists of four problems. For those problems
that ask you to design algorithms, you can e
Ve281 Data Structures and Algorithms
Written Assignment Four
This assignment is announced on Nov. 26th, 2015. It is due by 3:40 pm on Dec.
4th, 2015. The assignment consists of six problems.
1. AVL tree
(a) Suppose that we insert a sequence of keys 2, 1,
Programming Assignment Four: Graph Algorithms
Out: Nov. 27, 2015; Due: Dec. 11, 2015.
I. Motivation
1. To give you experience in implementing a graph data structure using the adjacency list
representation.
2. To give you experience in implementing a few g
Programming Assignment One: Sorting
Out: Sep. 26, 2015; Due: Oct. 10, 2015.
I. Motivation
1. To give you experience in implementing various sorting algorithms.
2. To empirically study the time efficiency of different sorting algorithms.
II. Programming As
Programming Assignment Two: Priority Queue and its Application
Out: October 28, 2015; Due: November 11, 2015.
I.
Motivation
This project will give you experience in implementing priority queues using C+. You will also
empirically study the efficiency of d
Programming Assignment Three: Electronic Trading
Out: November 10, 2015; Due: November 29, 2015.
I. Motivation
1. Get familiar with the various data structures provided by STL: priority
queues (std:priority_queue), hash tables (std:unordered_map,
std:unor
/*
*Lab of Computer Architecture
*
* <Please put your name and userid here>
Name: Xinyi Chen student ID:515030910156
*
* bits.c - Source file with your solutions to the Lab.
*
This is the file you will hand in to your instructor.
*
* WARNING: Do not inclu
VE281
Data Structures and Algorithms
Quick Sort; Comparison Sort Summary
Outline
Quick Sort
Comparison Sort Summary
2
Review: Quick Sort
Choose an array element as pivot.
Put all elements < pivot to the left of pivot.
Put all elements pivot to the ri
VE281
Data Structures and Algorithms
Average-Case Time Complexity of BST;
Other Efficient BST Operations
Review
Binary search tree insertion
Binary search tree removal
Node to be removed is a leaf: Delete the node.
Node to be removed is a degree-one n
VE281
Data Structures and Algorithms
Binary Search Trees
Review: Binary Search Tree
Binary search tree
5
9
3
1
4
Search: recursive procedure
2
7
Outline
BST Insertion and Removal
Analysis of Average-Case Time Complexity
3
Binary Search Tree
Insertion
VE281
Data Structures and Algorithms
Dynamic Programming
Outline
Dynamic Programming
Motivation
Example: Matrix-Chain Multiplication
2
Algorithm Design Methods
We have already learned two ways to design algorithms:
Greedy method.
Divide and conquer.
VE281
Data Structures and Algorithms
Red-black Trees; Graphs
Review
Red-black tree property:
Root rule, red rule, path rule
Claim: Every red-black tree with nodes has height
2 log 2 ( + 1).
Red-black tree insertion
Insert as a leaf.
Color red.
Mov
VE281
Data Structures and Algorithms
Shortest Path
Review
Breadth-First Search
What? Visit all directly connected neighbors first, then nodes 2
hops away, 3 hops away, and so on.
How? Based on a queue.
Time complexity?
Topological Sorting
What?
Onl
VE281
Data Structures and Algorithms
Dynamic Programming
Final Exam
Time: Dec. 14th, 2:00 pm 3:40 pm.
Location: Dong Xia Yuan 104 & 106. More details on Sakai.
A written exam.
Like our written assignments.
Pseudo-code OK (but make sure we can underst