COMP1051 Computational Thinking exam questions

अब Quizwiz के साथ अपने होमवर्क और परीक्षाओं को एस करें!

Give two illustrations of principles of Computational Thinking in the context of hardware.

'Processing in parallel ' in multi-core or GPGPU computing. 'Using abstraction and decomposition in tackling a large complex task' in IC design and computer system design. 'Prefetching and caching in anticipation of future use' in caching within CPUs. 'Interpreting code as data and data as code' in processor architectures.

What is the difference between a maximum independent set and a maximal independent set in a graph?

'maximal' independent set: an independent set that is not contained in any other independent set (but where there might be a totally different independent set that contains more vertices). • A maximum independent set in G is an independent set of the greatest size possible.

Give a regular expression that denotes the set of strings over the alphabet {a, b} consisting of strings with the property that any a must always be followed by bb.

(abb)*(abb|e) // b***(abb)**(b|ǫ)

Give a regular expression that denotes the set of strings over the alphabet {a, b, c} consisting of strings with the property that there is always at most one c.

(a|b)**c(a|b)**

What is a process control block (PCB) and what is one used for by the operating system? Name 3 items in a PCB.

- A data structure that the kernel uses in order to manage a process, allowing the current situation/state of a process to be fully understood. - The process' unique ID - The current state of the process - CPU scheduling info (e.g. process priority, events pending, etc.) - The PC (program counter) - Values of other CPU registers

What drives the evolution of programming languages?

- Curiosity and creativity - Productivity: to speed up software development, RAD (rapid application development) languages such as python were developed. - Reliability: to include features such as type checking and exception handling (dealing with errors) - Data security issues - Execution speed: new languages were developed for optimal performance with multi-core computers (parallel computing).

Essential features of any programming language?

- Ease of use for the programmer - Low maintenance costs - support abstraction to allow addition of new features - support testing, debugging, & program verification (proving programs are correct).

Explain the principle of mutual exclusion and give an illustration to show that ensuring mutual exclusion is important.

- Multiple threads/processes need to synchronise & communicate with each other. - This leads to the problem of mutual exclusion, i.e ensuring two threads are not in critical section at the same time. (Critical section: exclusive access to some shared resource such as a memory location). See notes for example

Give three different notions relating to general problem solving that are key concerns in Computer Science?

- The constructive nature of solutions - The repeated application of solutions - The concern with and measurement of difficulty of solving problems

Detail four different functions of the operating system.

- The operating system controls and organises the use of hardware by different programs and all access to hardware is through the operating system. - Managing the machines resources efficiently, I.e. managing the CPU, hardware, memory, etc. It starts and stops programs and ensures that when a program is stopped, the memory allocated to this program is freed up for use by other programs and the processor. - Deals with system calls, i.e. retrieving files and inputs/outputs. - Data security. - The operating system facilitates error handling and recovery when programs don't do what they are supposed to do. -It tries to provide some limitation to the effects of badly written or maliciously written programs.

Explain the principle of context switching with regard to process control blocks.

- The process of an OS pausing one process and resuming another. Very time consuming. - Context switching entails managing the PCBs, as different processes are given access to the processor

Explain the difference between a byte and a word in relation to computer architecture. How is the size of a word related to the width of a bus?

1 byte of storage consists of 8 bits. A word, a number of bytes, is the amount of data that can be handled by the processor as one unit, and is equal to the bus width

What do we mean when we say that a MIPS (Microprocessor without Interlocked Pipeline Stages) instruction is 32 bits wide?

32 registers. Each instruction is encoded to 32 bits as the memory has 2^32 memory locations so the address bus is 32 bits wide

Phases of compilation?

4 phases 1. Lexical analysis 2. Syntax analysis 3. translation 4. code generation 1. HLPL's are converted to tokens (basic syntactic components) in a token stream 2. Token stream is converted into a parse (syntax) tree 3. The parse tree is flattened into a linear sequence of intermediate code. 4. Converts intermediate code into assembly, then to machine code

In order to execute a high-level program we must first convert it into machine code so that the CPU can 'understand' it. Briefly explain the difference between compilation and interpretation. How are Java programs executed?

