This document discusses pointer analysis techniques for determining how pointers may be aliased in a program. It begins with an introduction to pointers and examples of pointer aliasing. It then discusses challenges in pointer analysis like approximation and undecidability. The document covers specific pointer analysis algorithms like may-alias analysis and different approaches to abstracting the heap and control flow, including flow-insensitive and context-insensitive techniques. It also provides examples of applying pointer analysis rules and points-to graph representations. Finally, it discusses ways to classify pointer analysis algorithms based on properties like flow-sensitivity and context-sensitivity as well as common heap abstraction schemes.
The document discusses functional programming concepts in Scala including creating immutable objects to represent rational numbers, using pattern matching to add rationals, and defining classes with private fields and auxiliary constructors while avoiding side effects through immutable and functional design. It provides examples of functional programming techniques like creating rational number objects that are immutable and can be freely passed around without risk of mutation, and defining methods as functions that take arguments instead of mutating object state.
Please implement in Java. comments would be appreciated 5.pdffms12345
Please i need help with these question, thanks.
4.) What is Total Revenue and How is it calculated (formula)? MacBook Air
Solution
Total revenue is the sum of the revenue generated by selling each unit of good. It is the revenues
which are generated by selling given level of input.
Total revenue can be computed by adding up Marginal revenue generated from selling each
additional unit of good.
Therefore, the Total revenue = MR1+MR2+MR3+MR4+.... MRn.
This document discusses first-class functions and lambda calculus. It begins with an overview of Alonzo Church and the origins of lambda calculus. It then covers first-class functions in JavaScript, functions as objects in Java, and first-class functions in Scala. The document also discusses generic higher-order functions and control abstraction.
Computer Graphics in Java and Scala - Part 1bPhilip Schwarz
First see the Scala program from Part 1 translated into Java.
Then see the Scala program modified to produce a more intricate drawing.
Java Code: https://github.com/philipschwarz/computer-graphics-50-triangles-java
Scala Code: https://github.com/philipschwarz/computer-graphics-chessboard-with-a-great-many-squares-scala
Here are the steps to solve this problem numerically in MATLAB:
1. Define the 2nd order ODE for the pendulum as two first order equations:
y1' = y2
y2' = -sin(y1)
2. Create an M-file function pendulum.m that returns the right hand side:
function dy = pendulum(t,y)
dy = [y(2); -sin(y(1))];
end
3. Use an ODE solver like ode45 to integrate from t=0 to t=6pi with initial conditions y1(0)=pi, y2(0)=0:
[t,y] = ode45
This presentation explains the difference between concurrency and parallelism, and how could we make parallel computations and how could we design an API for parallel computation following the structure presented in the Functional Programming in Scala book
This document discusses monads and continuations in functional programming. It provides examples of using monads like Option and List to handle failure in sequences of operations. It also discusses delimited continuations as a low-level control flow primitive that can implement exceptions, concurrency, and suspensions. The document proposes using monads to pass implicit state through programs by wrapping computations in a state transformer (ST) monad.
The document discusses functional programming concepts in Scala including creating immutable objects to represent rational numbers, using pattern matching to add rationals, and defining classes with private fields and auxiliary constructors while avoiding side effects through immutable and functional design. It provides examples of functional programming techniques like creating rational number objects that are immutable and can be freely passed around without risk of mutation, and defining methods as functions that take arguments instead of mutating object state.
Please implement in Java. comments would be appreciated 5.pdffms12345
Please i need help with these question, thanks.
4.) What is Total Revenue and How is it calculated (formula)? MacBook Air
Solution
Total revenue is the sum of the revenue generated by selling each unit of good. It is the revenues
which are generated by selling given level of input.
Total revenue can be computed by adding up Marginal revenue generated from selling each
additional unit of good.
Therefore, the Total revenue = MR1+MR2+MR3+MR4+.... MRn.
This document discusses first-class functions and lambda calculus. It begins with an overview of Alonzo Church and the origins of lambda calculus. It then covers first-class functions in JavaScript, functions as objects in Java, and first-class functions in Scala. The document also discusses generic higher-order functions and control abstraction.
Computer Graphics in Java and Scala - Part 1bPhilip Schwarz
First see the Scala program from Part 1 translated into Java.
Then see the Scala program modified to produce a more intricate drawing.
Java Code: https://github.com/philipschwarz/computer-graphics-50-triangles-java
Scala Code: https://github.com/philipschwarz/computer-graphics-chessboard-with-a-great-many-squares-scala
Here are the steps to solve this problem numerically in MATLAB:
1. Define the 2nd order ODE for the pendulum as two first order equations:
y1' = y2
y2' = -sin(y1)
2. Create an M-file function pendulum.m that returns the right hand side:
function dy = pendulum(t,y)
dy = [y(2); -sin(y(1))];
end
3. Use an ODE solver like ode45 to integrate from t=0 to t=6pi with initial conditions y1(0)=pi, y2(0)=0:
[t,y] = ode45
This presentation explains the difference between concurrency and parallelism, and how could we make parallel computations and how could we design an API for parallel computation following the structure presented in the Functional Programming in Scala book
This document discusses monads and continuations in functional programming. It provides examples of using monads like Option and List to handle failure in sequences of operations. It also discusses delimited continuations as a low-level control flow primitive that can implement exceptions, concurrency, and suspensions. The document proposes using monads to pass implicit state through programs by wrapping computations in a state transformer (ST) monad.
This document discusses three functional patterns: continuations, format combinators, and nested data types. It provides examples of each pattern in Scala. Continuations are represented using explicit continuation-passing style and delimited control operators. Format combinators represent formatted output as typed combinators rather than untyped strings. Nested data types generalize recursive data types to allow the type parameter of recursive invocations to differ, as in square matrices represented as a nested data type. The document concludes by drawing an analogy between fast exponentiation and representing square matrices as a nested data type.
This document summarizes the major changes in ECMAScript 6 (ES6), also known as ECMAScript 2015. Some key changes include the introduction of classes, modules, iterators, generators, default parameters, rest parameters, arrow functions, new data structures like Map and Set, string padding capabilities, template literals, and new numeric literal syntaxes for binary, octal and Unicode characters. ES6 aims to make JavaScript code more modular and reusable through these new features.
Principles of functional progrmming in scalaehsoon
a short outline on necessity of functional programming and principles of functional programming in Scala.
In the article some keyword are used but not explained (to keep the article short and simple), the interested reader can look them up in internet.
Function Programming in Scala.
A lot of my examples here comes from the book
Functional programming in Scala By Paul Chiusano and Rúnar Bjarnason, It is a good book, buy it.
This document discusses social network analysis in Python. It begins with an introduction and outline. It then covers topics like data representation using graphs, network properties measured at the network, group, and node level, and visualization. Network properties include characteristic path length, clustering coefficient, degree distribution, and more. Representations include adjacency matrices, incidence matrices, adjacency lists, and incidence lists. NetworkX is highlighted as a tool for working with graphs in Python.
This document contains a student assignment submission for a course on Perspective in Informatics. It includes the student's responses to 3 questions:
1) Analyzing different functions to determine if they satisfy the properties of a distance measure, including max(x,y), diff(x,y), and sum(x,y).
2) Computing sketches of vectors using different random vectors and analyzing the estimated vs. true angles between the vectors.
3) Calculating the expected Jaccard similarity of two randomly selected subsets R and S of a universe U with n elements and size m.
I am Josh U. I am a Python Homework Expert at pythonhomeworkhelp.com. I hold a Master's in Computer Science from, the University of Warwicks. I have been helping students with their homework for the past 13 years. I solve homework related to Python.
Visit pythonhomeworkhelp.com or email support@pythonhomeworkhelp.com. You can also call on +1 678 648 4277 for any assistance with Python Homework.
This document discusses fundamental concepts in data structures and algorithms including:
1) How to design algorithms by analyzing requirements, designing data objects and operations, and refining and coding programs.
2) Key criteria for algorithms including being unambiguous, terminating in a finite number of steps, and having basic instructions.
3) Abstract data types which separate the specification of objects and operations from their implementation.
4) Asymptotic analysis which classifies algorithms according to how their running time grows relative to the input size.
This document discusses fundamental concepts in data structures and algorithms including:
1) How to design algorithms by analyzing requirements, designing data objects and operations, and refining and coding programs.
2) Key criteria for algorithms including being input/output defined, unambiguous, and able to terminate in a finite number of steps.
3) How abstract data types specify objects and operations separately from implementation.
4) Examples of analyzing time and space complexity for different algorithms including iterative and recursive solutions.
5) Common asymptotic notations like O(1), O(n), O(n^2), and O(nlogn) and how they describe an algorithm's growth rate.
Create a java project that - Draw a circle with three random init.pdfarihantmobileselepun
Create a java project that:
- Draw a circle with three random initial points on the circle.
- Link the points to form a triangle.
- Print the angles values in the triangle.
- Use the mouse to drag a point along the perimeter of the circle. As you drag it, the triangle and
angles are redisplayed dynamically.
Here is the formula to compute angles:
A = acos((a * a - b * b - c * c) / (-2 * b * c))
B = acos((b * b - a * a - c * c) / (-2 * a * c))
C = acos((c * c - b * b - a * a) / (-2 * a * b))
Solution
@Suppresswarnings(\"WeakerAccess\")
public class DragPoints extends Application {
@Override
public void start(Stage primaryStage) {
final PointPane pane = new PointPane(640, 480);
pane.setStyle(\"-fx-background-color: wheat;\");
Label label = new Label(\"Click and drag the points.\");
BorderPane borderPane = new BorderPane(pane);
BorderPane.setAlignment(label, Pos.CENTER);
label.setPadding(new Insets(5));
borderPane.setBottom(label);
Scene scene = new Scene(borderPane);
primaryStage.setTitle(\"Exercise15_21\");
primaryStage.setScene(scene);
primaryStage.show();
}
private class PointPane extends Pane {
final Circle circle = new Circle();
final Vertex[] v = new Vertex[3];
final int strokeWidth = 2;
final Color circleStroke = Color.GRAY, legStroke = Color.BLACK;
@SuppressWarnings(\"SameParameterValue\")
PointPane(double w, double h) {
this.setPrefSize(w, h);
this.setWidth(w);
this.setHeight(h);
circle.setStroke(circleStroke);
circle.setFill(Color.TRANSPARENT);
circle.setStrokeWidth(strokeWidth);
circle.radiusProperty().bind(this.heightProperty().multiply(0.4));
circle.centerXProperty().bind(this.widthProperty().divide(2));
circle.centerYProperty().bind(this.heightProperty().divide(2));
this.getChildren().add(circle);
for (int i = 0; i < v.length; i++) {
v[i] = new Vertex(circle, 2 * Math.PI / v.length * (i + Math.random()));
v[i].radiusProperty().bind(circle.radiusProperty().divide(10));
v[i].setPosition();
v[i].setStroke(new Color(i == 0 ? 1 : 0, i == 1 ? 1 : 0, i == 2 ? 1 : 0, 1));
v[i].setFill(Color.TRANSPARENT);
v[i].setStrokeWidth(strokeWidth);
this.getChildren().add(v[i]);
v[i].setOnMouseDragged(new EventHandler() {
@Override
public void handle(MouseEvent event) {
int i;
for (i = 0; i < v.length; i++)
if (v[i] == event.getSource())
break;
v[i].setAngle(event.getX(), event.getY());
moveUpdate((Vertex) event.getSource());
}
});
}
for (int i = 0; i < v.length; i++) {
int j = i + 1 < v.length ? i + 1 : 0;
int k = j + 1 < v.length ? j + 1 : 0;
v[i].bindLeg(v[j], v[k]);
v[i].leg.setStroke(legStroke);
v[i].leg.setStrokeWidth(strokeWidth);
this.getChildren().add(v[i].leg);
this.getChildren().add(v[i].text);
}
for(DoubleProperty p: new DoubleProperty[]
{circle.radiusProperty(), circle.centerXProperty(), circle.centerYProperty()})
p.addListener(new ResizeListener());
moveUpdate(v[0]);
}
void moveUpdate(Vertex vert) {
vert.setPosition();
double[] legLength = new double[3];
for (int i = 0; i < v.length; i++)
legLength[i] = v[i].getLegLength();
for (int i = .
b. (10 pts) Implement the rotate left method for AVL trees.c. (10 .pdfakanshanawal
b. (10 pts) Implement the rotate left method for AVL trees.
c. (10 pts) Implement the rotate right method for AVL trees.
d. (10 pts) Implement the rotate left-right method for AVL trees.
e. (10 pts) Implement the rotate right-left method for AVL trees.
f. (15 pts) Implement the rebalance method for AVL trees.
g. (3 pts) Implement pre-order, in-order, and post-order traversals for AVL trees.
All of this should be implemented in the below code, in C++, without changing any of the
parameters or functions as they are laid out.
#include
#include
#include "AVLTree.h"
#include "AVLNode.h"
using namespace std;
AVLTree::AVLTree() {
root = nullptr;
size = 0;
}
std::shared_ptr AVLTree::getRoot() {
return root;
}
int AVLTree::getSize() {
return size;
}
std::shared_ptr AVLTree::search(int val) {
return search(root, val);
}
std::shared_ptr AVLTree::search(std::shared_ptr n, int val) {
if (n == NULL) //if root node is null just return null value
{
return n;
}
//if target is less than root's value search in left half
if (val < n->value)
{
return search(n->left, val);
}
//if target is greater than root's value search in right half
else if (val > n->value)
{
return search(n->right, val);
}
//else if target is equal to root node just return the root node i.e n.
return n;
}
std::shared_ptr AVLTree::minimum() {
std::shared_ptr curr = root;
while (curr && curr->left) {
curr = curr->left;
}
return curr;
}
std::shared_ptr AVLTree::minimum(std::shared_ptr n) {
std::shared_ptr curr = n;
while (curr && curr->left) {
curr = curr->left;
}
return curr;
}
std::shared_ptr AVLTree::maximum() {
std::shared_ptr curr = root;
while (curr && curr->right) {
curr = curr->right;
}
return curr;
}
std::shared_ptr AVLTree::maximum(std::shared_ptr n) {
std::shared_ptr curr = n;
while (curr && curr->right) {
curr = curr->right;
}
return curr;
}
int getHeight(std::shared_ptr n) {
if (n == nullptr) {
return -1;
}
return n->height;
}
int getBalanceFactor(std::shared_ptr n) {
if (n == nullptr) {
return 0;
}
return getHeight(n->left) - getHeight(n->right);
}
void AVLTree::insertValue(int val) {
root = insertValue(root, val);
}
std::shared_ptr AVLTree::insertValue(std::shared_ptr n, int val) {
if (n == nullptr) {
shared_ptr newNode(new AVLNode(val));
size++;
return newNode;
}
if (val < n->value) {
n->left = insertValue(n->left, val);
}
else if (val > n->value) {
n->right = insertValue(n->right, val);
}
else {
// Duplicate value, no change
return n;
}
// Update the height of the current node
n->height = 1 + max(getHeight(n->left), getHeight(n->right));
// Rebalance the node if necessary
return rebalance(n);
}
void AVLTree::deleteValue(int val) {
root = deleteValue(root, val);
}
std::shared_ptr AVLTree::deleteValue(std::shared_ptr n, int val) {
if (n == nullptr) {
return nullptr;
}
if (val < n->value) {
n->left = deleteValue(n->left, val);
}
else if (val > n->value) {
n->right = deleteValue(n->right, val);
}
else {
// Found the value to delete
if (n->left == nullptr && n->right == nullptr) {
// .
Introduction to Neural Networks and Deep Learning from ScratchAhmed BESBES
If you're willing to understand how neural networks work behind the scene and debug the back-propagation algorithm step by step by yourself, this presentation should be a good starting point.
We'll cover elements on:
- the popularity of neural networks and their applications
- the artificial neuron and the analogy with the biological one
- the perceptron
- the architecture of multi-layer perceptrons
- loss functions
- activation functions
- the gradient descent algorithm
At the end, there will be an implementation FROM SCRATCH of a fully functioning neural net.
code: https://github.com/ahmedbesbes/Neural-Network-from-scratch
The document discusses various math and string classes in Java. It covers:
- Constructing objects using the new operator and passing parameters.
- Using the Random class to generate random numbers.
- Declaring constants using final and static final.
- Basic arithmetic, increment/decrement, and math methods.
- Creating and manipulating strings using methods like length(), substring(), and concatenation.
- Drawing shapes on a frame using Graphics2D methods in a JComponent's paintComponent method.
The document discusses recursion, including:
1) Recursion involves breaking a problem down into smaller subproblems until a base case is reached, then building up the solution to the overall problem from the solutions to the subproblems.
2) A recursive function is one that calls itself, with each call typically moving closer to a base case where the problem can be solved without recursion.
3) Recursion can be linear, involving one recursive call, or binary, involving two recursive calls to solve similar subproblems.
I am Jayson L. I am a Signals and Systems Homework Expert at matlabassignmentexperts.com. I hold a Master's in Matlab, from the University of Sheffield. I have been helping students with their homework for the past 7 years. I solve homework related to Signals and Systems.
Visit matlabassignmentexperts.com or email info@matlabassignmentexperts.com.
You can also call on +1 678 648 4277 for any assistance with Signals and Systems homework.
The document discusses techniques for line drawing and generalization in computer graphics. It covers Bresenham's line drawing algorithm, which uses only integer arithmetic for efficiency. It also discusses circle drawing using the midpoint circle algorithm and extensions to draw ellipses. Anti-aliasing techniques like area sampling are introduced to reduce jagged edges when rasterizing lines.
This document discusses vectorized code in MATLAB. It covers operations on vectors and matrices such as addition, subtraction, and multiplication. It discusses using vectors and matrices as function arguments and performing element-wise operations. It also covers logical vectors and examples of vectorizing code using loops to perform operations such as finding maximum/minimum values, counting elements, and comparing elements in less than 3 sentences.
Frequency Response with MATLAB Examples.pdfSunil Manjani
The document discusses frequency response analysis and control system design. It introduces frequency response, defines it as the steady-state response of a system to a sinusoidal input in terms of gain and phase lag. Bode diagrams are presented as a tool to graphically analyze the frequency response from a transfer function or experimentally. MATLAB functions like tf() and bode() are used to define transfer functions and plot Bode diagrams from the frequency response. Discrete-time PID and PI controller implementations and state-space models are also covered.
This document discusses reasons for poor software quality and characteristics of companies with low quality standards ("quality laggards"). It then outlines categories of quality attributes from both product-specific and organization-specific perspectives. Finally, it discusses approaches that leading companies use to achieve high levels of software quality, such as enterprise-wide quality programs, formal inspections, specialized testing teams, and executive support for quality initiatives.
This document discusses software defects, including what they are, where they originate, and how they can be eliminated. It defines a software defect as an error, flaw, or fault that prevents software from functioning as intended. Defects are introduced during requirements, design, coding, documentation, testing, and other phases. They can have varying effects from minor issues to system crashes or security vulnerabilities. The document outlines inspection and testing methods for removing defects, noting that requirements and design defects are particularly difficult to fix. It aims to provide an overview of software defects before discussing topics in more depth later.
This document discusses three functional patterns: continuations, format combinators, and nested data types. It provides examples of each pattern in Scala. Continuations are represented using explicit continuation-passing style and delimited control operators. Format combinators represent formatted output as typed combinators rather than untyped strings. Nested data types generalize recursive data types to allow the type parameter of recursive invocations to differ, as in square matrices represented as a nested data type. The document concludes by drawing an analogy between fast exponentiation and representing square matrices as a nested data type.
This document summarizes the major changes in ECMAScript 6 (ES6), also known as ECMAScript 2015. Some key changes include the introduction of classes, modules, iterators, generators, default parameters, rest parameters, arrow functions, new data structures like Map and Set, string padding capabilities, template literals, and new numeric literal syntaxes for binary, octal and Unicode characters. ES6 aims to make JavaScript code more modular and reusable through these new features.
Principles of functional progrmming in scalaehsoon
a short outline on necessity of functional programming and principles of functional programming in Scala.
In the article some keyword are used but not explained (to keep the article short and simple), the interested reader can look them up in internet.
Function Programming in Scala.
A lot of my examples here comes from the book
Functional programming in Scala By Paul Chiusano and Rúnar Bjarnason, It is a good book, buy it.
This document discusses social network analysis in Python. It begins with an introduction and outline. It then covers topics like data representation using graphs, network properties measured at the network, group, and node level, and visualization. Network properties include characteristic path length, clustering coefficient, degree distribution, and more. Representations include adjacency matrices, incidence matrices, adjacency lists, and incidence lists. NetworkX is highlighted as a tool for working with graphs in Python.
This document contains a student assignment submission for a course on Perspective in Informatics. It includes the student's responses to 3 questions:
1) Analyzing different functions to determine if they satisfy the properties of a distance measure, including max(x,y), diff(x,y), and sum(x,y).
2) Computing sketches of vectors using different random vectors and analyzing the estimated vs. true angles between the vectors.
3) Calculating the expected Jaccard similarity of two randomly selected subsets R and S of a universe U with n elements and size m.
I am Josh U. I am a Python Homework Expert at pythonhomeworkhelp.com. I hold a Master's in Computer Science from, the University of Warwicks. I have been helping students with their homework for the past 13 years. I solve homework related to Python.
Visit pythonhomeworkhelp.com or email support@pythonhomeworkhelp.com. You can also call on +1 678 648 4277 for any assistance with Python Homework.
This document discusses fundamental concepts in data structures and algorithms including:
1) How to design algorithms by analyzing requirements, designing data objects and operations, and refining and coding programs.
2) Key criteria for algorithms including being unambiguous, terminating in a finite number of steps, and having basic instructions.
3) Abstract data types which separate the specification of objects and operations from their implementation.
4) Asymptotic analysis which classifies algorithms according to how their running time grows relative to the input size.
This document discusses fundamental concepts in data structures and algorithms including:
1) How to design algorithms by analyzing requirements, designing data objects and operations, and refining and coding programs.
2) Key criteria for algorithms including being input/output defined, unambiguous, and able to terminate in a finite number of steps.
3) How abstract data types specify objects and operations separately from implementation.
4) Examples of analyzing time and space complexity for different algorithms including iterative and recursive solutions.
5) Common asymptotic notations like O(1), O(n), O(n^2), and O(nlogn) and how they describe an algorithm's growth rate.
Create a java project that - Draw a circle with three random init.pdfarihantmobileselepun
Create a java project that:
- Draw a circle with three random initial points on the circle.
- Link the points to form a triangle.
- Print the angles values in the triangle.
- Use the mouse to drag a point along the perimeter of the circle. As you drag it, the triangle and
angles are redisplayed dynamically.
Here is the formula to compute angles:
A = acos((a * a - b * b - c * c) / (-2 * b * c))
B = acos((b * b - a * a - c * c) / (-2 * a * c))
C = acos((c * c - b * b - a * a) / (-2 * a * b))
Solution
@Suppresswarnings(\"WeakerAccess\")
public class DragPoints extends Application {
@Override
public void start(Stage primaryStage) {
final PointPane pane = new PointPane(640, 480);
pane.setStyle(\"-fx-background-color: wheat;\");
Label label = new Label(\"Click and drag the points.\");
BorderPane borderPane = new BorderPane(pane);
BorderPane.setAlignment(label, Pos.CENTER);
label.setPadding(new Insets(5));
borderPane.setBottom(label);
Scene scene = new Scene(borderPane);
primaryStage.setTitle(\"Exercise15_21\");
primaryStage.setScene(scene);
primaryStage.show();
}
private class PointPane extends Pane {
final Circle circle = new Circle();
final Vertex[] v = new Vertex[3];
final int strokeWidth = 2;
final Color circleStroke = Color.GRAY, legStroke = Color.BLACK;
@SuppressWarnings(\"SameParameterValue\")
PointPane(double w, double h) {
this.setPrefSize(w, h);
this.setWidth(w);
this.setHeight(h);
circle.setStroke(circleStroke);
circle.setFill(Color.TRANSPARENT);
circle.setStrokeWidth(strokeWidth);
circle.radiusProperty().bind(this.heightProperty().multiply(0.4));
circle.centerXProperty().bind(this.widthProperty().divide(2));
circle.centerYProperty().bind(this.heightProperty().divide(2));
this.getChildren().add(circle);
for (int i = 0; i < v.length; i++) {
v[i] = new Vertex(circle, 2 * Math.PI / v.length * (i + Math.random()));
v[i].radiusProperty().bind(circle.radiusProperty().divide(10));
v[i].setPosition();
v[i].setStroke(new Color(i == 0 ? 1 : 0, i == 1 ? 1 : 0, i == 2 ? 1 : 0, 1));
v[i].setFill(Color.TRANSPARENT);
v[i].setStrokeWidth(strokeWidth);
this.getChildren().add(v[i]);
v[i].setOnMouseDragged(new EventHandler() {
@Override
public void handle(MouseEvent event) {
int i;
for (i = 0; i < v.length; i++)
if (v[i] == event.getSource())
break;
v[i].setAngle(event.getX(), event.getY());
moveUpdate((Vertex) event.getSource());
}
});
}
for (int i = 0; i < v.length; i++) {
int j = i + 1 < v.length ? i + 1 : 0;
int k = j + 1 < v.length ? j + 1 : 0;
v[i].bindLeg(v[j], v[k]);
v[i].leg.setStroke(legStroke);
v[i].leg.setStrokeWidth(strokeWidth);
this.getChildren().add(v[i].leg);
this.getChildren().add(v[i].text);
}
for(DoubleProperty p: new DoubleProperty[]
{circle.radiusProperty(), circle.centerXProperty(), circle.centerYProperty()})
p.addListener(new ResizeListener());
moveUpdate(v[0]);
}
void moveUpdate(Vertex vert) {
vert.setPosition();
double[] legLength = new double[3];
for (int i = 0; i < v.length; i++)
legLength[i] = v[i].getLegLength();
for (int i = .
b. (10 pts) Implement the rotate left method for AVL trees.c. (10 .pdfakanshanawal
b. (10 pts) Implement the rotate left method for AVL trees.
c. (10 pts) Implement the rotate right method for AVL trees.
d. (10 pts) Implement the rotate left-right method for AVL trees.
e. (10 pts) Implement the rotate right-left method for AVL trees.
f. (15 pts) Implement the rebalance method for AVL trees.
g. (3 pts) Implement pre-order, in-order, and post-order traversals for AVL trees.
All of this should be implemented in the below code, in C++, without changing any of the
parameters or functions as they are laid out.
#include
#include
#include "AVLTree.h"
#include "AVLNode.h"
using namespace std;
AVLTree::AVLTree() {
root = nullptr;
size = 0;
}
std::shared_ptr AVLTree::getRoot() {
return root;
}
int AVLTree::getSize() {
return size;
}
std::shared_ptr AVLTree::search(int val) {
return search(root, val);
}
std::shared_ptr AVLTree::search(std::shared_ptr n, int val) {
if (n == NULL) //if root node is null just return null value
{
return n;
}
//if target is less than root's value search in left half
if (val < n->value)
{
return search(n->left, val);
}
//if target is greater than root's value search in right half
else if (val > n->value)
{
return search(n->right, val);
}
//else if target is equal to root node just return the root node i.e n.
return n;
}
std::shared_ptr AVLTree::minimum() {
std::shared_ptr curr = root;
while (curr && curr->left) {
curr = curr->left;
}
return curr;
}
std::shared_ptr AVLTree::minimum(std::shared_ptr n) {
std::shared_ptr curr = n;
while (curr && curr->left) {
curr = curr->left;
}
return curr;
}
std::shared_ptr AVLTree::maximum() {
std::shared_ptr curr = root;
while (curr && curr->right) {
curr = curr->right;
}
return curr;
}
std::shared_ptr AVLTree::maximum(std::shared_ptr n) {
std::shared_ptr curr = n;
while (curr && curr->right) {
curr = curr->right;
}
return curr;
}
int getHeight(std::shared_ptr n) {
if (n == nullptr) {
return -1;
}
return n->height;
}
int getBalanceFactor(std::shared_ptr n) {
if (n == nullptr) {
return 0;
}
return getHeight(n->left) - getHeight(n->right);
}
void AVLTree::insertValue(int val) {
root = insertValue(root, val);
}
std::shared_ptr AVLTree::insertValue(std::shared_ptr n, int val) {
if (n == nullptr) {
shared_ptr newNode(new AVLNode(val));
size++;
return newNode;
}
if (val < n->value) {
n->left = insertValue(n->left, val);
}
else if (val > n->value) {
n->right = insertValue(n->right, val);
}
else {
// Duplicate value, no change
return n;
}
// Update the height of the current node
n->height = 1 + max(getHeight(n->left), getHeight(n->right));
// Rebalance the node if necessary
return rebalance(n);
}
void AVLTree::deleteValue(int val) {
root = deleteValue(root, val);
}
std::shared_ptr AVLTree::deleteValue(std::shared_ptr n, int val) {
if (n == nullptr) {
return nullptr;
}
if (val < n->value) {
n->left = deleteValue(n->left, val);
}
else if (val > n->value) {
n->right = deleteValue(n->right, val);
}
else {
// Found the value to delete
if (n->left == nullptr && n->right == nullptr) {
// .
Introduction to Neural Networks and Deep Learning from ScratchAhmed BESBES
If you're willing to understand how neural networks work behind the scene and debug the back-propagation algorithm step by step by yourself, this presentation should be a good starting point.
We'll cover elements on:
- the popularity of neural networks and their applications
- the artificial neuron and the analogy with the biological one
- the perceptron
- the architecture of multi-layer perceptrons
- loss functions
- activation functions
- the gradient descent algorithm
At the end, there will be an implementation FROM SCRATCH of a fully functioning neural net.
code: https://github.com/ahmedbesbes/Neural-Network-from-scratch
The document discusses various math and string classes in Java. It covers:
- Constructing objects using the new operator and passing parameters.
- Using the Random class to generate random numbers.
- Declaring constants using final and static final.
- Basic arithmetic, increment/decrement, and math methods.
- Creating and manipulating strings using methods like length(), substring(), and concatenation.
- Drawing shapes on a frame using Graphics2D methods in a JComponent's paintComponent method.
The document discusses recursion, including:
1) Recursion involves breaking a problem down into smaller subproblems until a base case is reached, then building up the solution to the overall problem from the solutions to the subproblems.
2) A recursive function is one that calls itself, with each call typically moving closer to a base case where the problem can be solved without recursion.
3) Recursion can be linear, involving one recursive call, or binary, involving two recursive calls to solve similar subproblems.
I am Jayson L. I am a Signals and Systems Homework Expert at matlabassignmentexperts.com. I hold a Master's in Matlab, from the University of Sheffield. I have been helping students with their homework for the past 7 years. I solve homework related to Signals and Systems.
Visit matlabassignmentexperts.com or email info@matlabassignmentexperts.com.
You can also call on +1 678 648 4277 for any assistance with Signals and Systems homework.
The document discusses techniques for line drawing and generalization in computer graphics. It covers Bresenham's line drawing algorithm, which uses only integer arithmetic for efficiency. It also discusses circle drawing using the midpoint circle algorithm and extensions to draw ellipses. Anti-aliasing techniques like area sampling are introduced to reduce jagged edges when rasterizing lines.
This document discusses vectorized code in MATLAB. It covers operations on vectors and matrices such as addition, subtraction, and multiplication. It discusses using vectors and matrices as function arguments and performing element-wise operations. It also covers logical vectors and examples of vectorizing code using loops to perform operations such as finding maximum/minimum values, counting elements, and comparing elements in less than 3 sentences.
Frequency Response with MATLAB Examples.pdfSunil Manjani
The document discusses frequency response analysis and control system design. It introduces frequency response, defines it as the steady-state response of a system to a sinusoidal input in terms of gain and phase lag. Bode diagrams are presented as a tool to graphically analyze the frequency response from a transfer function or experimentally. MATLAB functions like tf() and bode() are used to define transfer functions and plot Bode diagrams from the frequency response. Discrete-time PID and PI controller implementations and state-space models are also covered.
This document discusses reasons for poor software quality and characteristics of companies with low quality standards ("quality laggards"). It then outlines categories of quality attributes from both product-specific and organization-specific perspectives. Finally, it discusses approaches that leading companies use to achieve high levels of software quality, such as enterprise-wide quality programs, formal inspections, specialized testing teams, and executive support for quality initiatives.
This document discusses software defects, including what they are, where they originate, and how they can be eliminated. It defines a software defect as an error, flaw, or fault that prevents software from functioning as intended. Defects are introduced during requirements, design, coding, documentation, testing, and other phases. They can have varying effects from minor issues to system crashes or security vulnerabilities. The document outlines inspection and testing methods for removing defects, noting that requirements and design defects are particularly difficult to fix. It aims to provide an overview of software defects before discussing topics in more depth later.
The document discusses dataflow analysis techniques including reaching definitions analysis, available expressions analysis, very busy expressions analysis, and live variables analysis. It defines each analysis, provides examples of their application including computing IN and OUT sets at each program point, and classifies the analyses as either forward or backward and may or must analyses. The overall goal of dataflow analysis is to reason about the flow of data through a program using its control flow graph and local analysis rules.
The document discusses delta debugging, a technique for simplifying test cases to identify the root cause of software failures. It involves iteratively removing portions of input until the failure disappears, allowing engineers to minimize test cases. The technique uses a binary search approach, removing half the input at each step. Mozilla used this approach in a "BugAThon" to simplify over 370 bug reports, cutting complex test cases down to their core issue in a small number of steps.
This document discusses type systems and their use in static analysis of programs. It begins by defining what a type is - a set of values that represents concrete program elements. It then presents the notation and rules for a simple typed lambda calculus. Key points are that type systems provide abstraction over program elements, type checking is done using inference rules, and environments map variables to their types. Type systems ensure soundness by guaranteeing programs evaluate without type errors. Constraints may also need to be solved, such as ensuring types are consistent in conditionals and recursion.
This document provides an overview of central banking and the structure of the Federal Reserve System in the United States. It discusses the origins of the Fed following financial panics in the 19th century. The structure of the Fed is designed to diffuse power across various entities, including the 12 Federal Reserve Banks, the Board of Governors, and the Federal Open Market Committee. The roles and responsibilities of these groups in determining monetary policy and regulating financial institutions are also examined.
Mobile App Development Company In Noida | Drona InfotechDrona Infotech
Drona Infotech is a premier mobile app development company in Noida, providing cutting-edge solutions for businesses.
Visit Us For : https://www.dronainfotech.com/mobile-application-development/
The Rising Future of CPaaS in the Middle East 2024Yara Milbes
Explore "The Rising Future of CPaaS in the Middle East in 2024" with this comprehensive PPT presentation. Discover how Communication Platforms as a Service (CPaaS) is transforming communication across various sectors in the Middle East.
Top Benefits of Using Salesforce Healthcare CRM for Patient Management.pdfVALiNTRY360
Salesforce Healthcare CRM, implemented by VALiNTRY360, revolutionizes patient management by enhancing patient engagement, streamlining administrative processes, and improving care coordination. Its advanced analytics, robust security, and seamless integration with telehealth services ensure that healthcare providers can deliver personalized, efficient, and secure patient care. By automating routine tasks and providing actionable insights, Salesforce Healthcare CRM enables healthcare providers to focus on delivering high-quality care, leading to better patient outcomes and higher satisfaction. VALiNTRY360's expertise ensures a tailored solution that meets the unique needs of any healthcare practice, from small clinics to large hospital systems.
For more info visit us https://valintry360.com/solutions/health-life-sciences
Preparing Non - Technical Founders for Engaging a Tech AgencyISH Technologies
Preparing non-technical founders before engaging a tech agency is crucial for the success of their projects. It starts with clearly defining their vision and goals, conducting thorough market research, and gaining a basic understanding of relevant technologies. Setting realistic expectations and preparing a detailed project brief are essential steps. Founders should select a tech agency with a proven track record and establish clear communication channels. Additionally, addressing legal and contractual considerations and planning for post-launch support are vital to ensure a smooth and successful collaboration. This preparation empowers non-technical founders to effectively communicate their needs and work seamlessly with their chosen tech agency.Visit our site to get more details about this. Contact us today www.ishtechnologies.com.au
Using Query Store in Azure PostgreSQL to Understand Query PerformanceGrant Fritchey
Microsoft has added an excellent new extension in PostgreSQL on their Azure Platform. This session, presented at Posette 2024, covers what Query Store is and the types of information you can get out of it.
Why Apache Kafka Clusters Are Like Galaxies (And Other Cosmic Kafka Quandarie...Paul Brebner
Closing talk for the Performance Engineering track at Community Over Code EU (Bratislava, Slovakia, June 5 2024) https://eu.communityovercode.org/sessions/2024/why-apache-kafka-clusters-are-like-galaxies-and-other-cosmic-kafka-quandaries-explored/ Instaclustr (now part of NetApp) manages 100s of Apache Kafka clusters of many different sizes, for a variety of use cases and customers. For the last 7 years I’ve been focused outwardly on exploring Kafka application development challenges, but recently I decided to look inward and see what I could discover about the performance, scalability and resource characteristics of the Kafka clusters themselves. Using a suite of Performance Engineering techniques, I will reveal some surprising discoveries about cosmic Kafka mysteries in our data centres, related to: cluster sizes and distribution (using Zipf’s Law), horizontal vs. vertical scalability, and predicting Kafka performance using metrics, modelling and regression techniques. These insights are relevant to Kafka developers and operators.
E-Invoicing Implementation: A Step-by-Step Guide for Saudi Arabian CompaniesQuickdice ERP
Explore the seamless transition to e-invoicing with this comprehensive guide tailored for Saudi Arabian businesses. Navigate the process effortlessly with step-by-step instructions designed to streamline implementation and enhance efficiency.
E-commerce Development Services- Hornet DynamicsHornet Dynamics
For any business hoping to succeed in the digital age, having a strong online presence is crucial. We offer Ecommerce Development Services that are customized according to your business requirements and client preferences, enabling you to create a dynamic, safe, and user-friendly online store.
14 th Edition of International conference on computer visionShulagnaSarkar2
About the event
14th Edition of International conference on computer vision
Computer conferences organized by ScienceFather group. ScienceFather takes the privilege to invite speakers participants students delegates and exhibitors from across the globe to its International Conference on computer conferences to be held in the Various Beautiful cites of the world. computer conferences are a discussion of common Inventions-related issues and additionally trade information share proof thoughts and insight into advanced developments in the science inventions service system. New technology may create many materials and devices with a vast range of applications such as in Science medicine electronics biomaterials energy production and consumer products.
Nomination are Open!! Don't Miss it
Visit: computer.scifat.com
Award Nomination: https://x-i.me/ishnom
Conference Submission: https://x-i.me/anicon
For Enquiry: Computer@scifat.com
UI5con 2024 - Boost Your Development Experience with UI5 Tooling ExtensionsPeter Muessig
The UI5 tooling is the development and build tooling of UI5. It is built in a modular and extensible way so that it can be easily extended by your needs. This session will showcase various tooling extensions which can boost your development experience by far so that you can really work offline, transpile your code in your project to use even newer versions of EcmaScript (than 2022 which is supported right now by the UI5 tooling), consume any npm package of your choice in your project, using different kind of proxies, and even stitching UI5 projects during development together to mimic your target environment.
Baha Majid WCA4Z IBM Z Customer Council Boston June 2024.pdfBaha Majid
IBM watsonx Code Assistant for Z, our latest Generative AI-assisted mainframe application modernization solution. Mainframe (IBM Z) application modernization is a topic that every mainframe client is addressing to various degrees today, driven largely from digital transformation. With generative AI comes the opportunity to reimagine the mainframe application modernization experience. Infusing generative AI will enable speed and trust, help de-risk, and lower total costs associated with heavy-lifting application modernization initiatives. This document provides an overview of the IBM watsonx Code Assistant for Z which uses the power of generative AI to make it easier for developers to selectively modernize COBOL business services while maintaining mainframe qualities of service.
WWDC 2024 Keynote Review: For CocoaCoders AustinPatrick Weigel
Overview of WWDC 2024 Keynote Address.
Covers: Apple Intelligence, iOS18, macOS Sequoia, iPadOS, watchOS, visionOS, and Apple TV+.
Understandable dialogue on Apple TV+
On-device app controlling AI.
Access to ChatGPT with a guest appearance by Chief Data Thief Sam Altman!
App Locking! iPhone Mirroring! And a Calculator!!
How Can Hiring A Mobile App Development Company Help Your Business Grow?ToXSL Technologies
ToXSL Technologies is an award-winning Mobile App Development Company in Dubai that helps businesses reshape their digital possibilities with custom app services. As a top app development company in Dubai, we offer highly engaging iOS & Android app solutions. https://rb.gy/necdnt
Unveiling the Advantages of Agile Software Development.pdfbrainerhub1
Learn about Agile Software Development's advantages. Simplify your workflow to spur quicker innovation. Jump right in! We have also discussed the advantages.
Everything You Need to Know About X-Sign: The eSign Functionality of XfilesPr...XfilesPro
Wondering how X-Sign gained popularity in a quick time span? This eSign functionality of XfilesPro DocuPrime has many advancements to offer for Salesforce users. Explore them now!
DECODING JAVA THREAD DUMPS: MASTER THE ART OF ANALYSISTier1 app
Are you ready to unlock the secrets hidden within Java thread dumps? Join us for a hands-on session where we'll delve into effective troubleshooting patterns to swiftly identify the root causes of production problems. Discover the right tools, techniques, and best practices while exploring *real-world case studies of major outages* in Fortune 500 enterprises. Engage in interactive lab exercises where you'll have the opportunity to troubleshoot thread dumps and uncover performance issues firsthand. Join us and become a master of Java thread dump analysis!
3. [x == 1]
Introducing Pointers
x = 1;
y = x;
assert(y == 1)
x = new Circle();
x.radius = 1;
y = x.radius;
assert(y == 1)
Example without pointers
[y == 1]
Same example with pointers
4. [x == 1]
Introducing Pointers
x = 1;
y = x;
assert(y == 1)
x = new Circle();
x.radius = 1;
y = x.radius;
assert(y == 1)
Example without pointers
[y == 1]
Same example with pointers
[y == 1]
[x.radius == 1]
5. Pointer Aliasing
• Situation in which same address referred to in different ways
Circle x = new Circle();
Circle z = ?
x.radius = 1;
z.radius = 2;
y = x.radius;
assert(y == 1)
x = new Circle();
x.radius = 1;
y = x.radius;
assert(y == 1)
[x.radius == 1]
[x.radius == ?]
[x.radius == 1]
[y == 1]
6. May-Alias Analysis
Circle x = new Circle();
Circle z = new Circle();
x.radius = 1;
z.radius = 2;
y = x.radius;
assert(y == 1)
May-Alias Analysis == Pointer Analysis
[x.radius == 1, x != z]
[x.radius == 1]
[y == 1]
[x != z]
7. Circle x = new Circle();
Circle z = x;
x.radius = 1;
z.radius = 2;
y = x.radius;
assert(y == 1)
Must-Alias Analysis
• May-Alias and Must-Alias are dual problems
• Must-Alias more advanced, less useful in practice
• Focus of this Lesson: May-Alias Analysis
[x.radius == 2]
[y == 2]
[x.radius == 1, x == z]
[x == z]
y == 2
9. Approximation to the Rescue
•Pointer analysis problem is undecidable
=> We must sacrifice some combination of:
Soundness, Completeness, Termination
•We are going to sacrifice completeness
=> False positives but no false negatives
10. What False Positives Mean
Circle x = new Circle();
Circle z = new Circle();
x.radius = 1;
z.radius = 2;
y = x.radius;
assert(y == 1)
Pointer analysis answers questions of form: MayAlias(x, z)?
No => x and z are not aliased in any run
Yes => Can’t tell if x and z are aliased in some run
[x.radius == 1, x == z or x != z]
No Yes
[x == z or x != z]
[x.radius == 1 or x.radius == 2]
[y == 1 or y == 2]
False Positive!
[x.radius == 1, x != z]
[x.radius == 1]
[y == 1]
[x != z]
11. Approximation to the Rescue
•Many sound approximate algorithms for pointer analysis
•Varying levels of precision
•Differ in two key aspects:
• How to abstract the heap (i.e. dynamically allocated data)
• How to abstract control-flow
12. Example Java Program
void doit(int M, int N) {
Elevator v = new Elevator();
v.floors = new Object[M];
v.events = new Object[N];
for (int i = 0; i < M; i++) {
Floor f = new Floor();
v.floors[i] = f;
}
for (int i = 0; i < N; i++) {
Event e = new Event();
v.events[i] = e;
}
}
class Elevator {
Object[] floors;
Object[] events;
}
13. A Run of the Program
void doit(int M, int N) {
Elevator v = new Elevator();
v.floors = new Object[M];
v.events = new Object[N];
for (int i = 0; i < M; i++) {
Floor f = new Floor();
v.floors[i] = f;
}
for (int i = 0; i < N; i++) {
Event e = new Event();
v.events[i] = e;
}
}
doit(3, 2) v
14. Abstracting the Heap
void doit(int M, int N) {
Elevator v = new Elevator();
v.floors = new Object[M];
v.events = new Object[N];
for (int i = 0; i < M; i++) {
Floor f = new Floor();
v.floors[i] = f;
}
for (int i = 0; i < N; i++) {
Event e = new Event();
v.events[i] = e;
}
}
v
15. Result of Heap Abstraction: Points-to Graph
Elevator
v
Object[] Object[]
Floor Event
f e
floors
[*] [*]
event
s
v
16. Abstracting Control-Flow
void doit(int M, int N) {
Elevator v = new Elevator();
v.floors = new Object[M];
v.events = new Object[N];
for (int i = 0; i < M; i++) {
Floor f = new Floor();
v.floors[i] = f;
}
for (int i = 0; i < N; i++) {
Event e = new Event();
v.events[i] = e;
}
}
Elevator
v
Object[
]
Object[
]
Floor Event
f e
floors
[*] [*]
events
17. Flow Insensitivity
void doit(int M, int N) {
Elevator v = new Elevator();
v.floors = new Object[M];
v.events = new Object[N];
for (int i = 0; i < M; i++) {
Floor f = new Floor();
v.floors[i] = f;
}
for (int i = 0; i < N; i++) {
Event e = new Event();
v.events[i] = e;
}
}
void doit(int M, int N) {
v = new Elevator
v.floors = new Object[]
v.events = new Object[]
f = new Floor
v.floors[*] = f
e = new Event
v.events[*] = e
}
- Notice that all control-flow features have been removed, including constructs like for-loops and also semicolons indicating sequentially
ordered statements.
- All statements that do not affect pointers have also been removed. For example, the approximated code no longer has statements
setting the integer i equal to 0 and incrementing i.
- Finally, array indices are replaced by nondeterministic choice, denoted by the asterisk symbol. This is similar to how conditions at
branch points in dataflow analysis were replaced by nondeterministic choice.
18. Chaotic Iteration Algorithm
graph = empty
repeat:
for (each statement s in set)
apply rule corresponding to s on graph
until graph stops changing
19. Kinds of Statements
(statement) s ::= v = new … | v = v2 | v2 = v.f |
v.f = v2 | v2 = v[*] | v[*] = v2
(pointer-type variable) v
(pointer-type field) f
20. Is This Grammar Enough?
v.events = new Object[]
tmp = new Object[]
v.events = tmp
v.events[*] = e
tmp = v.events
tmp[*] = e
v = new … | v = v2 | v2 = v.f |
v.f = v2 | v2 = v[*] | v[*] = v2
21. Example Program in Normal Form
void doit(int M, int N) {
v = new Elevator
v.floors = new Object[]
v.events = new Object[]
f = new Floor
v.floors[*] = f
e = new Event
v.events[*] = e
}
void doit(int M, int N) {
v = new Elevator
tmp1 = new Object[]
v.floors = tmp1
tmp2 = new Object[]
v.events = tmp2
f = new Floor
tmp3 = v.floors
tmp3[*] = f
e = new Event
tmp4 = v.events
tmp4[*] = e
}
22. Normal Form of Programs
v1.f.g = v2.h
v1.f = v2.f
v = new … | v = v2 | v2 = v.f |
v.f = v2 | v2 = v[*] | v[*] = v2
Convert each of these two expressions to normal form:
23. Normal Form of Programs
v1.f.g = v2.h
v1.f = v2.f
tmp1 = v1.f
tmp2 = v2.h
tmp1.g = tmp2
tmp = v2.f
v1.f = tmp
v = new … | v = v2 | v2 = v.f |
v.f = v2 | v2 = v[*] | v[*] = v2
Convert each of these two expressions to normal form:
24. Rule for Object Allocation Sites
v = new B
After:
v
Before:
v
A
A
B
25. Rule for Object Allocation Sites: Example
void doit(int M, int N) {
v = new Elevator
tmp1 = new Object[]
v.floors = tmp1
tmp2 = new Object[]
v.events = tmp2
f = new Floor
tmp3 = v.floors
tmp3[*] = f
e = new Event
tmp4 = v.events
tmp4[*] = e
}
Elevator
v
Object[] Object[]
Floor Event
f e
tmp
1
tmp
2
26. Rule for Object Copy
v1 = v2
A
v1 v2
v1 v2 B
After:
Before:
A
B
B
27. Rule for Field Writes
f or [*]
After:
Before:
v1 . f = v2
v1[*] = v2
v1 A v2 B A C
v1 v2 B A
C
or
f or [*]
f or [*]
A
B
28. Rule for Field Writes: Example
void doit(int M, int N) {
v = new Elevator
tmp1 = new Object[]
v.floors = tmp1
tmp2 = new Object[]
v.events = tmp2
f = new Floor
tmp3 = v.floors
tmp3[*] = f
e = new Event
tmp4 = v.events
tmp4[*] = e
}
Elevato
r
v
Object[
]
Object[
]
Floor Event
f e
floors
event
s
tmp
1
tmp
2
29. Rule for Field Reads
A v2 B B C
v2 B B C
After:
Before:
C
A
v1 = v2.f
v1 = v2[*]
or
f or [*]
f or [*]
v1
v1
30. Rule for Field Reads: Example
void doit(int M, int N) {
v = new Elevator
tmp1 = new Object[]
v.floors = tmp1
tmp2 = new Object[]
v.events = tmp2
f = new Floor
tmp3 = v.floors
tmp3[*] = f
e = new Event
tmp4 = v.events
tmp4[*] = e
}
Elevato
r
v
Object[
]
Object[
]
Floor Event
f e
floors
event
s
tmp
1
tmp
2
tmp
3
tmp
4
31. Continuing the Pointer Analysis: Example
Elevato
r
v
Object[
]
Object[
]
Floor Event
f e
floors
event
s
tmp
1
tmp
2
tmp
3
tmp
4
[*] [*]
void doit(int M, int N) {
v = new Elevator
tmp1 = new Object[]
v.floors = tmp1
tmp2 = new Object[]
v.events = tmp2
f = new Floor
tmp3 = v.floors
tmp3[*] = f
e = new Event
tmp4 = v.events
tmp4[*] = e
}
32. class Node {
int data;
Node next, prev;
}
Node h = null;
for (...) {
Node v = new Node();
if (h != null) {
v.next = h;
h.prev = v;
}
h = v;
}
Pointer Analysis Example
Choose the points-to graph for
the shown program.
Node
h
nex
t
pre
v
v
Node
h
nex
t
pre
v
v
Node
h
nex
t
pre
v
v Node
h
nex
t
pre
v
v
34. Classifying Pointer Analysis Algorithms
•Is it flow-sensitive?
•Is it context-sensitive?
•What heap abstraction scheme is used?
•How are aggregate data types modeled?
35. Flow Sensitivity
•How to model control-flow within a procedure
•Two kinds: flow-insensitive vs. flow-sensitive
•Flow-insensitive == weak updates
• Suffices for may-alias analysis
•Flow-sensitive == strong updates
• Required for must-alias analysis
36. Context Sensitivity
• How to model control-flow across procedures
• Two kinds: context-insensitive vs. context-sensitive
• Context-insensitive: analyze each procedure once
• Context-sensitive: analyze each procedure possibly
multiple times, once per abstract calling context
37. Heap Abstraction
• Scheme to partition unbounded set of concrete
objects into finitely many abstract objects (oval
nodes in points-to graph)
• Ensures that pointer analysis terminates
• Many sound schemes, varying in precision & efficiency
• Too few abstract objects => efficient but imprecise
• Too many abstract objects => expensive but precise
38. Scheme #1: Allocation-Site Based
One abstract object per allocation site
Allocation site identified by:
• new keyword in Java/C++
• malloc() call in C
Finitely many allocation sites in a
program
=> finitely many abstract objects
Elevator
v
Object[] Object[]
Floor Event
f e
floors events
[*] [*]
39. Scheme #2: Type Based
• Allocation-site based scheme can be costly
- Large programs
- Clients needing quick turnaround time
- Overly fine granularity of sites
• One abstract object per type
• Finitely many types in a program
=> finitely many abstract objects
Elevator
v
Object[]
Floor Event
f e
[*] [*]
floors events
40. Scheme #3: Heap-Insensitive
Single abstract object representing entire heap
Popular for languages with primarily
stack-directed pointers (e.g. C)
Unsuitable for languages with only
heap-directed pointers (e.g. Java)
v
floors,
events,
[*]
f e
41. [*]
Tradeoffs in Heap Abstraction Schemes
More Efficient
More Precise
Allocation-site
based
Type based Heap-
insensitive
v
floors,
events,
[*]
f e
Elevator
v
Object[] Object[]
Floor Event
f e
floors events
[*]
Elevator
v
Object[]
Floor Event
f e
[*] [*]
floors events
42. Modeling Aggregate Data Types: Arrays
• Common choice: single field [*] to represent all array elements
• Cannot distinguish different elements of same array
• More sophisticated representations that make such distinctions are
employed by array dependence analyses
• Used to parallelize sequential loops by parallelizing compilers
43. Modeling Aggregate Data Types: Records
Three choices:
1. Field-insensitive: merge all fields of each
record object
2. Field-based: merge each field of all
record objects
3. Field-sensitive: keep each field of each
(abstract) record object separate
f1 f2
a1
a2
f1 f2
a1
a2
f1 f2
a1
a2
44. Pointer Analysis Classification
Classify the pointer analysis algorithm we learned
in this lesson.
Flow-sensitive?
Context-sensitive?
Distinguishes fields of object?
Distinguishes elements of array?
What kind of heap abstraction?
A. Yes B. No
A. Yes B. No
A. Yes B. No
A. Yes B. No
A. Allocation- B. Type
site based based
45. Pointer Analysis Classification
Flow-sensitive? B
Context-sensitive? B
Distinguishes fields of object? A
Distinguishes elements of array? B
What kind of heap abstraction? A
A. Yes B. No
A. Yes B. No
A. Allocation- B. Type
site based based
A. Yes B. No
A. Yes B. No
Classify the pointer analysis algorithm we learned
in this lesson.