Determine if a schedule is serialisable or not

I’m not sure I fully grasp the different kind´s of schedules. I have that a schedule is a sequence of transaction operations. A serial schedule is a schedule where the transactions are executed one after the other. A serialisable schedule is whenever executing the transactions sequentially, in some order, could have left the database in the same state as the actual schedule. Finally a conflict serialisable schedule is one where the transaction operations order can be changed to make the schedule serial while resulting in the same outcome.

If I have the following schedule $ R_1(A),R_2(B), W_1(B),R_2(A),W_1(A),R_2(B),R_2(A)$ , there is a non repeatable read happening as $ T_2$ will read different values for $ A$ and $ B$ , then the schedule is conflict serialisable because we can change the order of the operations to make the schedule serial but how can I determine if the schedule is serialisable or not?

Question about how can i determine if counting sort is the right option over other sorting algorithms

So, an exam’s exercise asks me to find an alghoritm that can determine if counting sort is the best solution, otherwise use another optimal sorting algorithm.

Now i find that solutions for that question given by my professors are wrong because they do something like( pseudocode)

Sorting(A,k) //where k is a value inserted by the user(?) {  max=a[0]; for i=1 to n // n=dim {     if( a[i] > max) update max with a[i] } if( max <= k*n) then countingsort(A)  else heapsort(A);  return A; 

Now that being said, K is passed but i dont get what this k exactly is, neither there is explanations in prof’s notes… i guess it is not the range between max/min otherwise why would he check for max if u already got the range?

my solution is:

Sort(A){     int max, i;     int min;     if( arr[0] > arr[1]){         max=a[0];         min=a[1];     }      for(i= 2 ; i < n ; i++){         if(a[i] > max) max=arr[i];          else if( a[i]< min) min=arr[i];     }     range= max-min+1; // range for counting sort     if(range/n < log n) counting sort(A,range);      else mergesort/heapsort(A......);      return A;     } 

If range/n is less than logn , it means that range is atleast < nlogn, which implies it “”should”” be better than other optimal sorting algorithms. It might be not the most accurate way but it seems like it should be something like that, shouldnt it?

Is it wrong to use a boolean parameter to determine behavior?

I have seen a practice from time to time that “feels” wrong, but I can’t quite articulate what is wrong about it. Or maybe it’s just my prejudice. Here goes:

A developer defines a method with a boolean as one of its parameters, and that method calls another, and so on, and eventually that boolean is used, solely to determine whether or not to take a certain action. This might be used, for example, to allow the action only if the user has certain rights, or perhaps if we are (or aren’t) in test mode or batch mode or live mode, or perhaps only when the system is in a certain state.

Well there is always another way to do it, whether by querying when it is time to take the action (rather than passing the parameter), or by having multiple versions of the method, or multiple implementations of the class, etc. My question isn’t so much how to improve this, but rather whether or not it really is wrong (as I suspect), and if it is, what is wrong about it.

Is it wrong to use a boolean parameter to determine behavior?

I have seen a practice from time to time that “feels” wrong, but I can’t quite articulate what is wrong about it. Or maybe it’s just my prejudice. Here goes:

A developer defines a method with a boolean as one of its parameters, and that method calls another, and so on, and eventually that boolean is used, solely to determine whether or not to take a certain action. This might be used, for example, to allow the action only if the user has certain rights, or perhaps if we are (or aren’t) in test mode or batch mode or live mode, or perhaps only when the system is in a certain state.

Well there is always another way to do it, whether by querying when it is time to take the action (rather than passing the parameter), or by having multiple versions of the method, or multiple implementations of the class, etc. My question isn’t so much how to improve this, but rather whether or not it really is wrong (as I suspect), and if it is, what is wrong about it.

Is is possible to determine if a given number is xor combination of some numbers?

I have been given a number Y which is ($ a$ xor $ b$ xor $ c$ xor $ d$ xor $ e$ ) of some numbers ($ a$ ,$ b$ ,$ c$ ,$ d$ ,$ e$ ) and another no X. Now i have to determine if X is a xor combination of ($ a$ ,$ b$ ,$ c$ ,$ d$ ,$ e$ )

e.g – ($ a$ xor $ d$ ) , ($ b$ xor $ c$ xor $ e$ ) , ( $ a$ xor $ e$ )

What i know clearly is that lets say X= ($ b$ xor $ d$ ) , Now if I xor X and Y i get ($ a$ xor $ c$ xor $ e$ ), as ( $ b$ xor $ b$ =0 ) and if it was some number not a xor combination (say $ p$ ) then i would have got ($ a$ xor $ b$ xor $ c$ xor $ d$ xor $ e$ xor $ p$ )

How should i approach this question?

Determine if a graph has exactly 1 cycle using a SAT solver

I have a connected undirected graph whose edges are either enabled or disabled. I want to create a set of clauses that are SAT iff all enabled edges are part of a single loop.

If I assert that each vertex has either 0 or 2 enabled edges, then graphs where all enabled edges are part of a single loop will satisfy the clauses. However, graphs with multiple disjoint loops can will also satisfy those clauses. How can I make sure that only 1 loop graphs satisfy the clauses?

How to determine the complexity of a mixed strategy NASH equilibrium problem

How to determine a complete-information mixed strategy NASH equilibrium problem with finite numbers of players and strategies? That is, there exists a payoff matrix which shows all the relation among all the player’s profile. For example, 5 player all have 5 strategies, and all of them know the results for all 5*5*5*5*5 strategy combinations.

Another question: If I concatenate all player’s the KKT conditons to solve this problem, what is the complexity of the problem?

If I multiclass into 2 or more spellcasting classes, how do I determine my known/prepared spells?

If I multiclass into 2 or more classes/subclasses that can cast spells, how do I determine what spells I know or can prepare?

For instance, if I am playing a multiclassed character with 1 level in warlock, 2 levels in bard, and 3 levels in paladin, how do I determine which spells I know/have prepared?


There are many questions on RPG.SE asking about individual multiclassed combinations of spellcasting classes, but there was no question covering the general case for all of these questions to be marked as a duplicate of. Questions should only be marked as a duplicate if they are asking the same thing, or if one question is entirely a subset of the other. Previously, there was no such general question about this topic; thus, as I suggested on meta back in January, I went ahead and asked this question.


Related:

  • Can a multiclass character use either of its spellcasting modifiers for spells?
  • Can a multi-class spellcaster have one thing be two different focuses?

How to determine if this problem is decidable?

I am currently stuck on the following problem:

Given a WHILE-program P and the knowledge that all input variales are set to 0, is it decidable if a specific instruction is reached 1000 times?

My intuition is that it is not decidable. Rice’s theorem says that a non-trivial property of a program is always undicidable. But I am not sure if “a specific instruction is reached x times” even qualifies as a “property of a program”.

I am stuck on this for a while now, so I hope someone can give a hint where to look to find an answer to this problem. Thank you so much! All help is greatly apprechiated.