GRAPH ALGORITHMS
BASICS
Graph: G = cfw_V, E
V =cfw_v1, v2, , vn, E = cfw_e1, e2, em, eij=(vi, vj, lij)
A set of n nodes/vertices, and m edges/arcs as pairs of nodes:
Problem sizes: n, m
When lij is present, it is a label, if it is a number it is the
w
Three background concepts:
1.Decision Problems: output yes/no
2. Nondeterministic algorithm: certificate additional input
3. Polynomial transformation: one problem input to
another type problem input in poly-time
(C) Debasis Mitra
1. DECISION PROBLEMS
De
ALGORITHM TYPES
Divide and Conquer, Dynamic Programming, Greedy,
and Backtracking
Note the general strategy from the examples
The classification is neither exhaustive (there may be
other types), nor mutually exclusive (one may
combine)
PROBLEM 1: DYNAM
LINEAR PROGRAMMING
Modeling a problem is boring
- and a distraction from studying the abstract form!
However, modeling is very important:
- for your motivation,
- and for your training on how to use the theory on a real
application!
Read the text bo
Polynomial Multiplication with
Discrete Fourier Transform
Fast Fourier Transform
09/02/17
FFT
1
Signal
Amplitude or
Intensity of, e.g.
Voltage
Time
09/02/17
FFT
2
Signal as a linear combination of
sinusoidal waves
Cos(wt) + i sin(wt)
= ei t 2Pi/n, w=2Pi/n
ALGORITHM TYPES
Divide and Conquer, Dynamic Programming,
Backtracking, and Greedy.
Note the general strategy from the examples.
The classification is neither exhaustive (there may be
more) nor mutually exclusive (one may combine).
Sep'17, 2014
(C) Deba
ALGORITHM TYPES
Divide and Conquer, Dynamic Programming,
Backtracking, and Greedy.
Note the general strategy from the examples.
The classification is neither exhaustive (there may be
more) nor mutually exclusive (one may combine).
Backtracking Algorith
Intro to Analysis of Algorithms
CSE 4081
VERSION
UG
Fall 2014
Exam 2
Points 34
Time 60 min
ANSWERS ARE TO BE CRISP ONE NUMBER/WORD/PHRASE,
ONLY ON THE ANSWER SHEET PROVIDED: NO PARTIAL GRADING
[Students ignore these key words: Foundations, Problem solving
Introduction to Analysis of Algorithms
CSE 4081
YOUR NAME:
Fall 2014
Exam 3
Points 40
Time 60 min
ANSWERS ARE TO BE CRISP, ONLY ON THE ANSWER SHEET PROVIDED.
[Students ignore these key words: Foundations, Problem solving, Algorithm
understanding.]
1a
2
1b
Task 6: Draw the flowchart of a program that reads two numbers from the user. Your program should
then print first is greater if the first number is greater, second is greater if the second number is
greater, and the numbers are equal otherwise.
start
pro
Task 7: Draw the flowchart of a program that reads two numbers, subtracts the smaller number from the
larger one, and prints the result.
start
prompt a
read a
prompt b
read b
A>b
sum = a - b
Sum = b-a
print sum
stop
Task 3: Draw the flowchart of a program that reads the radius of a circle and prints its circumference and
area. (Area = PI*r^2, Circumference = 2*PI*r)
start
prompt r
read r
area = PI * r ^ 2
circumference = 2 * PI* r
print area
print circumference
start
Task 5: Draw the flowchart of a program that reads two numbers from the user. Your program should
then print first is greater if the first number is greater, and first is not greater otherwise.
start
prompt a
read a
prompt b
read b
A>b
Print First is grea
Task 9: Draw the flowchart of a program that reads two numbers, subtracts the second number from the
first number if the first number is greater and prints the result and then print MINUS, otherwise adds
the numbers and print the result and then print ADD
Task 8: Draw the flowchart of a program that reads a number, and prints The number is even or The
number is odd, depending on whether the number is even or odd. (Hint: use the modulus operator)
start
prompt x
read x
x%2= = 0
Print The number is even
Print
Task 4: Draw the flowchart of a program that reads two numbers from the user and prints first if the
first number is greater than the second number.
start
prompt a
read a
prompt b
read b
A>b
Print First
stop
Task 2: Draw the flowchart of a program that reads two numbers from the user, and prints their sum,
product and difference.
start
prompt x
read x
prompt y
read y
Sum1 = x + y
Sum2 = x - y
Sum3 = x * y
print sum1
print sum2
print sum3
stop
Task 1: Draw the flowchart of a program that reads one number from the user, and prints it back to show
which number was entered by the user.
start
prompt n
read n
print n
stop
Task 10: Draw the flowchart of a program that asks the user his age. Your program should print You are
adult if the input is greater than 20, You are young otherwise.
start
prompt age
read age
age > 20
print You are adult
print You are young
stop
Programming Assignment #1: Six Days of Christmas (15 points)
Program Description:
This program tests your understanding of using static methods and println statements. You
should write a Java class called SixDays that should be saved into a file called Si
/ This program calculates tutition bills as credits times rate per credit hour
public class FixDebugThree4 /class header
cfw_ / open class
public static void main(String args[]) /main method header
cfw_ / opens the main method
/ int myCredits = 13 ass
#include<iostream>
int main ()
cfw_
double k,m;
char choice;
cout < "conversion temperature Program\n";
cout < "enter the temprature in k=";
cout < "or the temprature in m=";
cin > choice;
if (choice ='k')
cfw_
cout < "enter the temprature in k=";
cin > m
#include<iostream>
int main ()
cfw_
double e;
cout < "enter the level of the earthquake=";
cin > e;
if (e ='8')
cout < "most structures Fail"<e;
else
if (e ='7')
cout < "Many buildings destroyed"<e;
else
if (e ='6')
cout < "many buildings considerably dam
/*
time
CSE-1502 Section 3
distance.cpp
Purpose: calculates the distance that an object would freefall in that
@author Boyu Zhang
@date 9/2/2016
*/
/
#include <iostream>
using namespace std;
int main ()
cfw_
double a, t, Distance;
cout <"Enter the value o
#include <iostream>
using namespace std;
int main ()
cfw_
int count;
cout <"Enter number of students=>";
cin > count;
cout <"Introduction to Software Development with C+\n";
cout <"CSE 1502, Augest 24,2016\n";
cout <"Section 1: -M Scott -\n";
cout <"Lectu
/*
CSE-1502 Section 3
distance.cpp
Purpose: Use linear interpolation to compute a new freezing temperature
for water with a specified salinity
@author Boyu Zhang
@date 9/9/2016
*/
/
#include <iostream>
using namespace std;
int main ()
cfw_
double fb,b,a,f
#include <iostream>
using namespace std;
int main ()
cfw_
cout
<*
*\n";
cout <"
!\n";
c
cout <"
!\n";
c
cout <
!\n";
c
cout <
\n";
cout <
00\n";
s
c
c
cout <
!\n";
cout <
!\n";
c
c
cout <"
!\n";
cout <
!\n";
c
s
s
s
s
s
s
s
s s
s
s
c
s
c
s
c
c
c
c
c
s
s
s
/*
CSE-1502 Section 3
lab2.cpp
Purpose: transmit data over the telephone
@author Boyu Zhang
@date 9/16/2016
*/
/
#include <iostream>
using namespace std;
int main()
cfw_
int first, second, third, fourth, temp, a;
cout < "Enter a four digit encrypted numbe