A compiler translates HLPL's into machine code for execution by the CPU. An interpreter translates one instruction at a time as needed, with the translations interspersed (II) with the activity of the program itself. Compiled programs tend to run faster due to point (II). Time is spent optimising during the compilation process, leading to enhanced performance. Errors are reduced during compilation due to analysis for bugs taking place. Interpreted programs use memory better as only a small number of instructions are stored at a time Also facilitates development as it cuts out the compilation time; which is repeated again and again after every change in the code. For large code blocks, compilation time after editing is a big issue. Java programs are first compiled into byte code, and then this is translated by a Java Virtual Machine for the target processor.

What is a Boolean function?

A function which only returns either true (1) or false (0).

What is a graph? What is a proper colouring of a graph and an op- timal colouring of a graph? Describe two different algorithms (in En- glish) that enable you to colour graphs. Explain whether or not your algorithms yield an optimal colouring (you may use graphs to illustrate your answer if you wish). Show how your algorithms proceed when you wish to decide whether the graph in Fig. 1 can be coloured using 4 colours.

A graph G(V,E) Has a finite set V of vertices A set of unordered pairs E of distance edges, where no edge appears more than once in E and edge (u,v) = edge (v,u) If (u,v) is in E then we say that u and v are adjacent. A graph colouring is: - Proper when it is such that any two adjacent nodes are coloured differently - Optimal if it is proper and uses as few colours as possible. 1. Greedy algorithm The colours are put in some arbitrary increasing order The vertices are named in an order The algorithm works through the vertices in order, choosing the legal lowest colour available 2. • choose a vertex to colour so as to use the 'lowest' colour available; • if there is more than one possible vertex to colour then break ties using the vertex ordering. So, at any point within the execution of our algorithm we first run through the list of uncoloured vertices in order looking for a vertex that we can legally colour blue. If we find one then we colour it blue and consider which vertex to colour next in the same way. Otherwise, we run through the list of uncolored vertices, in order, looking for a vertex that we can legally colour green. If we find one then we colour it green and consider which vertex to colour next. If we can't colour a vertex green then we move on to yellow and so on. If our algorithm results in a 4-colouring of our graph then we answer 'yes'; otherwise, we answer 'no'.

What is a hardware description language?

A language for the purpose of formally describing digital logic circuits. Useful as it allows the function fo a hardware to be described without having to actually build the implementation (costly). (A piece of hardware can be modelled before being physically built.)

What is the real-world register allocation problem? Explain how we might abstract this problem as a graph colouring problem.

A large number of program variables are allocated to a small number of k CPU registers. Not all program variables are in use at the same time. If they are, they have to be assigned to different registers. Program variables are abstracted as nodes and two nodes are joined by an edge if they are in use at the same time. We can build an allocation of program variables to k registers, if and only if the abstraction graph can be coloured using k colours.

Modern parallel computing can come in many shapes and forms. Briefly explain the fundamental difference between multi-core computing and GPGPU computing.

A multi-core computer is a computer where more than one processor is integrated on one IC. GPGPU computing uses the processors within the graphics processing unit to compute with rather than deal with the screen pixels.

What is the real-world map-colouring problem? Explain how we might abstract this problem as a graph colouring problem. What is a planar graph? Explain how planar graphs and maps are related. Is every graph a planar graph?

A plane map of regions, each contained within a continuous border, must be coloured so that any two touching regions must be coloured differently. We create a graph where each vertex is a region, and any two vertices joined by an edge must be coloured differently. A planar graph is a graph that can be drawn on the plane so no two edges overlap. Every map produces a planar graph Kuratowski's Theorem from 1930 characterizes exactly which graphs correspond to maps. The theorem says that a graph is planar, if, and only if, no subgraph (that is, subset of vertices and some of the edges joining them) can be obtained from the graphs K3,3 or K5 by sub-dividing edges, where a sub-division of an edge is the placement of a new vertex on it.

What is process within an operating system and what are the two essential elements of a process? Is it the case that an operating system for a CPU with one processor can only have one process?

