Algorithm

18 Apr 2012

Reflection On the Midterm

Woow very bad today,

It was my understanding of the programming algorithm is still far below the word understanding,, 
 Midterms today made ​​me realize that I do not know anything about Al-Pro. and made ​​me realize that a lot of exercise it is necessary to make us understand in a matter, but what should I do first to start it? I am still confused on the algorithm, and I also struggled in pouring it into a program, if the raptor program my little understood, but if it is poured into the compiler program, I will be confusion, it is hard Alpro, is why I will attempt to conquer programming algorithm ... I have to do better when entering college after 2 midterms .... I will try harder .....

------------------------------------------------@_@" ---------------------------------------------------

17 Apr 2012

Sub Programs

In the discussion of sub-programming algorithm that is in the program display more than one output.
For example, a work performed by a person would have done by that person according to his profession.
For example, a course director will lead a company with many employees underneath. They automatically (subordinate directors) will perform the work in accordance with masing2 they do, and the directors would only accept the results.
In the process we can apply the algorithm to a subprogram, by making the procedure beforehand.
This time I have an example in raptor flowchart subprogram, which is a number that will display the results +5 outputny.
So for example we have input the number 2, then the result will come out 7. It occurs also as the above example. Making procedure and it will bring results in line with the command or the works of inputannya.
Flowchart below the image will bring up the output of +5:




subprogram in the flowchart below, we created two flowcharts in a single raptor. The flowchart first notified in advance we have input variables, then we outputkan results. Flowchart of the procedure for calling us to make these variables, then the process in the flowchart. So if we run the flowchart, the result will be menginputkan’s a +5 balustrades and output results

Motivation : We can learn any time, any time, anywhere and anytime, all we see is the source of learning for us.

--------@_@---------

14 Apr 2012

Benefits of Recursive Functions in C + +

Now i will post about the benefits of recursive and iterative, advantages and disadvantages of each as well as similarities and differences.

"What are the benefits of using Recursion Function". "Because of the recursion function is similar to the loop, so the advantages / benefits of writing the program listing on the savings when compared to looping / iteration".


==>Recursive<==


Recursive loop >> is one method of programming in which the instructions contained in a function that calls a function that sendri, or more commonly referred calls itself.

Excess looping >> it's easy to do looping with a wide range in terms of looping in a large scale.


Can >> looping with the restriction function


Recursive looping >> Disadvantages: Can not perform a nested loop or nested loops


Usually >> makes it difficult to understand the function, only suitable for certain problems


Requires >> stack larger, for each time the function was called, local variables and formal parameters will be placed into the stack and there will Kalaya no longer enough to cause a stack (Stack Overum)


>> The process is somewhat convoluted because there pemangilan repetitive functions and data calls are stacked


==>Iterative


 Iterative loop is looping >> the looping process of group instruction. Iteration performed within the limits specified conditions. When conditions are not met then the iteration will stop again.

Iterative loop >> Pros: Easy to understand and easy to do debuging when there is one iteration


Can perform a nested loop >> or the so-called nested looping


The process is short >> looping occurs in conditions that have been adjusted


Overflow occurs >> Rarely due to restrictions and conditions clear looping


Weakness >> looping iterativeTidak can use the restrictions of functions


Iteration with a broad restriction would make it difficult in making looping program itself.



++>Differences and Similarities Recursive and Iterative: <++


Equation
- Same-as a form of looping. 
- Do check conditions before repeating.

Difference 

- Iterative use the FOR, WHILE, DO-WHILE IF while the recursive use only.
- Iterative can be run on a program that consists of procedures (There is no function) whereas a recursive function.


Motivation : Everything to do with sincerity, then Allah will Simplify our way...(Inayah 14042012)

----> @_@ <----

13 Apr 2012

RECURSIVE PROGRAM EXAMPLE

Friends this time I will share the few raptors that use the recursive program.

it's the program..

>>Program to find out the value to 5 and 7 recursively






when on the run and the results are like this:
 


>>Above it is an example of a recursive program ..
 


Motivation : We Will Not Understand Where We Never Tried and We Will Never Understand When We Do not Try To Understand (Inayah 12042012)

Video Of Raptor Array

Because we've entered the seventh weeks, we learn about one dimention  of Array,, so i searching in youtube how the tutorial raptor about Array,, and i found it...

This is A video of tutorial flowchart about Array---
Let's we seen.....


this vireo show us what will the Array can work,, it's interested to watch and we can learn more from this video------

@_@

12 Apr 2012

What Is Recursive...???

Recursive 

