Having trouble with an assignment about sorting, the toilet stall problem

I’m in programming 2 and my professor is both unhelpful and a harsh grader. So I don’t want to take any chances so i wont get another F.

I’m sure this assignment is common enough that someone here has heard of it, Given a number of stalls, each stall should be filled in the midpoint of unfilled stalls. Currently, my code works for around 4-5 iterations, however it has to work for at least 30.

   {         for(int i=1;i<Stalls.length;i++)       {           if(Stalls[i]==false)           {             freeStallRange++;              i++;             }        }             Stalls[freeStallRange/2]=occupant;     }  

It looks blindingly simple right now, because I’m quite stumped at the moment, any assistance?

Set: in part assignment is not a symbol

This is probably a basic question but I am new to Mathematica, so please help me out here.

I have the following piece of code:

lmax = 2; arrlen = lmax + 1; xarr[x_] = Array[x^# &, arrlen, 0]; parr[p_] = Array[p^# &, arrlen, 0]; arr[x_, p_] = Join[xarr[x], parr[p]]; mboot[x_, p_] := Outer[NonCommutativeMultiply, arr[x, p], arr[x, p]] 

Now, I want to set a few particular elements of mboot[x,p] to 0. But when I try, for example:

mboot[x,p][[1,1]]=0 

I get an error saying Set: mboot[x,p] in the part assignment is not a symbol.

It would be great if someone could help me figure out what is going wrong and how I can fix it.

Compiler Design Assignment

1.grammar G which is context-free has the productions

S → aAB

A → Bba

B → bB

B → c

Compute the string w = ‘acbabc’ with left most derivation, right most derivation and draw Top Down parse tree.

2.Compute the First and Follow sets

S→ Aa

A→ BD

B→ b|λ

D→ d|λ

Proof of non-trivial machine assignment greedy algorithm

I’m trying to prove a greedy algorithm works for a specific problem:

You have $ n$ jobs and an unlimited number of machines. Each job $ j$ has a size $ s_j$ . Each machine $ i$ has a constant associated with its speed, $ p_i$ . The cost of running job $ j$ on machine $ i$ is simply $ s_j \cdot p_i$ . We can only assign at most $ k$ jobs to one machine. How should the jobs be assigned to minimize cost?

The simple greedy algorithm is to first sort the jobs from greatest size to least size, and the machines from fastest (least $ p_i$ in this case) to slowest, and then assign the $ k$ largest jobs to the fastest machine, second $ k$ largest jobs to the second fastest machine, etc.

I’m now trying to prove this algorithm is correct. My first try was to show that the greedy algorithm stays ahead. I reasoned that the optimal algorithm must also use the fastest machines (or else it is trivial to show it isn’t actually optimal), and therefore if we look at the machines from fastest to slowest, we can consider the first job for which they differ. But then it isn’t necessarily true that the greedy algorithm is doing better at this point as the optimal algorithm could minimize cost for that specific slot by putting in a smaller job (even though it actually hurts it later).

I also tried doing an overall induction on the number of jobs. Say we show it it optimal for $ n$ jobs. Can we show it is optimal for $ n+1$ jobs given the same options for machines? Again, it isn’t clear how to make this argument since we can’t just slide in job $ n+1$ ; maybe the optimal assignment suddenly follows a wildly different pattern.

Now I’m thinking that maybe it is necessary to create some sort of global objective function and show it is minimized using this assignment. But I’ve never seen a proof like this for a greedy algorithm and am unsure of how to proceed.

Thanks for the help!

CIPD assignment help

Writing assignments paper a students must be good at writing to achieve the best grades in educational career. Some students are searching for custom writer who can write and edit assignments. Then the online CIPD assignment help service is the best place to order writing services. Students struggle a lot in their study and complete their assignments and cleared all exams. After this whole struggle a student should start their business or practical career. Writing Yard is one of best writing…

CIPD assignment help

What is the logical assignment of attribute rolls based on class?

When rolling a new character for DnD, I roll (SUM 4 * D6) 6 times,

[15, 15, 13, 12, 9, 8]

throw the lowest one away leaving me with 5 numbers.

[15, 15, 13, 12, 9]

If my class is a Barbarian, my primary ability is STR and my saving throw proficiencies are STR and CON

Is it most logical to assign the 15 to STR and 15 to CON and rest don’t matter so much?

Computing an optimal integer assignment given an optimal LP-solution

I modeled an ILP where I have a set of outfits and a set of friends with , all these friends should take one outfit with the lowest effort , considering the fact that these outfits differ in size, body form, and adjustments. The solution should be like this:

with the next constraints:

The relaxation to LP would be to put:

Now, considering the fact that we don’t have an integrality gap in this problem and for every fractional LP-solution, there exists an integral feasible solution with the same cost, how can we give give a polynomial-time algorithm that, from any given optimal LP-solution, computes such an optimal integer assignment.

Problem Definition Assignment

To come up with a problem definition, write up some sample questions you would ask the president of Java Airlines to better help what they would like their software to do. Be Creative in your questions! Write up a mock Problem Definition Statement to summarize what you think the Java Airline software should be. Attention to detail will earn full marks on this assignment.

Would anyone explain or summarize it to me what should I do?

Assignment Problem — finding the $k$ agents with the best assignment

I have a question that I have been thinking about. Suppose we have $ n$ agents, $ m$ tasks, and a cost matrix with $ M_{ij}$ being the cost of agent $ i$ performing task $ j$ . How can we find the $ k < n$ agents, who when each optimally allocated a unique task, result in a minimum total cost? Can this be related to the assignment problem? Thank you very much for any guidance or assistance.