A process is an executing program Consists of thread(s) and address space Threads: instructions to be carried out sequentially Address space: Memory locations that the process can read and written to. NO

Define carefully what a regular expression is and explain how a regular expression is used to denote a set of strings

A regular expression over some alphabet Σ, a finite set of symbols, is defined as any a ∈ Σ is a regular expression ∅ and E are special regular expressions if ω and ω′ are regular expressions then so are: (ωω′) (ω|ω′) (ω∗) a denotes the set of strings {a} ∅ denotes the set of strings {} (the empty set of strings) and E denotes the set of strings {E} (the set containing just the empty string E) Regular expressions define sets of strings called regular languages, which are accepted by finite state machines

What is the real-world travelling salesman problem? Explain how this problem is usually abstracted so that it is amenable to computational solution. Illustrate how this abstraction might not be in keeping with reality

A salesman wishes to compute the shortest tour of a given collection of cities, to save time, money, and fuel. The problem is abstracted by considering the number of cities, distance between them (or time), whether the distance/time fluctuates due to traffic flow conditions, the viability of certain city to city journeys (are there obstacles?) How close the abstraction is to reality depends on how much time, money and computation resources are put into it.

Give a precise definition of a search problem and of a solution of a search problem

A search problem S consists of: • a set of instances I; • a set of solutions J; and • a binary search relation R ⊆ I × J. In order to solve a search problem, for any instance x ∈ I, we need to • find a solution y ∈ J such that (x, y) ∈ R, if there is one • answer 'no' if there is no solution y for which (x, y) ∈ R. Sometimes our search problem might be such that for every x ∈ I, there is exactly one y ∈ J such that (x, y) ∈ R.

What is a transistor? The two main types?

A semiconductor device used for amplifying or 'switching' electronic signals. The two main types are NPN and PNP: NPN: if base voltage is 'on', current can flow PNP: if base voltage is 'off' current can flow

What is the relationship between regular expressions and finite state machines?

A set of strings is represented by a regular expression if, and only if, it is accepted by a finite state machine (such sets of strings are called the regular languages).

What is abstraction in relation to real-world problem solving? How does abstraction in Computer Science differ from abstraction in other subjects?

Abstraction is a technique for managing complexity in computer systems. Abstractions need to be represented and manipulated in a computer program, and mirror reality closely enough so that solutions still apply with regards to the real-world problem. In other subjects, abstraction is characterised as the process of eliminating specificity by ignoring certain features. Abstraction in computer science tends to be multi-layered and concerned more with information 'hiding' rather than 'information neglect'.

Give two illustrations of principles of Computational Thinking in the context of problem solving

Abstraction, literally anything in this topic Algorithm, greedy colouring of graphs or independent sets

Give two illustrations of principles of Computational Thinking in the context of instruction set architectures and operating systems.

Abstractions = Life of a process Algorithms = Interrupts and PCB managing order of processes

Define an algorithm. How is this different to a programming language? How many different implementations of an algorithm are there in a programming language?

Algorithm: a sequence of precise instructions, taking an input and giving an output, which can be applied generally to data. Programming language: a language with defined syntax which translates an algorithm into a program which a computer can execute. Infinitely many

Explain what an interrupt is and how the operating system uses interrupts to deal with peripheral devices that operate much more slowly than the CPU

An interrupt is a signal that alerts the CPU when raised, but allows other tasks to be handled by the CPU while the program waits for an input, preventing bottleneck. Once raised, it is signalled along a bus line connecting CPU and ip/op device. The interrupt handler makes necessary arrangements. Imagine a program requiring input from the keyboard, requiring considerable time for request and wait for input. The operating system allows the CPU to continue with other tasks whilst waiting for input. The input from the keyboard is only dealt with when the operating systems' interrupt handler announces that an interrupt has been raised (that is, that such keyboard input has been entered). The interrupt is signalled on one of the lines of the bus connecting the CPU and the input/output device. The interrupt handler makes our paused program resume.

Give a precise definition of an optimisation problem and of a solution of an instance of an optimisation problem.