what is it recursive???

 This time I will post material recursively, instead of raptor, or program, but the understanding and explanation of what it is recursive ... 
so that we can easily learn and understand about the famous recursive material is not easy, and also to think to understand and easily put it in a raptor or a program. 


Recursive is a tool / way to solve the problem in a function or procedure that calls itself.Definition according to Niclaus Wirth:"An object is said be recursive if it consist partially or is defines in terms of Itself"mathematical calculations (eg factorial function and the Fibonacci numbers)Factorial 

>>Factorial function of the positive integer n is defined as follows: 

n! = n. (n-1)! , If n> 1n! = 1, if n = 0, 1 

example: 

3! = 3. 2!3! = 3. 2. 1!3! = 3. 2. 13! = 6 

We can write the factorial function calculator as shown below: 

int Factorial (int n) 
   {if ((n == 0) | | (n == 1))return (1); 

else return 

      (n * factorial (n-1));} 

On line 3 of the above functions,checked the value of n is equal to 0 or 1,if yes, then the function returns 1 row {4},if not, the function returns the value of n * Factorial (n -1){Line 6}this is where the recursive process, notice of this factorial function calls itself, but with parameters (n-1). 

>>Fibonacci Numbers 

Other functions can be transformed into a recursive form of the Fibonacci calculations. 

Fibonacci numbers can be defined as follows: 

fn = fn-1 + fn-2 for n> 2f1 = 1f2 = 1 

Here is a sequence of Fibonacci numbers ranging from 

                     n = 11 1 2 3 5 8 13 21 34 

Fibonacci algorithm is used:
  • Function Fibonacci (input n: integer) integer -->
Declaration of Local

  
{No}DescriptionIf (n == 1 | | n == 2) Then


  
return (l)Else
  
 

return (Fibonacci (n-1) + Fibonacci (n-2))ENDIF 
example: 

For the size of n = 4, 

the Fibonacci calculations can be performed as follows: 

f4 = f2 + f3f4 = (f1 + f2) + f2f4 = (1 +1) +1f4 = 3 

Combination of:Function Combination (input n, r: integer) --> realDeclaration
 
 

If (n <r) Thenreturn (0)
 

  Elsereturn (Factorial (n) / factorial (r) * factorial (nr))
 
 

ENDIF 


>>Permutations: 

The permutation function (input n, r: integer) --> realDeclaration
     

 {No}
  

 Description
    
 

       If (n <r) Thenreturn (0)
  

  Elsereturn (Factorial (n) / factorial (n-r))
  

 ENDIF

There is a theory about Recursive. I hope we can be understand with it.. 

Motivation :  Learn More And Get More (Inayah 12042012)

@_@/.....!!??

cheeesseee.......!!!!!

11 Apr 2012

Overloading friend operator for template class

I'm trying to overload the operator << as a friend to a template class Pair, but I keep getting a compiler warning saying----

friend declaration std::ostream& operator<<(ostream& out, Pair<T,U>& v) declares a non template function
for this code:
friend ostream& operator<<(ostream&, Pair<T,U>&);
it gives a second warning as a recommendation saying
if this is not what you intended, make sure the function template has already been declared and add <> after the function name here
Here is the function definition
template <class T, class U>
ostream& operator<<(ostream& out, Pair<T,U>& v)
{
    out << v.val1 << " " << v.val2;
}
and here is the whole class.
template <class T, class U>
class Pair{
public:
    Pair(T v1, U v2) : val1(v1), val2(v2){}
    ~Pair(){}
    Pair& operator=(const Pair&);
    friend ostream& operator<<(ostream&, Pair<T,U>&);
private:
    T val1;
    U val2;
};

10 Apr 2012

Reflection Programming Algorithm To Seven Weeks

Was not already entered the seventh week of the course the algorithm, Recursive discussion, the words that I can say "DO NOT UNDERSTAND", more precisely still do not understand.

This time I want to share about this is the result of recursive pretest our lab, but still do not understand all explained well, but in fact if not in a recursive well learned it is easy. only one I can remember about the recursive that "in no such thing as a recursive loop" so if there is a program that has a loop then it is not "recursive" but "iterative"

Let's take a tough program.


Turning Words In Recursive Program

 

 

If on the run it will be like this ...
 
  

Above is an example of a recursive program, hopefully with friends to see it to understand,, hehe ..

nahh,, week seven already completed, and preparing for midterm exams programming algorithm which is certainly not easy .. so must be learned and continue to let me learn to understand the algorithm.






Motivation: 
We Learn Not To Get a Good Value, But Learning To Get An Understand (Inayah 09042012)


see yaaa....!!!! @_@