## Help computalion complexity problems

Can someone help me with these exercises and can you solve them? They are very difficult for me and even a little help would be very useful. (I’ve already asked in another stackexchange but I think it’s better to write here too)

thank you very much

## Introduction

I am dissatisfied with the rules for grappling in 5e. Well, it’s more that I’m dissatisfied with the fact that there’s no way to restrain someone in 5e via grappling.

The rules, as they are (if I imagine two humans having a fight) are better to describe someone grabbing someone’s arm, or by the scruff of the neck, which may prevent them from moving (unless they “break the grapple”), but otherwise doesn’t prevent them from doing anything else, because the Grappled condition simply reduces the grappled creature’s speed to 0.

If that is the player’s intent, then those rules work fine; you use an attack (not Action, just a single attack) to try to grab someone, with a contested check. If you win, now they can’t run away. That’s fine.

## Problem

However, what about if someone wants to restrain someone? I can imagine it would be easy enough to grab around someone such that their arms are pinned to their body, making them effectively Restrained. However, RAW, there is no way the average PC can do this; they need to have taken the Grappler feat, and even then, it takes two attacks to do so (so unless you have Extra Attack or Action Surge, it takes two turns to actually restrain someone).

Since I don’t like these rules, I’ve tried to come up with something to make restraining a target more appealing, especially for new players for whom trying something like this might seem intuitive, but then the RULES get in their way. The amount of times I’ve seen a new player try to grapple the enemy, thinking it’ll actually do something, only to find that in practice it did nothing and the creature just attacked them anyway without penalty…

## Proposal

Anyway, my proposed house rules are that, on top of the existing rules for grappling, you can also:

• spend your Action (not an attack, your full action) to attempt to Restrain a creature.
• Not just any creature, only a humanoid creature, or a creature that is roughly humanoid (like, say, a zombie, which is “undead”, but a normal person attempted to restrain one would still intuitively understand how to do it).
• Both creatures are then restrained, as per the Grappler feat, but this is something anyone can do.

The reason for the restriction on humanoid (or humanoid-like) is because I, personally, could give restraining another human a pretty good go, but I wouldn’t know how to go about restraining a dog (note: I do not own dogs, so maybe dog owners would know how to), let alone a Basilisk or a Spectator or something that one might encounter in the D&D universe.

## Grappler feat

Of course, this seriously nerfs the Grappler feat, so I’ve adjusted that too.

• Firstly, it should lift the restriction above; a “trained grappler” should know how to grapple a dog, Basalisk, Spectator, or whatever else can be grappled RAW.
• Secondly, they can restrain someone with an attack, not action, which is also an improvement on the RAW Grappler feat, which takes two attacks (potentially two turns, although most likely a character that would take the Grappler feat is also one who is likely to have Extra Attack past level 5).
• I was also considering adding “able to grapple (just a normal grapple) as a bonus action”, possibly instead of the previous point (so you can restrain using your bonus action and one “attack”), but I was wary of treading on the toes of the Tavern Brawler feat, so I’m not sure…

## Question

Given my proposed house rules, I hope that it:

1. gives an option to players (I mostly have new players in mind who don’t know obscure rules like how grappling works) to be able to sacrifice their turn to restrain someone,
2. for it to be balanced rather than a “strictly superior choice”, and
3. to still have the Grappler feat be a worthwhile investment for a “grapple build”, such that it’s not a “must-have” that out-muscles any other feat, but also not that it’s basically useless with my new “Restrain as an Action” house rules.

Are there problems with my proposal that I’m overlooking that will make my new “Restrain” Action massively overpowered, or my revised Grappler feat massively over- or under-powered? I just want a sanity check on what I’ve come up with before it “goes live” in my games.

## Are there any NP-hard problems for which the following statement is true:

$$\overline{A} \le A\ and$$ $$A \le \overline{A}$$

Is the following proof correct?

If $$\overline{A} \le A \Rightarrow \overline{A} \in NP$$ since A is NP-hard $$\Rightarrow A \in coNP$$

Since $$\overline{A} \le A$$ and $$A \in coNP \Rightarrow \overline{A} \in coNP \Rightarrow A \in NP$$

$$A \in coNP$$ and $$A \in NP$$ iff $$NP=coNP$$

## What problems does a university/college have that can be solved in the form of computer software development?

What problems does a university/college have that can be solved in the form of computer software development?

