Monday, February 22, 2016

Today we continue to discuss jigsaw.Efficient, low effort mashup isolation by James Mickens and Matthew Finifter. Mashups are web applications that contain code from different principals.
Jigsaw lets mashups be isolated with its framework  and lets them selectively expose private state. We saw how Jigsaw improves the language and runtime for its purpose. It supports robust encapsulation technique using a Jigsaw to Javascript compiler and a client side library. The latter introduces box management interface and the rewriter adds an integer object id to every object created. This ensures that at most one proxy is created for every object. In addition, jigsaw includes the id of the creating box with each object so that it can determine if the surrogate object is executing within the same box. If so, it in wraps the object  and executes methods. Jigsaw adds a per object map of visibility Metadata by listing properties that are declared public and private and this map is immutable which secures the object from an untrusted box. Jigsaw also creates new boxes using the eval () statement  the boxes are created by the function that adds aliases to the global objects. This adds a security layer when out of box calls are made. This later enforces security policies and prevents virtual operations to be applied to their real counterparts.

#code jam exercise
We have to insert an element into a sorted array of N elements no tworries of which are duplicates ever. Typically we do binary search to find the position where we insert. In this modified problem, each comparison has a varying cost between 1 and 9 inclusive. What will be the total cost of this binary search in the worst case ?

 Here the cost of a comparison can vary. Therefore for each comparison there may be a better pick that achieves the same result of narrowing down the range. The final position of insertion is only one where the elements to the left are smaller and the elements to the right are bigger. This can be one of N+1 positions. The worst case is when we have exhausted all these positions to arrive at this one.
Consequently we create two sufficiently large matrices  where the rows cover the cumulative costs (arbitrarily large) and the columns span from 0 to N+1. These matrices keep track of the final position as columns against each possible cost as rows with the values initially ranging from 0 to N+1 aND iNC reading fRon left to right. We need two because one for left and another for right of the range we are considering. We update this matrix to reflect the monimum position for the given cost and  keep the values sorted before each update. Finally we read the row index of the right matrix as the answer where the first column equals N as the positions considered.

No comments:

Post a Comment