# Problem Solving | Sample Computer Science Assignment

## Problem 1

A Linear Programming can take different types of forms such as either infeasible or unbounded or there is an optimal value of objective which contains a specific value [0, + ∞].

The above statement can be modified by using <, >,= in constraints.

First, it needs to observe that there is a maximization or a minimization problem that depends upon the problem and observe whether the function of the objective can be maximized, minimized, or not. Here, the constraints can be either** inequalities ( <=or >=) or equalities** **as per the requirement. **Some variables are used for unrestricted based on the sign and it may have both **Positive **and **Negative **Value. A general program with linear function is used in the decision variables x1; : : : ; xn is

Therefore the following form:

**Maximize or Minimize z = c0 + c1x1 + : : : + cnxn**

**Where**

The problem of the data in the linear program mainly consists of the functions of cj (j = 0,….,n), bi (i = 1,….,m) and aij (i = 1,…., m, j = 1,….,n). Cj is referred to the function of the objective which has the co-efficient value of xj or, simply, the coecient of cost is xj . bi is mainly denoted as right-hand-side (RHS) of the equation i.

**Note that: **The term consultant C0 can be omitted without the effects on the optimal solution set. The program of linear is always in standard form if

- There are the maximization on the program
- Their equations are only on equalities (not inequalities)
- All the variables are restricted on the non-negative functions.

In the form of a matrix, a linear program is always in the form of standard, can be written as:

**Max z = c^T x**

Subject to:

Ax = b, x >= 0:

Where

are vectors of the column, cT mainly denotes the** transpose vector c**, and the A = [aij ] is the m n matrix whose i; j are the element is aij .

Any type of linear program can be transformed into an **equivalent linear program **in standard form. Various conditions are determined from the above equations

- If the function of the objective is implemented with the minimize function such z = c1x1 + : : : + cnxn then we can simply maximize z’ = – z = -c1x1,….., – cnxn.

For Example, the linear program

**Minimize z = 2×1 – x2**

This is subject to

**Equivalent to the linear program **

** **

With the variables of decision x+1; x1 ; x2; x3; x4.

In some of the cases, other forms of linear program are used. It can be implemented through the form of

Hence, the linear program can be modified with different constraints. (Proved)

It is a canonical form that can be replaced by the standard form of linear programming by using Ax < = b by Ax + Is = b, s >= 0 where s is the slack variables of vector and I is the m*n identity matrix. Similarly, it can be replaced by using canonical form such as

## Problem 2

**Proposed Algorithm for Bin packing where all item sizes are greater than ⅓**

The algorithm of bin is used for creating output in bins which are at least 2/3 full and sizes are 1/3. **In this condition, the ratio of approximation for the algorithm is 3/2.**

In this algorithm, the inputs are classified into 4 different ranges (0-1/3), (1/3-1.5/3), (1.5/3-2/3) and (2/3-1) are called 𝑆, 𝑀1, 𝑀2, and 𝐿, respectively.

In the primary step, the L number of items is put in the separate files of output bins then sorted M1 and M2. Try to match all the items with M2 with the possible items of M1. After the step, some of the items have remained in M1 as well as in M2.

**𝑀****1 items with each other and add |****𝑀****1|/2 to ****𝐵𝑖𝑛****−****𝑐𝑜𝑢𝑛𝑡𝑒𝑟**** (The number of users in bins).**

**Next step, try to match ****𝑀****2 items with items of ****𝑆****. Finally, ****𝑆**** items are matched with each other.**

*Algorithm for Bin*

Read inputs & classify them into 𝑆, 𝑀1, 𝑀2, and 𝐿

Sort 𝑀1& 𝑀2

For (any item 𝑎 in 𝑀2)

If (𝑎 can be matched with at least an item in 𝑀1)

Match 𝑎 with the biggest possible item in 𝑀1;

Eliminate them & Bin-counter ++;

Else continue;

Bin-counter + = |𝑀1/|2;

For (any item 𝑎 in 𝑀2)

Do

