Assume variables A, B, C and D are stored in memory locations 100, 101, 102 and 103, respectively. Using any of the sample machine language instructions given in this section, translate the following pseudocode operations into machine language instruction sequences. Have your instruction sequences begin in memory location 50:
(a) Set A to the value of B x C x D (that is B multiplied by C multiplied by D). You can use a MULTIPLY command for the multiplication.
(b) Set A to the value of B + C + D. You can use an ADD command
Write an algorithm that takes the positive integer ‘n’ as input and returns the exponent 2^n as output. Analyze the time complexity of the algorithm using program step table method.
Given the set of numbers S = {16, 3, 7, 10, 25, 1}, draw the recursive Merge Sort tree and Merge tree.
Sort the following elements using merge sort technique
using the Divide and Conquer strategy. {12,45, 6, 18, 10, 4, 3, 1, 13, 15, 16}
Determine the time and space complexity of the following algorithm.
Algorithm A(x,n)
Begin
for i := 1 to n do
for j : = 1 to i do
for k := 1 to j do
x := x+1;
End
Write the algorithm, draw the flowchart, write and execute the Dart code for the following problem.
A student’s Midterm grade is 60 and the Final Grade is 80. The weight of Midterm and Final exams are % 40 and % 60 respectively.
Find the semester grade for this student.
Using appropriate diagrams, analyses the process flow for recognition evolvement, typically arranged as a hierarchy
Prove the theorem
The elass of regular languages is closed under union operation. In othe words, if Al
and A2 are regular languages, so is (Ai UA2)"for the following languageL-twiw acepts even mumber of 'a' or even number of "b'.
On the MIPS architecture, for example, the load-linked and store-conditional instructions can be
used in tandem to build locks and other concurrent structures. The C pseudocode for these
instructions is shown below. Alpha, PowerPC, and ARM provide similar instructions.
// Actions of thread Ti
1: int LoadLinked(int *ptr) {
2: return *ptr;
3: }
4: int StoreConditional(int *ptr, int value) {
5: if (no other thread has updated *ptr since the last LoadLinked access to *ptr by thread Ti)
6: {
7: *ptr = value;
8: return 1; // success
9: }
10: else {
11: return 0; // failed to update
12: }
13: }
The key difference comes with the store-conditional, which only
succeeds (and updates the value stored at the address just load-linked from) if no intervening store
by another thread to the address has taken place. In the case of success, the store-conditional returns
1 and updates the value at ptr to value; if it fails, the value at ptr is not updated and 0 is returned.
Please develop a mutex lock using this instruction.
The following flowchart finds if the triangle is isosceles, equilateral, or scalene. Some boxes in the flowchart are filled in for you, fill in the rest of the details.
Hint: In an equilateral triangle three sides are equal.
In an isosceles triangle two sides are equal.
In a scalene triangle three sides are not equal.