thought of Educational software development

## Why do I always have something missing in my understanding of topics which always lead me to solve problems incorrectly?

I am computer science masters student, i come from background of engineering and not cs, my problem is whenever i have a problem set, a programming task or an exam. i always try hard to understand the question and think for the right answers, but i usually either get stuck or have a wrong answer, and when i seek help i figure out i wasn’t completely understanding the topic of the question itself, missig some part of the information in or even having a wrong understanding to some parts.
So my question is, how i can approach a computer science topic “for e.g. operating systems” and have a good understanding with the right depth to have a better comprehension and to be able perform better at programming tasks and exams.

## Thought process to solve tree based Dynamic Programming problems

I am having a very hard time understanding tree based DP problems. I am fairly comfortable with array based DP problems but I cannot come up with the correct thought process for tree based problems and I was hoping somebody could please explain their thought process.

I will talk about my thought process behind array based problems and then explain my troubles with tree based DP problems.

My thought process for array problems

The way I think about DP in array based problems is as follows. Let us consider a problem like Minimum Path Sum. Here the objective is to get from the top left to bottom right positions in a matrix such that we minimize the cost of the path. We can only move left and right.

The way I would approach problems like this is as follows:

• First I would construct a recurrence. In this case the recurrence is as follows

The recurrence is:

f(i, j) = a[i][j] // if i == m and j == n f(i, j) = a[i][j] + f(i, j+1) // if i == m f(i, j) = a[i][j] + f(i+1, j) // if j == n f(i, j) = a[i][j] + Math.min( f(i, j+1), f(i+1, j) ) // Otherwise 
• Next I look at the last equation f(i, j) = a[i][j] + Math.min( f(i, j+1), f(i+1, j) ) which tells me the problem can be solved using DP as there are overlapping subproblems in f(i+1, j) and f(i, j+1). There is also an optimal substructure.

• I can also tell the time/space complexity just by looking at the recurrence.

• Because we must compute all states which is all (i,j) pairs and because time per state is O(1) (adding a[i][j] to result) the time complexity is O(n^2).
• Looking at the recurrence, i depends only on i+1 and not on i+2, i+3 … similarly j depends only on j+1 and not on j+2, j+3… so we can get away with using only 1 extra row (either i+1 or j+1) instead of the entire matrix so space complexity is O(n).

Hence I would come up with a n^2 time and n space solution. I can do this without any problems.

My thought process for tree problems

However I am having a hard time applying the same thought process to tree based DP problems. As an example let us consider the problem Diameter of Binary Tree where the objective is to find the longest path between any 2 nodes in the tree.

I can come up with a recurrence for this problem which is as follows:

f(n) = 0 // if n == null f(n) = max( 1+height(n.left) + height(n.right),         // longest path passing through root             f(n.left),                                  // longest path in left subtree             f(n.right)                                  // longest path in right subtree 

Because f(n.left) for example is computed by doing 1+height(n.left.left) + height(n.left.right) I can tell that DP must be used.

So my approach would be to create a cache of size ‘n’ that stores all the heights of the nodes. So the space complexity would be O(n).

However the optimal solution of this problem has a space complexity of O(1) and I am having a hard time figuring that out just by looking at the recurrence. How does the recurrence tell you that space complexity can be reduced and that O(1) space is enough and O(n) is not needed? How do you know what value(s) to store in this case? In array based problems I can get the answers to both these questions just by looking at the recurrence but for tree based dp it is not so obvious to me.

My questions:

1. What can you tell about this problem just by looking at the recurrence for the tree problem? Putting aside my own thought process, if I gave you this recurrence and nothing else what conclusions would you reach and how would you write the program? I am curious about your thought process.

2. For array based problems I can tell just by looking at the recurrence both how much space I needed to solve the problem AND what exactly I needed to store (I need to store values of row i+1 in min path sum and nothing else). How can I do the same for the tree problem?

Thanks.

## How to deal with pace problems?

I’m a player in a pathfinder campaign on Discord with 3 other friends, 2 players (let’s call them A and B) and the GM.

A little background