Choose an item 𝑏 in 𝑆;

𝑎=𝑎+𝑏 & eliminate 𝑏 & 𝑐=𝑏;

While (𝑎 ≤ 1)

Eliminate 𝑎 & put 𝑐 in 𝑆 & Bin-counter ++;

While ( 𝑎≤1)

Choose an item 𝑏 in 𝑆 & 𝑎=𝑎+𝑏 & 𝑐=𝑏;

Eliminate 𝑎 & Bin-counter++ & put 𝑐 in 𝑆

End

**Definition**

**P **is the bin numbers in the solution of OPT and **P* **is bin numbers in the **proposed algorithm.**

**Lemma**

If the ⅔ of the size of each output is already used and full the bin, the ratio of the approximation is at least 3/2.

**Proof**

Consider the worst condition for the output bins and completely full based on the solution of OPT. Suppose the sum of the input items are W. On that condition,

**Theorem**

**The proposed algorithm of the bin is a 3/2-approximation algorithm and with a difference of ⅓. (Proved)**

## Problem 3

**Theorem: F-approximation Algorithm**

A set E’ of elements in E is independent if, for all e1, e2 ∈ E0, there is no Si ∈ C such that e1, e2 ∈ Si.

User has to analyze the frequency of each of the elements based on the numbers of set which contains the entire element. Thus, F is the large number in the set from **S **and it needs to use cover C for implementing it with approximation. It is also clear that the elements are preferred for the algorithm depends upon the independent set. However, there may be some element that contains the elements of the set and use the un-weighted set Cover approximation algorithm which is used by a greedy strategy to yield in an approximation of n.

**Algorithm**

Set Cover(E, S):

- C ← ∅.
- While E mainly contains all the elements which are not covered by C

(a) Us the set Si-containing all greatest number of elements which are uncovered.

(b) Add Si to C.

**Proof**

Let K = OPT and the Et is the set of elements that not covers I with the function E0 = E. OPT mainly covers the Et and not more than elements in the sets of k.

## Problem 4

A dice which is conventional is denoted by {1,2,3,4,5,6}. It consists of six faces with the value of the face is 1 to 6.

**Problem 1**

p(x) is a probability-based on the function for the random variable which are discrete in X if, for all x, p(x) >= 0, and p(x) =1. In this case, p(x) = P(X = x) is the probability which consists diifferent values with the occurrence of X in the population.

**Figure 1: Probability – Sample space for two dice (outcomes)**

** **The outcomes such as (1, 1), (2,2) are called the doublets. The pairs are consists of several outcomes. When two dice are rolled, It gives n(S) = (6 × 6) = 36.

Now, A = {(1, 4), (2, 3), (4, 1), (3, 2)}, and

B = {(3, 1), (3, 2), (3, 3), (3, 4), (3, 5), (3, 6), (1,3), (2, 3), (4, 3), (5, 3), (6, 3)}

A ∩ B = {(2, 3), (3, 2)} ≠ ∅.

Hence, A has highest total value of face than, then A is a better dice. (Proved)

**Problem 2**

Therefore, the total number of all possibility of outcomes = 36

Number of the outcomes which is favorable = E

Number of outcomes which are having equal numbers for both dice are

= 6 [namely, (1, 1), (2, 2), (3, 3), (4, 4), (5, 5), (6, 6)].

So, by definition, P(E) = 6/36 = ⅙

Therefore, the second statement is correct.

## Problem 5

The sequence of binary is mainly implemented with 0s and 1s. There are two types of sequences with their digits such as S 1 = 0100101110 and s2 = 0110100110

if α = return nullable(S)

Initialize table T with false everywhere

for i ∈ {0, 1, . . . , |α| − 1}

// for each terminal a,

if α[i] = a then T[i, i + 1, a] := true

for k ∈ {2, 3, . . . , |α|}

for i ∈ {0, 1, . . . , |α| − k}

for j ∈ {i + 1, i + 2, . . . , i + k − 1}

// for each production A → θ1θ2,