An optimisation problem O is defined as follows: • it consists of a set of instances I; • for every instance x ∈ I, there is a set of feasible solutions f(x); • for every instance x ∈ I and for every feasible solution y ∈ f(x), there is a value v(x,y) ∈ N = {0,1,2,...} giving the measure of the feasible solution y for the instance x; and • there is a goal which is either min or max.

What is a crown graph on 2n vertices? What is the smallest number of colours that can be used so as to obtain a proper colouring of the crown graph?

An undirected graph with two sets of vertices {u1, u2, ... un} and {v1, v2,... vn} where there is an edge between ui and vj whenever i=/=j (every vertex in set one is connected to every vertex in set two except the one directly opposite it) 2 colours the issue is finding the ordering of vertices to obtain this optimal solution.

What is the essential rule to bear in mind when developing an abstraction of a real-world problem?

As regards map-colouring, we need to abstract the essential information relevant to the solution of an instance of the problem and represent this in a form suitable for access by some program. The abstraction must be as close to the real world problem as possible while still accessible by some program to solve

What is a basic principle as regards different types of memory and its physical distance from the CPU?

As you get closer to the CPU, the cost and performance of the memory increases.

Which algebraic notation is normally use to specify the syntax of a programming language?

Backus Naur form

Purpose of data bus?

Carries the contents of registers between the processor and main memory.

Outline a greedy algorithm for finding an independent set in a graph. Does your algorithm solve the Independent Set (optimisation) problem (optimally)? (If so then you should explain why; if not then you should provide a counter-example.) Show how your algorithm proceeds on the graph in Fig. 1.

Choose vertex v in graph of smallest degree and add to independent set. Remove v and its incident edges from original graph, as well as v's neighbours and their incident edges. Repeat with new, smaller graph Halt when graph is empty. Independent set done.

What is Moore's Law?

Coined by Gordon Moore in 1965, the law states that transistor capacity (density) doubles every 18-24 months.

Give an advantage of compilation over interpretation, and of interpre- tation over compilation

Compiled programs run faster due to enhanced performance thanks to optimisation during the compilation process. Interpreted programs facilitate development by cutting out the compilation time.

What is the real-world frequency assignment problem? Explain how we might abstract this problem as a graph colouring problem.

Consider a network of radio transmitters, each of which must be assigned one of 'f' operating frequencies. If two nearby transmitters are operating on the same frequency then they have the potential to interfere with each other. The frequencies assigned to such pairs of transmitters are required to be distinct The transmitters are abstracted as nodes, which are joined by an edge if they are nearby each other (within the specified tolerance). We can assign the transmitters f frequencies, so that any radios that are close to each other transmit on different frequencies, provided the abstraction graph can be coloured using f colours.

What is data security (in the context of operating systems)?

Data is secure if the memory allocated to each program is kept separate and secure from other programs.

Name the types of bus within a CPU

Data, address, and control bus

Name the three main components in CPU/chip architecture & describe their function

Datapath: Handles all data processing operations and includes the ALU to perform all arithmetic and logical operations. It also includes registers. Control: Tells the data path, memory and ip/op devices what to do. Cache: on-chip memory. Small, fast and expensive. Stores memory items that need to be accessed regularly.

What is the famous Four Colour Theorem in graph theory?

Every map can be 4-coloured but not every map can be 3- coloured.

Purpose of cache memory in a CPU?

Expensive. Close to the CPU. Used to store rapidly accessed items.

What are the three fundamental phases of IC design?

Functional specification - Describes what the IC is supposed to do, which will affect the factors of chip area, speed and cost. Register transfer level - With reference to the functional specification, logic gates and interconnecting wires are used to design the behaviour of the digital circuits on the chip, as well as inputs and outputs. The design is converted into an electrical circuit design where further tests aim to confirm it is matching the FS Mapping to a physical layout -CAD tools are used to map the physical design onto silicon. Testing is undertaken at many stages to ensure it conforms to the RTL.

What is virtualization (in the context of operating systems)?

