(a) A nave programmer writes the following Prolog program to…

Question Answered step-by-step (a) A nave programmer writes the following Prolog program to… (a) A na¨?ve programmer writes the following Prolog program to implement a quicksort. quicksort( [], []). quicksort( [X|Tail], Sorted) :- split( X, Tail, Small, Big), append( SortedSmall, [X|SortedBig], Sorted), quicksort( Small, SortedSmall), quicksort( Big, SortedBig). split( X, [], [], [X]). split( X, [Y|Tail], [Y|Small], Big) :- X>Y, !, split( X, Tail, Small, Big). split( X, [Y|Tail], Small, [Y|Big]) :- split( X, Tail, Small, Big). Unfortunately, there are two mistakes that will prevent it running as expected. What are these mistakes and how can they be corrected? [6 marks] (b) Explain how the operator ! in the split predicate works and why it is used here. [2 marks] (c) Our programmer now decides to improve the efficiency of the program by using difference lists. Explain how the technique works and modify the program to use difference lists by introducing a new predicate quicksort2 quicksort( List, Sorted) :- quicksort2( List, Sorted – [] ). [6 marks] (d) Comment on the space and time complexity of the execution of the two versions of quicksort for the call quicksort([2,5,7],X). [6 marks](a) Define Boyce-Codd normal form. [3 marks] (b) Suppose that a relation R has n attributes. How many distinct functional dependencies could be defined for R? [3 marks] (c) The union rule for functional dependencies states that if F |= X ? Y and F |= X ? Z, then F |= X ? Y ? Z (this can also be written as F |= X ? Y, Z). Prove this rule using only Armstrong’s axioms. [5 marks] (d) Heath’s Theorem states that if R(A, B, C) satisfies the functional dependency A ? B, where A, B, and C are disjoint non-empty sets of attributes, then R = ?A,B(R) ./A ?A,C (R), where ./A is the equi-join on the attributes of A. Prove this theorem. [9 marks] (a) Explain what is meant by the following statements:(i) f : N ? N is a total recursive (TR) function; [3 marks](ii) the sequence {fn : N ? N}n?N of TR functions of a single variable isrecursively enumerable. [4 marks](b) Show that no recursive enumeration can include the set of all TR functions ofa single variable. [4 marks](c) Suppose u(n, x) is a recursive enumeration of the sequence of TR functionsfn(x) = u(n, x). Show how to define a sequence {gn : N ? N} of TRfunctions of a single variable such that each gn is distinct from every functionfn, and also from each gk for k 6= n. [5 marks](d) Express the sequence {gn} as an explicit recursive enumerationv(n, x) = gn(x).  It is proposed to store a large number of records on a disk using Larsen’s methodso that any lookup can be done using only one disk transfer. All the records are oflength 200 bytes and each contains a 20 byte key. The data is to be held on a singledisk preformatted to contain 100,000,000 sectors each of size 4096 bytes. Readingmultiple consecutive sectors is regarded as a single transfer.(a) Describe Larsen’s algorithm in detail and, for the records and disk specifiedabove, state the disk block size, the signature size and the amount of mainmemory that you would choose to use. [10 marks](b) Carefully estimate the maximum number of records that could reasonably bestored on the disk assuming the sizes you gave in part (a). [6 marks](c) Discuss the advantages and disadvantages of different signature sizes.[4 m (a) Briefly describe the concept of coroutines as provided in BCPL, and outlinethe effect of the library functions createco(f, size), deleteco(cptr),callco(cptr, val), and cowait(val). [6 marks](b) Discuss the relative merits of BCPL coroutines versus those of threads suchas provided in Java. [6 marks](c) Outline the overall design and organisation of a BCPL program to performdiscrete event simulation using coroutines to implement the simulatedactivities. Concentrate on the design of the simulation event loop, theorganisation of the priority queue and what functions you would provide tosimplify the implementation of the activities. It would probably be sensibleto adopt a programming style similar to that used in Simula 67. You shouldhold simulated time as a global (integer) variable. [8 marks]5 Operating Systems II(a) Most conventional hardware translates virtual addresses to physical addressesusing multi-level page tables (MPTs):(i) Describe with the aid of a diagram how translation is performed whenusing MPTs. [3 marks](ii) What problem(s) with MPTs do linear page tables attempt to overcome?How is this achieved? [3 marks](iii) What problems(s) with MPTs do inverted page tables (IPTs) attempt toovercome? How is this achieved? [3 marks](iv) What problems(s) with IPTs do hashed page tables attempt to overcome?How is this achieved? [3 marks](b) Operating systems often cache part of the contents of the disk(s) in mainmemory to speed up access. Compare and contrast the way in which this isachieved in (i) 4.3 BSD Unix and (ii) Windows 2000. . Write  program to read data using CL register and check whether it’s positive or negative.: Write  program that asks the user for a positive integer value. The program should use a loop to get the sum of all the integers from 1 up to the number entered.Write  program that reads a set of integers and then finds and prints the sum of the even and odd integersImage transcription textQuestion 1 (1 point) Locate the FASTQTrimmer utility in Galaxy. Which of thefollowing is the correct ci… Show more… Show moreImage transcription textSummary: With its proposed acquisitionof UK-based Arm, Nvidia will completeits transformation from a ni… Show more… Show more  Computer Science Engineering & Technology Networking ELE 486 Share QuestionEmailCopy link Comments (0)