• I’m a very close friends with the others players and the GM.
• We’ve played IRL and on discord a few times before, but not all together. I played with A and GM on a campaign and with B and GM on an other campaign and A and B played with GM on a third one.
• We are all very good friends IRL outside of role-playing games.
• Player A plays a rogue, player B plays a paladin-scaled-fist-monk, and I play a summoner. We are a level 3 party.
• Player A likes to ask questions and plan things out-of-character only. Player B is the other way around, very discrete out-of-character but speaks in character if needed. I often take initiatives in and out of character (talking with NPCs, proposing strategies, ect.), and I’m aware of that, so I try my best to include other player in those, and I think that’s a fact that may be relevant.

The scene

Last night we were at what seemed to be a boss fight, the scene was set up at our last session, 1 day prior, where the GM explicitly told us that if we wanted to plan something big, he would provide us with necessary non-magical items in our surroundings (for example barrels of explosive powder).
I explain my plan (involving said barrels, and a couple of other things going BOOM), player A proposed other plans but their’s had problems that my plan didn’t. Player B was silent despite my @mentions.

Finally, everybody agreed to try my plan. The fight began… and after the surprise round nothing went as expected as the BBEG won the initiative and throw a big stormy map control spell that wiped out all fire (no BOOM without fire) and throwing B and myself to the ground with no visibility.

As the party caster, I managed to teleport player B out of the spell area, but I was still in the middle of a 40ft radius icy-stormy-hell with no visibility. I was effectively out of the fight, leaving A, B and my eidolon out. I told A and B that they had to make the decisions now, because I was literally no more than a rolling piece of meat inside a fridge at the time.

The Incident

Then 40 minutes of silence of player B, only broken by questions of player A and GM’s answers. But with no actions. The GM then made the statement that if they don’t play now, the BBEG will go forward. And then player B rage-quit

After that

When our GM informed us that player B had rage-quit, we paused and tried to think about what happened. In fact player A and B were discussing what to do in private. The fact that the GM pushed the game forward upset her. We arrived at the conclusion that maybe the pace of the game was too quick, not letting time for B to give her ideas.

Pace is important in fight, but fun for all at the table is more important.
So how can we handle the situation at our level (player, GM, group), and what tools (on Discord) or tips (social) can we use?

## Proving decidability and undecidablity of CFL DCFL problems [closed]

I am trying to understand how can I prove various problems of CFLs and DCFLs are undecidable or undecidable.

For context free grammars $$G, G_1, G_2$$, how can I prove following problems are undecidable:

1. Whether $$L(G)$$ is a regular language?
2. Whether $$L(G)$$ is a DCFL?
3. Whether $$L(G)^c$$ is CFL?
4. Whether $$L(G_1)\cap L(G_2)$$ is CFL?

For deterministic context free grammar $$D$$ and regular grammar $$R$$, how can I prove following problems are decidable:

1. Whether $$L(D)\subseteq L(R)$$
2. Whether $$L(D)=L(R)$$
3. Whether $$L(R)\subseteq L(D)$$

I gave following attempts:

1. I know whether $$L(G)=\Sigma^*$$ is undecidable. $$\Sigma^*$$ is regular language. So, problem 1 is undecidable.
2. Undecidability of this problem follows from undecidability of 1st problem, since set of regular languages is proper subset of set of DCFLs.
3. I am unable to come up with any logic for this.
4. Given that I know whether $$L(G_1)\cap L(G_2)=\emptyset$$ is undecidable. $$\emptyset$$ is CFL. So, problem 4 is undecidable.
5. Given that I know, $$L(G)\subset L(R)$$ is decidable, $$L(D)\subset L(R)$$ is also decidable as set of DCFLs are proper subset of set of CFLs.
6. Decidability of this problem follows from 5th problem.
7. I am unable to come up with any logic for this.

Was I correct with my attempt? Also can someone help me out for problem 3 and 7?

## problems with PDF export of notebook

I have a largish notebook (300 hundred pages when printed) that I have exported to PDF in the past (version 11?). I am having trouble with this in version 12.0. A PDF is produced (except once), but it will not display. In SumatraPDF, text does not display and graphics display with no text. In Acrobat, nothing displays and page errors are reported. I have other (smaller) notebooks that export successfully. Are there known problems with PDF export of notebooks? Size related? Diagnostic hints will be welcomed.

## I´m having problems with this Context Free Grammar

I´m having problems with this Context Free Grammar, I´m not able to convert the languaje from the photo to a Context Free Grammar, the mayor problem is how to pump both “sides” of the word to obtain same number of 0s and 1s, but, without creating series of 01010101, can someone explain to me a solution?