if T[i, j, θ1] ∧ T[j, i + k, θ2]

T[i, i + k, A] := true

for i ∈ {0, 1, . . . , |α| − k}

repeat |G| times

// for each production A → θ,

if T[i, i + k, θ] then T[i, i + k, A] := true

return T[0, |α|, S]

The above is used for representing the boundary size which is used on the binary program. The syntax is always simpler and it is used for testing the functions of zero. The distance between S1 and S2 is number of the digits which are different. The given distance is d (s1, s2) = 2

It is stated to use the sequences for n programs of binary and the sequences are generally s1, s2,…., sn with all of the length. It mainly minimizes and maximizes all the distance between t and any of the si. It needs to use the Hamming distance between two of the strings and which are also equals with the position. For example, if the code is 3 bit and consists of two code words such as 111 and 000. Then the space distance contains all the 8 bit of the code such as 000, 011, 001, 101, 110, and 100. In the code, the single error of the bit occurs within the distance of Hamming based on the original codes. Thus, the minimum distance for hamming **d** is between the codeword’s and can detect the errors mostly on d-1 and make the correction using [(d-1)/2]. By replacing the values, the user can get the equation which is provided such as

## Problem 6

**Option Task 1**

**Four Color Map Problems**

**(i) Spiral Chain Coloring – Direct Proof**

Let us denote the four colors by the sets C={G, Y, R, B }≡ {1,2,3,4}

The proof is one of the vital proof of the four-color theorem and also quite different. It is also known as the assisted proof of computer. The main features of the proof are to use graph theory such as maximal, planner, cycles and many more. It is a special path that can be called a spiral chain. The chain of the spiral is defined for the basic region of the provided map or equivalently uses the graph of the maximal planner.

**(ii) Spiral Chain in the Tait Color – Indirect Proof**

From the four-color theorem, it is easy for reprinting that the every cubic graph of planar has three edges of coloring since the Tait found it with the sequential effort. The old conjecture is mainly used for outline the proof which is independent of the famous conjecture. It is mainly rely on the planar of cubic bridgeless (Lee *et al. *2020, p. 362). Any planar which is cubic can be used for decomposing into the disjoint of chaining on a spiral. Then, it is based on the decomposition of a simple algorithm of three -edge-coloring.

**(iii) Double Spiral Chain – Inductive Proof of Kempe’s**

Since, there are six possible chains of Kempe such as RG, RG, BY, BG, GY, RY types, it increases the length of one chain of Kempe by using the suitable switching of color and then use the length of the chain in BY (Chae *et al. *2019, p. 80). The chain remains same as it has the maximum length which is possible in the Kempe chain based on the function of Cs is the main. Instead of switching, one can use new colors for generating a suitable length that exists through the Kempe- Chain in Cs.

**(iv) The Victorian Age Proof – Fourth Proof**

Starting from the point of classic tedious, the four-color theorem is based on the failure of Kempe of reducibility of cases of a pentagon (Jia *et al. *2017, p. 4507). It is a correct proof for turning the large configuration and follows the argument of Kempe. The fourth proof mainly gives the idea about the implicitly bypassing the color in the problem of three-coloring of planar graphs within the proof of construction. In fact, the algorithm is used for the proof without relying on the color theorem.

### References

Chae, J., Steed, C.A., Goodall, J. and Hahn, S., 2019. Dynamic Color Mapping with a Multi-Scale Histogram: A Design Study with Physical Scientists. Electronic Imaging, 2019(1), pp.680-1.

Jia, Y., Zheng, Y., Gu, L., Subpa-Asa, A., Lam, A., Sato, Y. and Sato, I., 2017. From rgb to spectrum for natural scenes via manifold-based mapping. In Proceedings of the IEEE International Conference on Computer Vision (pp. 4705-4713).

Lee, H., Kim, K. and Lee, Y., 2020. Development of Stiffness Measurement Program Using Color Mapping in Shear Wave Elastography. Diagnostics, 10(6), p.362.