Hardware has complicated physical interfaces. The OS presents it as a virtual machine, providing abstractions giving an interface that is much easier for a user to understand and use. The OS can make the physical machine behave like an ideal virtual machine, aiding portability.

How does the Harvard architecture differ from the von Neumann one?

Harvard architecture uses separate buses for each of the data memory and instruction memory, eliminating the issue of the bottleneck.

Defining feature of a HDL that separates it from other programming languages?

Has explicit notation for expressing time and concurrency, primary attributes of computer hardware.

Purpose of address bus?

Holds addresses of locations in the main memory

What are the three types that MIPS instructions are partitioned into? Briefly describe these types

I type: Involves data transfer R type: : involves working on registers J type: involves jumps general structure: I-type: Opcode - 6 Rs - 5 Rd - 5 Address - 16 R-type Opcode - 6 Rs1 - 5 Rs2 - 5 Rd - 5 Shift - 5 Function - 6 J-type Opcode - 6 address 26

Give the different programming paradigms (styles) and explain the underlying principle of each

Imperative: programming instructions change a program's state. Closest to the computer hardware so in theory easiest to transform for execution. Declarative: e.g. - Functional: collections of mathematical functions that are composed together. - Logic: Specify a logical solution through use of a set of axioms and rules of inference to reach a goal statement. (Prolog) Data-Orientated: Manipulate and search through relations (data tables) Scripting: Automate frequently used tasks: glue existing programs together. (e.g. Ruby). Assembly: low-level, the interface between HLPL's and machine code (binary).

What is a half adder?

