Number of double wedges containing a point

We have a set of $ n$ double wedges on a plane. (By double wedge, I mean two lines intersecting at a point, with opposite sides of the point considered as “inside” the double wedge.) Now these $ n$ double wedges can intersect each other.

Our query is as follows: given a point, we want to find how many double wedges it’s contained in. We want to be able to make this query in $ O(\log n)$ time, using a data structure that can be constructed (preprocessed) in $ O(n^2\log n)$ time and $ O(n^2)$ space.

This exercise is from the de Berg’s computational geometry book in the chapter about arrangement of lines, so I was thinking we can do some kind of incremental construction by adding the double wedges one by one, but I can’t seem to think of the data structure.

enter image description here

Java – Problems with overload constructor containing only a string [closed]

I am having trouble figuring out how to correctly ask the user for 3 inputs representing attributes that will be used to create an object which will be printed on the screen and making sure the inputs aren’t bad values. For example, if the user typed in .5 as a diameter it would change to 1. The overload constructor is supposed to represent the name of a file which will contain the name, diameter, and temperature of the object being created.

When I try to run it, there would errors for missing symbols. How can I get it so that the overload constructor with string as its only parameter to be called into the Object2 class in order to create an object?

public class Object1 {    //attributes    private double yyy;    private int zzz;    private String xxx;    private String fileName;     //symbolic constants    private final double MINDIAMETER = 1;    private final int MINTEMP = 300;    private final String NA = "N/A";     // getter/setter methods for name    public void setName(String n)    {    if (n != "")    xxx = n;     else     xxx = NA;    }     public String getName()    {    return xxx;    }     // getter/setter methods for diameter    public void setDiameter(double d)    {    if (d >= MINDIAMETER)    yyy = d;     else     yyy = MINDIAMETER;    }     public double getDiameter()    {    return yyy;    }     // getter/setter methods for temperature    public void setTemp(int t)    {    if (t >= MINTEMP)    zzz = t;     else     zzz = MINTEMP;    }     public int getTemp()    {    return zzz;    }     public Object1()    {       xxx = NA;       yyy = MINDIAMETER;       zzz = MINTEMP;    }     public Object1(String n, double d, int t)    {       setName(n);       setDiameter(d);       setTemp(t);    }     public Object1(String f)    {         fileName = f; //Initialize the object's fileName with f         System.out.print("Enter the filename: ");      }     public String toString()    {       return "A object, named " + xxx + ", with a diameter of " + yyy + " miles, and a temperature of " + zzz + " Kelvin.";    } } 

Seperate file code

import java.util.Scanner; import; import; import; import; import;  public class Object2 {    public static void main(String[] args) throws IOException    {           // object with overload         Object1 z;         z = new Object1("");          Scanner kb = new Scanner(;           fileName = kb.nextLine();         File file = new File(fileName);         PrintWriter outputFile = new PrintWriter(file);          System.out.println("please enter name: ");         while (kb.hasNext())         {          name = kb.nextLine();         System.out.println("please enter the diameter: ");         diameter = kb.nextDouble();         System.out.println("please enter the temperature: ");         temp = kb.nextInt();          System.out.println(name + " " + diameter + " " + temp);          outputFile.println(name);         outputFile.println(diameter);         outputFile.println(temp);         }           outputFile.close();         System.out.println(z);     } }  

Find the max partition of unique elements where each element corresponds to the set pool containing that element

Given a list of sets:

a b c -> _ c d   -> d b d   -> b a c   -> a a c   -> c 

The objective is to find the max partition of unique elements with each element corresponding to the set containing that element.

I was thinking about ordering the elements in n * log(n) based on occurrence in other groups and then iteratively start with the lowest, and reorder the list each time based on subtracting the occurrences of other elements within the lists containing the removed element. We are able to do so, as each unique element contains a set of pointers to the lists where the element is contained in.

I can store the unique elements with its occurrences in a Min-Heap, where each unique element has handler to the node within the Min-Heap, thus we can remove the min and also decrease the key one for others within the same list as the contained element in log(n) giving that we have it’s handler.

Is the approach feasible at all, if not, what approach I can make use of?

Hydra HTTP Form Post with parameters containing a colon “:”

I’m trying to brute force login on my domain using THC Hydra v9.1-dev. It is using an form and some of the required post body parameters contain a colon : in them which is the separator used by Hydra. An example parameter: _ctl0:PlaceHolder:LoginName:txtLoginUsername=^USER^.

This makes hydra think that I have _ctl0 as the first part and Placeholder as the error message.

I tried:

  • URL encoding them, e.g this becomes: _ctl0%3APlaceHolder%3ALoginName%3AtxtLoginUsername=^USER^
  • replacing : with a \:
  • placing the parameter in quotation marks ""

but none of them worked and I can’t seem to find a way to change the separator.

Any help is much appreciated!

Find sub-matrix containing the maximum number of elements consisting only of 1’s

I am trying to get help on it here, originally posted first at:

Basically trying to get the max sub matrix that contains only 1’s of a matrix that is filled with 0’s and 1’s.

I could figure out the max sub matrix, now I just need to find how to do so that the sub matrix is only 1’s.

Find sub-matrix containing the maximum number of elements consisting only of 1’s

A matrix of integers of size R x C (R rows, C columns) is given. All its elements have a value of 0 or 1. The rows of the matrix are numbered from 1 to R, the columns are numbered from 1 to C.

I am trying to find the most effective algorithm that will output r1, r2, c1, c2 of a sub matrix that consists only 1’s and creates the maximum number of elements.

So far I thought of making a pre-matrix that counts the sum at each given element in the sub matrix (1, 1, r, c) and store it in a new matrix SUM (with same dimensions as the original matrix).

The formula for this could be then:

SUM[i, j] = SUM[i−1, j] + SUM[i, j−1] − SUM[i−1, i−1] + MATRIX[i, j]

I am not sure if I had to do the sums though, if anyone has experience with a similar problem I would appreciate an explanation.

What is the maximum number of swaps to sort an array containing number from 1 … n?

I have this algorithm to sort an array which contains unique numbers from 1 to n.

public static void cyclicSort(int[] nums) {     int i = 0;     while (i < nums.length) {         if (nums[i] != nums[nums[i] - 1]) {             swap(nums, i, nums[i] - 1);         } else {             i++;         }     } }  static void swap(int[] nums, int i, int j) {     int temp = nums[i];     nums[i] = nums[j];     nums[j] = temp; } 

How can I prove that in worst case, the running time of this algorithm is still asymptotically O(N)?

My observation:

  • Although i will not increase right after each swap but when it’s increase, the next number of required swaps will also be decreased.
  • The maximum number of swaps at i = 0 will be O(N-1).

Second question is: Is the running time still O(N) if it contains duplicated numbers?

Sampling a uniform distribution of fixed size strings containing no forbidden substrings

Given a list of “forbidden” words (substrings), an alphabet, and a desired output string length, how would I efficiently sample output strings containing no forbidden word?

For short output strings with few forbidden words, I would use simple rejection sampling. Pick a string (uniformly) with the specified alphabet and length, return that string if it contains no element of the forbidden list, try again otherwise.

If I use that algorithm for output lengths several times larger than the typical forbidden word, then the probability of rejection will be higher. (Most words are 2 or 3 characters long.)

Assume the requested output length is too long to enumerate and store every possible value. My alphabet size would be 16 to 36 characters, but solutions to large alphabets would be interesting to think about. (In which case I would call these things random sentences, forbidden n-grams, and dictionary words.)

My forbidden word list will have one hundred to one thousand strings. I would like to avoid solutions requiring expensive precomputation or lots of memory.

My first idea was to try to build a random string incrementally, in contrast to the all-or-nothing approach of straightforward rejection sampling. I doubt that my algorithm produces each possible output with equal probability.

The algorithm idea follows:

  1. Initialize a char buffer long enough to fit outlen characters.
  2. Pick a random letter of the alphabet and append it to the buffer.
  3. If the buffer ends with a forbidden word of length k, then remove the last k letters from the char buffer and go to 2.
  4. Otherwise, go to 2 if the buffer has less than outlen characters.
  5. Return the contents of the buffer if it is full.

Step 3 serves to rewind the algorithm, returning the char buffer to a previous legal state.

I understand that clearing the whole buffer in step 3 definitely would produce uniform output just like the straightforward rejection sampling method. However, the average number of rejections before the first valid output is generated will be the same.

I’ve gotten stuck trying to determine if my proposed algorithm is uniform. I have had no luck finding alternative algorithms either. I haven’t yet looked at how this algorithm’s performance would compare to basic rejection sampling.

How to generate a list (or even a sequence or a string) containing {x[1]==0&&x[2]==0&&…&&x[10]==0?

I need to solve a bunch of systems of n equations in n unknowns where n varies. I can do them, one by one, but I wish to automate the process.

The first equation equals 1 and the rest all equal zero. I currently type in each set of equations manually as follows. I have the n unknowns in a list: list1={r,s,…,t}. I have the expressions for the LHS in a 2nd list: list2={expr1, …, exprn]. I write sol=Solve[list2[[1]]==1&&list2[[2]]==0 … &&list2[[n]]==0,list1]

I would like to just type Solve[expr,list] where expr is something like list2[[1]]==1&&list2[[2]]==0 … &&list2[[n]]==0. I experimented with Table, RowBox, BoxData, and even CellPrint but I don’t know enough to write an expression involving && and == that will work inside the Solve function.

Complexity class of finding a siphon containing a trap?

I have found that finding a minimal siphon containing a set of places in general Petri Net is NP-complete. However, I am curious if this problem lands into a smaller complexity class if we only are trying to find a siphon, where the set of places is a trap T and we further require that the largest trap inside the siphon we find has to be T.

Or does this problem get easier if we instead require that this search is done in a Free Choice Petri Net, where many decision problems are much easier to solve than in a general Petri Net.

I have looked around, but it doesn’t seem to be a question many people are asking, so I haven’t found anything so far. Are those two “simpler” problems also NP-complete or are they in some smaller complexity class?