(iii). Data coherence problem and starvation cause a lot of havoc in computer systems. As an Operating System designer and/or developer, you are required to do the following: (α)…Distinguish between data coherence problem and starvation in the context of concurrency in operating systems. Give practical examples to illustrate your answer. (β).…Discuss how the two problems in (α) can be solved in computer systems.
Fill an array with digits 1,2,3,4,5. In c++
Write an algorithm to read 100 numbers then display the largest.
Which is the most suitable graph representation scheme for a dense graph
class Graph:
def __init__(self,vertices):
self.V= vertices self.graph = []
def addEdge(self,u,v,w):
self.graph.append([u,v,w])
def find(self, parent, i):
if parent[i] == i:
return i
return self.find(parent, parent[i])
def union(self, parent, rank, x, y):
xroot = self.find(parent, x)
yroot = self.find(parent, y)
if rank[xroot] < rank[yroot]:
parent[xroot] = yroot elif rank[xroot] > rank[yroot]:
parent[yroot] = xroot else :
parent[yroot] = xroot
rank[xroot] += 1
def KruskalMST(self):
result =[] i = 0
e = 0 self.graph = sorted(self.graph,key=lambda item: item[2])
parent = [] ;
rank = []
for node in range(self.V):
parent.append(node) rank.append(0)
while e < self.V -1 :
u,v,w = self.graph[i] i = i + 1
x = self.find(parent, u)
y = self.find(parent ,v)
if x != y:
e = e + 1
result.append([u,v,w]) self.union(parent, rank, x, y)
for u,v,weight in result:
print ("%d -- %d == %d" % (u,v,weight))
b- Find the complexity of your program?
c- Show the loop invariant?
PRINT-OPTIMAL-PARENS(s, i, j){
if (i=j) then
print “A”i else{
print “(”
PRINT-OPTIMAL-PARENS(s,i,s[i, j])
PRINT-OPTIMAL-PARENS(s, s[i, j] + 1, j)
print “)”} }
b- Find the complexity of your program?
c- Show that the parenthesization algorithm is loop invariant?
Write true or false for the following statements
1.1 The body of a loop executes at least once in a post-test loop.
1.2 Nested loop is a process of having an if statement inside another if statement.
1.3 A pseudocode includes all the declarations and all types of statements.
1.4 When the loop-continuation condition in an iteration statement never becomes false then that loop can become an infinite loop.
1.5 Continue and break statements may be embedded only within iteration statements.
A project that requires participants to provide algorithms for searching files in a given structure is taking place. As the lead engineer for your team, propose a model and its corresponding algorithm to efficiently traverse the presented folder structure. The algorithm should list each step in the process and the corresponding final order
True or False Statements
1.1 The body of a loop executes at least once in a post-test loop.
1.2 Nested loop is a process of having an if statement inside another if statement.
1.3 A pseudocode includes all the declarations and all types of statements.
1.4 When the loop-continuation condition in an iteration statement never becomes false then that loop can become an infinite loop.
1.5 Continue and break statements may be embedded only within iteration statements.
For the periods 2014 to 2019, ESKOM’s electricity percentage price adjustments are given in the
following table:
2014/15 2015/16 2016/17 2017/18 2018/19
7.05% 31.70% 8.18% 1.62% 2.82%
Table 1: Average percentage price adjustments
a) Find the Average (arithmetic mean) percentage price adjustment from
2014 to 2019 (5