Question
To convert a fragment to a illustration base 16 (i.E. Hexadecimal) you could multiply it with the aid of 16, and the resulting integer part
To convert a fragment to a illustration base 16 (i.E. Hexadecimal) you could multiply it with the aid of 16, and the resulting integer part is the primary digit of the base-16 representation. Multiplying the fraction left over via 16 gets the second digit and so forth. Write a method that accepts an array of digits (base 10) and creates and returns a new array representing the equal fraction but now base 16. Your code must paintings for any period enter array, now not just certainly one of length one thousand, and you can make the output array have the equal period as your enter array.
[6 marks] (d) Suppose the enter in your approach in element (c) changed into of period 1000 and commenced off with the decimal digits of one 7 in it. Although the preliminary digits inside the output array are the proper hexadecimal representation of one 7 the previous couple of turn out to be looking bizarre. Explain. [3 marks] (e) One manner to ensure that numerical effects are accurate is to use interval mathematics. A price is represented as a pair of arrays, one representing a quantity much less than (or same to) the actual fee and one a fee extra than it. So if the usage of 6 decimal locations the no 1 7 might be held as a pair 142857, 142858. If the two very last digits differ by using at most 1 then the smaller of them can be regarded as completely correct. Using this concept, write code that accepts a fragment in decimal form and returns a vector denoting the identical fee in some other base n (now not necessarily 16) such that all the digits in the result vector are correct. Clarity for your code is to be preferred to performance, but if you are aware of precise methods in which the code you present is specifically inefficient, you have to note and give an explanation for them. [5 marks] 6 CST.2008.1.7 10 Programming in Java The following is one of the examples from the Foundations of Computer Science course: exception Change; fun change (until, 0) = [] exchange ([], amt) = raise Change alternate (c::until, amt) = if amt<0 then raise change else (c :: change(c::till, amt-c)) handle> trade(till, amt); (a) Define a Java elegance of your own (i.E. Do now not use any library magnificence that you could be privy to) to symbolize connected lists of integers. Provide it with methods that can be used to reverse a list and to append lists. Comment on whether or not your layout has led you to make the strategies for append and opposite static. [7 marks] (b) Prepare a method called change that works inside the identical way as the ML code proven above. Provide the elegance which you outline it in with a primary method that uses it to attempt to make exchange for 73p using 2p, 5p and 20p cash, printing the end result well. [7 marks] (c) If you have got lists of non-zero integers such that all the values in them are less than 256 and you've at maximum eight objects in any list you could percent eight eight-bit fields right into a unmarried 64-bit "long". That offers a representation that a few people may count on to be faster than the usage of lists represented through chained up times of a class. Re-paintings your exchange-giving code primarily based on the above concept, and modelling the usage of exceptions by making the alternate characteristic return -1L in the awesome case.
Show that there may be no manner of deciding by way of algorithms whether or not a preferred sign in system application with code p will terminate when started with preliminary statistics of zero in each check in. [10 marks] Show that there's no manner of determining via algorithm whether or not the blank individual will be revealed at some stage in the path of a fashionable Turing machine computation. [10 marks] Note: any fashionable shape of the undecidability end result for the overall halting hassle can be assumed, but must be stated actually. 11 Complexity Theory Explain the way to measure the size of a hassle in complexity theory. [3 marks] What is meant through lowering one hassle to every other? [4 marks] Given that the Boolean Satisfiability Problem is NP-whole, show that the Hamiltonian Circuit Problem for undirected graphs is also NP-complete
(a) What is a binary seek tree rotation, and the way are rotations beneficial in the creation of green seek tree algorithms? [2 marks] (b) Write pseudocode for a recursive characteristic pick out(x, i) which, given a binary seek tree with root node x, executes a series of rotations to move the i th biggest node to the basis of the tree and returns a pointer to the new root node. (c) Making use of select to cope with complex cases, write pseudocode for a recursive function delete(x, okay) which deletes the node containing key price okay from the tree and returns a pointer to the new root node. [5 marks] (d) Write a greater efficient model of delete which does not use recursion or rotation to carry out its work. How does its time complexity evaluate with your answer to component (c)? [7 marks] 12 Algorithms (a) Carefully describe the purpose and shape of a pass list. Provide a pseudocode definition for a skip-list node. [7 marks] (b) Write pseudocode to find an integer in a pass listing. [7 marks] (c) Describe conditions in which you would implement a pass listing in choice to a hash desk.
1. In each case below run the Extended Euclidean Algorithm using pen and paper on inputs (a, b) and in each case provide two things: (i) ged(a,b) (ii) a linear equation of the form s *a+t+b= gcd(a, b). (a) (a,b) = (49,27) = (b) (a, b) (77,41) (c) (a,b) = (76,43) Euclidean Algorithm; Discrete math problems!! Please solve this Question. You can also program this algorithm, and this will actually help you understand how the algorithm works, but remember that you will not be able to use your program on a test...
Step by Step Solution
There are 3 Steps involved in it
Step: 1
Get Instant Access to Expert-Tailored Solutions
See step-by-step solutions with expert insights and AI powered tools for academic success
Step: 2
Step: 3
Ace Your Homework with AI
Get the answers you need in no time with our AI-driven, step-by-step assistance
Get Started