Sunday, March 14, 2010

Radio Shack Lightning

Project # 3 - Factorial Computation

Iteration:



The iteration in a nutshell is the repetition , and in this case the algorithm repeat as often as necessary or required for the algorithm solution.




Recursion:

This property is to synthesize an algorithm that does not know its resolution to simpler parts which can be resolved if, that is, from a base case, which is what if we resolve and from there to find solution to our algorithm.





















Recommendations :


is very helpful to use the iteration when the algorithm is repetitive, you should use for and while structures in the creation of pseudocode:

For → When you know the number of times to repeat the algorithm. While
→ Where no one knows the number of times to repeat the algorithm.

The Recursion is very useful when you know the resolution of a simpler algorithm and is necessary to solve it from a base case.

If you do not need to use recursion in resolving omitirmosm algorithms is preferable because otherwise it would make an algorithm that is easy to solve one with a lot of steps inesesarios for solution, which would occupy more memory computer and would be counterproductive.


Working Group:

What team did was to divide the work for not doing so heavy and that each member investigate well what was going to expose and and then explain that everyone and other was so well researched and all we were aware of each other's work.




Individual Work:

What I did was to investigate how to make a pseudocode iterative factorial problem of what happens after a compiler to run it and run it, also investigated the complexity of the algorithm, and all support to my teammates to edit the slides.





Slides:


Bloggs Team:



Are Mpv Test Accurate




Will A Queen Size Bed Fit In A Cargo Van

Hanoi Towers of Hanoi Towers

http://arelyquintanilla.blogspot.com

http://daaniiha.blogspot.com


http://lucygc.blogspot.com

Wedding Reading Prayer Of The Faithful

Blogs

Introduction

The Towers of Hanoi is a mathematical puzzle or game invented in 1883 by French mathematician Eduard Lucas.Este solo is a set of eight discs of increasing radius to be stacked back into one of three stakes on a board. The objective is to create another stack of cuttings by following certain rules. The problem is well known in computer science and appears in many textbooks as an introduction to the theory of algorithms.

In its most traditional form, consists of three vertical rods. In one of the rods are stacked any number of disks (made of wood) to determine the complexity of the solution, generally considered eight records. The disks are stacked on a rod in decreasing size. No two identical disks, all of which are stacked from largest to smallest radius of the rods, leaving the other two vacant rods. The game is to move all the disks in the rod busy (ie the one with the tower) to one of the other rods vacancies. To achieve this objective, you must follow three simple rules:

1. You can only move one disk at a time.
2. A larger disk can not rely on one smaller than himself.
3. You can only move the disk that is on top on each rod.

There are several ways to make the final solution of them by following different strategies.

Does Best Buy Phone Insurance Cover Water Damage?

Pseudocode

Recursive Algorithm Pseudocode

hanoi (n, source, destination, auxiliary)

if n = 1



then move a disk from the tower to the tower source destination / / { solution of the recursive method}


