topic 2 - fundamental problems Flashcards
what is computer science?
Computer Science is the study of computers and what they can do;the inherent powers and limitations of abstract computers; the design, char-acteristics and use of real computers; and the applications of computers tosolve problems
what is the difference between computer sciences and other sciences?
Problems in Computer Science are primarily about the repeated journey towards some goal, rather than just establishing a goal in isolation.
/what are key to the problems in computer science?
the constructive nature of their solutions; the repeated application of these solutions; and the concern with and measurement of the difficulty of solving problems
what are essential notions for finding solutions giving an example for each relating to a travelling salesman?
- computation (the salesman’s machine);* resource (the time taken); and* correctness (the quality of the solution)
how does the idea of abstraction of real world problems cause issues?
in order for a computer to solve a solution to a problem, the problem must be astracted so it shares the main characteristics however not completely identical to the real issue.
what is abstraction focused on in computer science?
with ‘information hiding’ than with ‘information neglect’
what are the essential qualities of the abstraction to solve a problem?
these abstractions need to be represented and manipulated within a computer program; and* these abstractions mirror reality sufficiently closely so that any conclusions reached (by the computer) remain valid as regards the real-world problem
what is the trade off when it comes to abstracting?
A trade-off arises between the quality of the solution and the general cost of getting the solution
how do you abstact a problem?
start with a base issue and then develop nessecary additions in order to be more accurate to true issue. for example the travelling sales man problem you may at first only look at the distances between citys then you may take into account the speed limits of the roads which will affect time taken to travel and then you can take into account the level of trafffic and so on
what is the features of a decision problem?
they consist of a set of instances and a subset of I which is a yes instance ’,with it being our job to decide upon the answer correctly.
how do you solve a desicion problem?
In order to solve a decision problem, we need to decide (using somealgorithm or program) whether any given instance is or is not a yes-instance
how would you represent in a graph a map colouring problem where there is only three colours and they cannot touch a state with the same colour?
represent the important information on a graph with nodes respresenting all the states and then join lines called edges between the nodes that are touching. the graph has the function G= (V, E) where V is a vertex (node) and E is set of edges
what was the first substantial theorem to be proved using a computer?
the four colour theorem which says every map can be coloured using 4 colours
how do you sort a list using lexicographic 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)
how would you abstract the question” Can you find a route from the start town to the end town, composed of interim routes from town to town, but so as to avoid motorways?” and what are the pros and cons?
you can abstract it two ways —-a graph G = (V, E) where the vertices correspond to towns and an edge(u, v) to the existence of a route from town u to town v avoiding any other town; together with* a list of edges corresponding to the (direct town-to-town) routes that are motorways; and* the start and end towns.—– or just as towns as the nodes and the various roads that are not motorways will be the edges. first is worst for information storage however is better if you want to make adjustments in future
what does a search problem consist off?
a set of instances I;* a set of solutions J; and* a binary search relation R ⊆ I × J
what is a binary search relation?
Binary search compares the target value to the middle element of the array. If they are not equal, the half in which the target cannot lie is eliminated and the search continues on the remaining half, again taking the middle element to compare to the target value, and repeating this until the target value is found.
why do you have to abstract both instances and the solution for a search problem?
we have to abstract solutions so that a solution returned from our computation corresponds to a solution of the underlying real-world (search) problem
what is the relationship between search problems and decision problems?
It is almost always the case that corresponding to any decision problem, there is a search problem and vice versa. as a search problem aims to find a solution rather than just prove there is one. and a decision problem will have the same set of instances as the search problem and the yes instance is when x is an instance and there is a corresponding to solution that matches x
what does an optimasation problem consist of ?
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 are the three outcomes of a maximisation optimisation problem?
Ideally you want to find a maximum however it may be the case that there are no feasible solutions for an instance; or for a maximization problem, there are feasible solutions of increasingly large measure. in both of the last two cases this should be signalled
how can you decide whether a graph can be coloured by hand?
you will need to develop a systematic procedure/ algorithm so that if the answer is yes you will be able to draw it by hand and if the answer is no then there still might be a possibility that it can be drawn by hand ie a false negative.
what is an effective procedure to solve a solution?
an effective procedure is one that is easy to implement and also gives back as few false errors as possible
what is the optimal solution to the colouring of a graph problem?
it is optimal when you can colour a graph with as few colours as possible and the solution is proper ie no same colours are touching
how can you solve the graph colouring problem using a greedy algorithm?
you number each verticie and number each colour in increasing order. you begin by colouring verticie 1 by colour 1 and then move to colour verticie two. if the verticie is touching an already coloured verticie it will use the lowest order colour. this process wil continue until all verticies are coloured.
why is it called a greedy algorithm?
it is called a greedy algorithm due to the fact that it works through greedily choosing the best thing to do for that one verticie
what are the issues with a greedy algorithm?
it isnt that sophisticated so as a result a lot more false negatives arise. also the efficency of the algorithm in finding the solution will depend heavily on how the verticies are ordered
what is the rule about greedy algorithms and the optimal solution?
for every graph, there always exists an ordering of the vertices so that greedily colouring the vertices yields a colouring using as few colours as possible
what is the most effective way to solve the 4 colour map problem?
suppose there was a vertex with strictly less neighbours then 4 in the graph G. if you remove this vertex and all its incident edges with other vertex then you will be left with graph G1. if G1 can be 4 coloured then so must G. if G1 has any vertex with less than 4 neighbours then you can remove that vertex to get G2 and so on to find G3, G4 etc. you will eventually not be able to remove any more vertex so if this final shape can be 4 coloured then the whole graph G can be 4 coloured solving the problem.
how can you abstract the sports day problem as a graph?
The sports day problem can be abstracted as a graph G = (V, E): vertices of V consist of the different events; and there is an edge (u, v) ∈ E if there is some athlete who wishes to participate in both the event corresponding to vertex u and the event corresponding to vertex v.
what is an independet set ?
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 .
what is a maximum independent set?
A maximum independent set in G is an independent set of the greatest size possible.
what is a 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).
how can you solve the sports day problem?
We chose a vertex v of our graph of smallest degree (that is, with the fewest number of neighbours and we break ties arbitrarily) and add itto our independent set I. We remove v (and its incident edges) as well as all neighbours of v (and their incident edges) from our graph and repeat (with our new, smaller graph). this will provide us with a large independent set as we are repeatedly removing as small a neighbour of vertices as possible each time.
provide a method to solve the Travelling salesperson problem?
Start at some city. Iteratively move to the nearest city (breaking ties arbitrarily). Output the tour obtained.
what is a programming language
A programming language essentially provides a means for transforming an algorithm into a form suitable for execution by a computer; or, more precisely, into a program that can then be transformed (trivially) into a form suitable for execution by a computer.
what are typical concepts associated with algorithms
an algorithm works on some input. an algorithm produces some output; the steps of an algorithm are precisely stated; and an algorithm can be applied generally to a variety of inputs.
an algorithm is a computer program, yes or no?
no, A computer program is some-thing written in a (concrete and explicitly defined) programming language, and an algorithm can have many different implementations as a program(even within the same programming language!)
why can you not provide a formal definition for an algorithm?
if we can formally define an algorithm then what we have is a programming language; yet, an algorithm is supposed to be different from a program
what are the two phases to converting an algorithm into something that the computer can execute?
the first phase is describing (that is, implementing)the (‘ghostly’) algorithm using a programming language; and the second is converting the resulting program into something that is machine-executable
what is the whole point of having different programming languages?
The whole point of having all these different programming languages is so as to make the first phase as satisfactory as possible for different programmers working in different environment