It takes x and y inputs and outputs the Boolean sum (which is 1 if, and only if, the input contains an odd number of 1's) and the resulting carry bit (which is 1 if, and only if, both x and y are 1).

What is the real-world scheduling problem? Explain how we might abstract this problem as a graph colouring problem.

Jobs must be allocated into set time-slots. Some jobs conflict. Can we decide whether there is a schedule for the jobs so that the number of time-slots is at most t? The jobs are abstracted as vertices and, if two jobs are in conflict, an edge joins the two nodes. There is a schedule of the jobs in t slots so that no conflicting jobs occupy the same slot if, and only if, the corresponding graph can be coloured using t colours.

Define carefully a finite state machine and explain how one is used to accept a set of strings

M = (Σ, Q, δ : Q × Σ → Q, q0 ∈ Q, F ) Σ is some finite alphabet; • Q is some finite set of states with initial state q0 and set of final states F ⊆ Q; and • δ:Q×Σ→Q is the transition function.

Explain how the principle of virtual memory works. Why is virtual memory required?

Many processes require more RAM than is available, so virtual memory is required. Having many simultaneous processes means a lot of RAM is needed and often there is not enough. The operating system will make use of virtual memory by paging. Moving memory backwards and forwards between RAM and the hard disk. The processor time-shares to execute a number of processes simultaneously. The time-sharing, however, will often not distribute the time equally, and prioritise certain important processes. Each process is unaware of where its data lies.

Give a precise definition of a decision problem.

More formally, a decision problem D consists of: • a set of instances I; and • a subset Y ⊆ I of yes-instances

What is the current trend in microprocessor design so as to overcome difficulties with power dissipation as we build faster and faster single processors?

Multi-core processors where each core/CPU has a lower clock-speed than the single processors, but when working together the system produces superior computational power.

What are registers in a CPU

On-chip memory locations that provide the fastest way to access data. They are limited in number.

Explain how a Prolog program computes?

Prolog, a logic programming language, specifies a 'logical solution'. The program consists of a set of axioms, a goal statement, and rules of inference, which are applied to ensure the truth of the goal statement. The execution of a logic program corresponds to the construction of a proof of the goal statement from the ax- ioms using the rules of inference.

In compilation, over 50% of the time taken can be spent on lexical analysis; that is, character handling. In moving from a program as a string of symbols to a token stream, which algebraic construction is usually used to define tokens?

Regular expressions are used to define tokens

Difference between static RAM (SRAM) and dynamic RAM (DRAM)?

SRAM: a bit of data is stored by a flip-flop. [A flip-flop incorporates 4-6 transistors] SRAM is stable and fast but requires more memory. DRAM: A bit of data is stored using a transistor/capacitor combination. It is cheap but slow and needs refreshing due to 'leaky' capacitors

Give a finite state machine that accepts the set of strings over the alphabet {a, b, c} consisting of strings with the property that there is always at most one c.

See drawing in computing folder

Describe the life-cycle of processes within the operating system (be sure to explain each component of the life-cycle).

See notes

Give two illustrations of principles of Computational Thinking in the context of software

Software structuring. Certain kinds of problems can be conveniently represented as multiple communicating threads which help to structure code in a more modular manner, e.g., by modelling user interface com- ponents as separate threads. Performance. We need to write parallel programs to achieve improv- ing performance from each new generation of multi-core processors. Real world concurrency. In distributed and real-time systems we have to model and react to events in the real world, e.g., handling multiple server requests in parallel.

Draw a diagram of the layers of abstraction in a modern computer system. [Abstraction: a representation of essential features without going into depth]

Software: - Applications - Algorithms and programs - Programming languages - Operating system Interface between Software and hardware - ISA (Instruction set architecture) Hardware - Microarchitecture - Gates / Register transfer level Electrical engineering - Circuits - Devices - Physics

Outline a real-world application of finding independent sets in graphs (you should explain clearly how finding independent sets is related to solving the real-world problem).

Sports day problem. Abstracted as Graph G(V,E) Vertices V are different events. An edge connects an event when there is an athlete who wants to participate in both. Finding the independent sets indicate the evens that can run simultaneously without causing clashes for the athletes.

What are the syntax and the semantics of a programming language? Give 2 reasons why we should strive for a formal semantics for a programming language.

Syntax: How a program is written (governs what is legit when written) Semantics: what a program means Formalising these allows for no ambiguity, so that we know and can prove what a program will do when executed. It allows us to know that different machines can execute the program identically every time. 'Precise' = mathematically formal.

Explain carefully the four phases of the fetch-decode-fetch-execute processor cycle (be sure to explain the purpose of any CPU components you happen to mention).

The 4 phases are: 1. Instruction fetch 2. Instruction decode 3. Operand fetch 4. Execute instruction 1. The address bus supplies an instruction's address and the data bus returns this instruction from the memory. 2. The stored instruction is interpreted within CPU 3. Involves the supply of the address and subsequently the return of any required data from the memory. 4. The CPU performs any necessary actions (can also be followed by a write-back phase where data is written back to memory.)

Give a (not necessarily precise) definition of what it means for an algorithm to be greedy.

The algorithm works through a list 'greedily' choosing the best thing to do

What is the instruction set architecture?

The interface between hardware and software, gives the programmer everything they need to control the processor. Primary component = the assembly language The ISA includes: - Organisation and structure of programmable storage (i.e. the registers and memory available to a programmer) - Instruction sets and formats - Methods for addressing and accessing the data items stored in memory. - The process of execution, i.e. the fetch-decode-fetch-execute cycle

What is the von Neumann bottleneck and how did it arise? What did this lead to?

The limit to the rate of data transfer between the CPU and the memory because data is fetched sequentially. This lead to the introduction of Caches.

Define the width of a bus? Explain how the width of a bus imposes memory or data limitations within a CPU.

The number of parallel wires in the bus, which determines the word size and the addressable memory.

Explain how there is always a decision problem corresponding to any search problem

There is always a decision problem corresponding to a search problem S = (I, J, R): • the decision problem has the same set of instances I; and • the yes-instances are those instances x ∈ I for which there exists some y ∈ J for which (x, y) ∈ R. The decision problem wins to show that there exists a solution, not what it is as with a search problem, so regardless of the solution of the search problem there will always be a corresponding decision problem.

Define what a Northbridge and a Southbridge do and describe the essential differences between them.

They are both chipsets in the computer hardware designed to handle certain communications between parts of the motherboard. Two chips in the core logic chipset architecture on a PC motherboard The Northbridge deals with faster communications amongst the CPU, memory and GPU The Southbridge deals with slower communications such as USB drives (external hard disks), audio, the internet, printers, keyboard and mouse, etc.

Name two distinctive computer hardware attributes that are normally expressible in HDL's

Time and concurrency

What is the aim of research in formal methods

To enable us to mathematically prove the properties of designs/programs/etc. without having to rely on empirical testing.

What are the two main components of an integrated circuit?

Transistors, interconnected by microscopic wires.

What do we mean by a brute-force algorithm to decide whether a graph can be coloured with 4 colours?

Trying every possible 4-colouring in turn and see if one is legal or not. Takes a lot of time (4^n solutions for n vertices).

What is the underlying principle of ubiquitous computing?

Ubiquitous computing involves the integration of computers and software into everyday objects and activities so that we can control (or have controlled for us) remote aspects of our lives.

Purpose of control bus?

Used to transfer information between CPU and other devices within the processor.

Outline how you would develop a Prolog program that given some facts about who is the mother or father of whom (in some collection of individuals), computes who is the grandmother, grandfather or descendant of whom.

grandmother(X,Y) :- mother(X,Z), parents( _ ,Z,Y) 'if X is the grandmother of Y, then X is the mother of Z and Z is a parent of Y' grandfather(W,Y) :- father(W,T), parent( _ ,T,Y) 'if W is the grandfather of Y, then W is the father of T and T is a parent of Y descend(X,Y) :- descend(X,Z), descend(Z,Y) 'If X is a descendant of Z and Z is a descendant of Y then X is a descendant of Y.' query the program using -?

Give three instructions of the MIPS (Microprocessor without Inter- locked Pipeline Stages) ISA and explain carefully what they do.

lw $s1, ($s2) register $s1 takes the value of the memory location held in register $s2 addi $s1, $s2, x register $s1 takes the value of register $s2 plus the number x j m jump to memory location m

Sometimes we can decide whether a graph can be coloured with a cer- tain number of colours, k say, by transforming the graph into a smaller graph so that the original graph can be k-coloured if, and only if, the transformed graph can. On occasion, we can iteratively do this so that we get a graph so small that we can trivially see whether or not it can be k-coloured. Give an example of such a transformation that we might use in this way. Apply your transformation to decide whether the graph in Fig. 1 can be coloured using 4 colours.

see notes in folder

Suppose that we are given two lists of symbols (possibly of different lengths). Explain how we order these two lists according to the lexico- graphic ordering

we compare two lists by working down the lists entry by entry until two corresponding entries differ; • the list with the least entry (we assume that there is some ordering on the entries) is deemed to be the least of the two lists; • if we never find two different corresponding entries but run out of one of the lists then this shortest list is the least list (note that in this case, the shorter list is a prefix of the longer one).

Outline a greedy algorithm for finding a tour in a given collection of cities. Does your algorithm solve the Travelling Salesman (optimisation) problem (optimally)? (If so then you should explain why; if not then you should provide a counter-example.) Show how your algorithm proceeds on the following instance of the Travelling Salesman problem (the city names are in bold and the distances between 2 cities are given in the table): [10]

• Start at some city • Iteratively move to the nearest city (breaking ties arbitrarily) • Output the tour obtained. Whilst we can sometimes obtain an optimal tour, the question remains as to whether we always obtain a tour of shortest length. It is not difficult to concoct a simple example where the tour found is not optimal. (If a city ends up being left out (not connected for instance).

What is an independent set in a graph? What is the Independent Set (optimisation) problem?

•An independent set U in a graph G=(V,E)is a subset U⊆V of vertices so that no vertex in U is joined by an edge to any other vertex of U. The independent set problem is finding the maximum independent set in G. • A maximum independent set in G is an independent set of the greatest size possible.


संबंधित स्टडी सेट्स

Abdomen 1 Final - Kidneys and Urinary Tract

View Set

Assessment For Young Children Exam 2

View Set

Chapter 29: Management of Patients With Complications from Heart Disease

View Set

Portales 1 Textbook - ¿Masculino o femenino?

View Set

physics test- light color and the EM spectrum

View Set