if
/ / {move n-1 disks from tower to tower auxiliary source}
call hanoi (n-1, source, auxiliary target) / / recursive call} {
Move a disc from the source tower to tower
destination
/ / { move n-1 disks from tower to tower auxiliary destination}

method call hanoi (n-1, axuliar, destination, origin) / / recursive call} {



order order






Iterative Algorithm Pseudocode

/ / the arguments origin, destination and axuliar are variables representing the three towers of the original problem (may be structures or simply the name of each tower, in this case represent only the name of the towers is therefore assumed to be in text format).
/ / n is the number of disks
/ / Pilane, battery, and battery are Pilad type structures
BATTERY / / stop is a variable of type integer.
/ / varaux is a variable of type text (in this case because the towers are represented only by name, ie, this variable must be the same type as origin, destination and auxiliary)
/ / flag is a variable

boolean type iterative solution (n, source, destination, auxiliary)

to stop = 0 and flag = false
repeat while (n> 0) and (flag = false)

repeat while (N> 1)

/ / are stored in the batteries current values \u200b\u200bof the parameters
stop = stop +1
Pilan [top] = n
stack [top] = origin
Pilad [top] = desthio
stack [top] = auxiliary

n = n-1 = target varaux

target = helper helper = varaux


End / / end repeat while (N> 1)

move disk from source to destination


flag = true if top> 0 then / / means that the batteries are not
empty
n = Pilan [top]
origin = stack [top]
target = Pilad [top]
auxiliary = stack [top]
top = top-1 disk

move from origin to destination

n = n- 1
varaux = source source = auxiliary
Auxiliary = varaux

flag = false

End / / end if top> 0 then
End / / end repeat while (n> 0) and (band = false)
End / / end method

How To Build Boat Seats



recursive algorithm

The Tower of Hanoi, often appearing as an example to illustrate the concept of recursion in computer programming courses, as there is a surprisingly simple recursive algorithm that solves it (in case anyone does not know , an algorithm is recursive if it calls itself in one of its steps.) Suppose we want to move the eight albums post A to post C. As the disc 8 is always below of all, the only way is to move first seven-disc tower 1 ... 7 to pole B. Then we can take the disc 8 from A to C, and finally again have to move the tower 1 ... 7 runs from B to C.

But discs 1 ... 7 form a tower similar to the initial full well that in two of the three previous steps we face a problem similar to the original. In fact it can be solved in the same way, now moving tower 1 ... 6. For example, the first step (move the tower 1 ... 7 from A to B) can be decomposed into three steps.

Of course, in two of these three steps we meet again with the original problem, now with n = 6. The process is not infinite, since it comes in a tower that is equivalent to moving a single disc (this occurs when the tower is a single disc, of course). In summary, the recursive algorithm is as follows.
algorithm to move the tower 1 ... n X pole to pole Z, using as auxiliary pole Y.

1.-If n = 1, Disc 1 takes X to Z and ends. 2.-Move
Tower 1 ... n-1 using this algorithm, from X to Y, using as auxiliary Z. 3.-Take
disk n from X to Z. 4.-Move
Tower 1 ... n-1 using this algorithm, Y to Z, using as auxiliary X.

This algorithm has always seemed surprising, it seems the definition of a problem resolution. In fact, all it does is specify a few steps inevitable. For example, as we saw before, to solve the puzzle is required to bring the disk n from A to C, and it is compulsory to wear before tower 1 ... n B, etc. The sequence of motions produced by this algorithm is the only optimal solution (ie minimum length) as possible. The number of movements is M3 (n) = 2n-1, as can be shown easily by induction on the number of disks.

is true for n = 1

M3 (1) = 1 = 21-1.

If true for n, holds for d +1

In implementing the algorithm for n +1 calls itself twice to n, plus a disc movement n +1. So queM3 (n +1) = 2 × M3 (n) + 1 = 2 × (2n-1) + 1 = 2n +1 = 2n +1-1 +1-2.

For n = 8 the number of movements is 28-1 = 255. For n = 64, 264-1 = 18,446,744,073,709,551,615. If the Brahmins of Benares site change a disc every second would take more than five hundred eighty billion years to complete their task, some forty times the age of the Universe.

recursive algorithms work well with computers, but are difficult to apply to a human. If you try to solve the tower of eight disks using the method described is easy to miss unless you go taking notes of where you. Even for computers recursive algorithms are often wasteful in the sense that they consume enough memory (and they also need. The alternative to recursive algorithms are iterative, in which no calls himself, but a or more loops. Very often there is no known or iterative alternative to a recursive algorithm, and when it is known, often much more complicated than the recursive version. However, in the case of the Tower of Hanoi, there several very simple iterative algorithm.

Chunky White Cervical Fluid



iterative algorithms

Before searching algorithm iterative reemphasize an important detail. Although we speak of various algorithms, the optimal solution (the less movement, as we have seen before, for n = 8 is 255) is unique. In other words, the series of moves that results from applying an algorithm (optimum) will either be always the same.

A key observation to find an iterative algorithm is that the smallest disk is moved after another, one might not. The first move must be done with disk 1. It is clear that after moving the disk 1 (at any time) must move a different disk (if you do not want to waste time moving the same disc multiple times.) This movement must be made between two posts that do not contain the disk 1. Then we do not are only two choices: undo the last move, which makes no sense, or return to move the disc 1. Also, when you touch your turn to a disk other than 1, the movement will be fully determined and will intervene only two posts and two poles there is only one possible move. So only when there can be no doubt that moving the lower disk. We leave this question with respect to any of the following rules.
-The small disk must always move cyclically in the same direction, clockwise (from A to B, B to C and from C to A) or left (A to C, C to B and B to A) as the number of disks is even or odd respectively.
-The small disk should always be placed either on a disk number, either as a single disk in the post of destination (C) if the record number is odd or the other (B) if pair.

Given the first rule is constructed an algorithm discovered by Peter Buneman and Leon Levy.

1.-If n is even, disk 1 moves to the right. If is odd, move to the left.
2.-If all the disks are in C, end. If not, move a disk other than 1 and returns to step 1.
Considering the second rule, the algorithm could be next.

1.-If possible, bring the disc 1 on a disc number. If not possible, take it to the post B if n is even or C if n is odd.
2.-If all the disks are in C, end. If not, move a disk other than 1 and returns to step 1.
To make this algorithm easier to implement, can be painted even and odd discs of two different colors. You can even paint the base into three pieces, as shown in the figure (it is as if the pieces were based disks n +1, n +2 and n +3).

How Can I Dry The Humidity In My House



Puzzle With this version of the latter algorithm can be written as follows: Take

disk 1 on disk (or piece of base) that is not the same color.

"If all the disks are in C, end. If not, move a disk other than 1 and returns to step 1.

- The smallest disk is not the only one not ever put on another of a different color,
at any time there are two discs of the same color together.

Thursday, March 4, 2010

Orchid Wedding Cakes 2010




Optimization




Problem:


"The mayor of San Nico will get in our town the president of Mexico in the town square, for which the area must be present for that day, say that the remaining days for its arrival is 3, then the mayor wants to find the most optimal way to leave the area very well presented by that date "


Suppose that the mayor has a budget of $ 1,166,666.6 for a week so the for 3 days are $ 500,000, which is derived from taxes paid by citizens, and to fix issues in the area are:

1.
Garbage
2.
Painting
3.Mantenimiento


The site area is 1800m to square grooming:





The mayor has 3 companies that are in charge of the work required and are as follows;


Option 1:

They take 5 days to do this work and charge a 150 % more for each day less to postpone the date. The weight of what they charge for each aspect is:

1. Garbage → $ 25 C/m2
2. Painting C/m2 → $ 100 → $ 80
3.Mantenimiento C/m2

f (x) = ((25x +100 x +80 x) • 3) + z

if z = 25x +100 x +80 x


Option 2

They fit the limit of time the client needs to work. The weight of what they charge for each aspect is:

1. Garbage → $ 35 C/m2
2. Painting → $ 90 C/m2
3. Maintenance → $ 50 C/m2

f (x) = 35x +90 x +50 x


Option 3

They tered 2 days to do its job and make a 5% discount for each day of term you leave it more.

1. Garbage → $ 60 C/m2
2. Painting → $ 110c/m2
3. Maintenance → $ 70 C/m2

f (x) = 60x +110 x +70 x - (z (0.05))

if z = 60x +110 x +70 x



What will be the most optimal way to order the job?

As the area = 1800m2 then the costs of each of the companies are:



Option 1 1. Garbage → $ 202.500
2. → Painting → 3.Mantenimiento
$ 810.000 $ 144.000

= $ 1,156,500 + 300%
Total = $ 4,626,000


Option 2 1. Garbage → $ 63.500
2. → Painting → 3.Mantenimiento
$ 162.000 $ 90.000

Total = $ 169.200


Option 3

1. Garbage → $ 108.000
2. Painting → $ 198.000
3.Mantenimiento → $ 126.000

= $ 432.000 - 5%
Total = $ 410.400

asymptotic complexity

the most optimal way would be to find a lower bound to the budget , but the more remote this is less the cost will, therefore, more optimal.






In this case, as shown in the graph the optimal height to choose option 2 is blue, and that meets the requirements to optimize the work, is below the altitude of income (green) and is also the lowest level, therefore the least expensive.


This decision problem belongs to the class "P", since the choice is not very complicated and the equations of each option are linear, that is why it is very difficult to resolve. Apart
these algorithms do not belong to an NP-hard problem, because for start as it is a NP problem can not therefore be NP-hard.



This is a representation of the algorithm:


* This is not a flow chart is a representation only simple diagram of the algorithm.



References:

http://www.google.com.mx/
http://es.wikipedia.org/wiki/NP-hard
http:// es.wikipedia.org / wiki / Clases_de_complejidad_P_y_NP
http://es.wikipedia.org/wiki/Cota_superior_asint% C3% B3tica
http://es.wikipedia.org/wiki/Optimizaci% C3% B3n_de_software
http://maps.google.com.mx/?gclid=CKvjnPWen6ACFSpeagodMlwzag
http://es.wikipedia.org/wiki/Problema_de_decisi% C3% B3n