{"id":25,"date":"2015-10-14T14:24:35","date_gmt":"2015-10-14T14:24:35","guid":{"rendered":"http:\/\/deanrih.blog.binusian.org\/?p=25"},"modified":"2015-10-14T14:24:35","modified_gmt":"2015-10-14T14:24:35","slug":"algorithm-part-2","status":"publish","type":"post","link":"https:\/\/deanrih.blog.binusian.org\/?p=25","title":{"rendered":"ALGORITHM [ PART &#8211; 2 ]"},"content":{"rendered":"<p>Last post i&#8217;m talking about PROBLEM, in Algorithm, and in this post, i will talking about<\/p>\n<ul>\n<li>BRANCHING ( SELECTION )<\/li>\n<li>LOOPING ( REPETITION )<\/li>\n<\/ul>\n<p><strong>BRANCHING [ SELECTION ]\u00a0IN ALGORITHM<\/strong><\/p>\n<p>Branching or Selection is usually used when we want to do something with some situation or condition,<br \/>\nwhen the situation or the condition is YES,\u00a0we will do action A, but if the condition is NO,\u00a0Action B wil be executed.<\/p>\n<p>The work flow is same in pseudo-code,\u00a0we just\u00a0write<\/p>\n<p>If Condition A == Expectation Then<br \/>\nDO THIS<br \/>\nElse<br \/>\nDO THIS<\/p>\n<p>or<\/p>\n<p>If Color of apple == Red<br \/>\nEAT THAT APPLE<br \/>\nElse<br \/>\nTHROW AWAY THAT APPLE<\/p>\n<p>that is an example for Pseudo-code, in some Programming language, we type<\/p>\n<p>if ( Condition)<br \/>\n{<br \/>\nSomething to do<br \/>\n}<br \/>\nelse<br \/>\n{<br \/>\nOther thing to do<br \/>\n}<\/p>\n<p>for example<\/p>\n<p>if ( i == 1 )<br \/>\n{<br \/>\nprintf(&#8220;The value of I is one!&#8221;);<br \/>\n}<br \/>\nelse<br \/>\n{<br \/>\nprintf(&#8220;The value of I is not one!&#8221;);<br \/>\n}<\/p>\n<p><strong>LOOPING\u00a0[ REPETITION\u00a0] IN\u00a0ALGORITHM<\/strong><\/p>\n<p>Looping or Repetition is type of algorithm to do the same thing for a given amount of time.<br \/>\nFor example, we must\u00a0write some word\u00a010 times, so, in Algorithm we use Looping for Writing down that word\u00a010 times.<\/p>\n<p>in Pseudo-code the form of Looping are\u00a0like this<\/p>\n<p>DO<br \/>\nWrite some word<br \/>\nFOR 10 TIMES<\/p>\n<p>or<\/p>\n<p>counter = 0<br \/>\nDO<br \/>\nWrite some word<br \/>\nIncrease counter by 1<br \/>\nWHILE counter\u00a0&lt; 10<\/p>\n<p>&nbsp;<\/p>\n<p>in programming world, we have 3 types of Looping, they are<\/p>\n<p>FOR (Condition) {Statement}<br \/>\nDO\u00a0{Statement} WHILE (Condition)<br \/>\nWHILE (Condition) {Statement}<\/p>\n<p>WHILE (){} and FOR () {} looping is the same style, so that is doesn&#8217;t matter you want to use WHILE (){} or FOR (){}<br \/>\nbut, they are different with DO {} WHILE {}, the difference is at the way the statement is executed<br \/>\nWHILE(){} or FOR(){} looping is executing the statement AFTER\u00a0checking their condition,<br \/>\nDO {} WHILE () looping is executing the statement FIRST and then checking their condition.<\/p>\n<p>&nbsp;<\/p>\n<p>&nbsp;<\/p>\n<p>&nbsp;<\/p>\n<p>In Algorithm, or especially, in programming, we have operands and operators for some math operation<\/p>\n<p>Operator \u00a0is symbolic character that used to count some operands, is that Sum, divide, multiply, etc.<br \/>\nSome known operators are<\/p>\n<ul>\n<li>+ [ Plus ]<\/li>\n<li>&#8211; [ Minus ]<\/li>\n<li>\/ [ Divide ] ( for dividing operation )<\/li>\n<li>* [ Multiply ] ( for multiplying operation\u00a0)<\/li>\n<li>= [ Equals ]<\/li>\n<\/ul>\n<p>&nbsp;<\/p>\n","protected":false},"excerpt":{"rendered":"<p>Last post i&#8217;m talking about PROBLEM, in Algorithm, and in this post, i will talking about BRANCHING ( SELECTION ) LOOPING ( REPETITION ) BRANCHING [ SELECTION ]\u00a0IN ALGORITHM Branching or Selection is usually used when we want to do something with some situation or condition, when the situation or the condition is YES,\u00a0we will [&hellip;]<\/p>\n","protected":false},"author":6678,"featured_media":0,"comment_status":"open","ping_status":"open","sticky":false,"template":"","format":"standard","meta":{"footnotes":""},"categories":[1],"tags":[],"class_list":["post-25","post","type-post","status-publish","format-standard","hentry","category-uncategorized"],"_links":{"self":[{"href":"https:\/\/deanrih.blog.binusian.org\/index.php?rest_route=\/wp\/v2\/posts\/25","targetHints":{"allow":["GET"]}}],"collection":[{"href":"https:\/\/deanrih.blog.binusian.org\/index.php?rest_route=\/wp\/v2\/posts"}],"about":[{"href":"https:\/\/deanrih.blog.binusian.org\/index.php?rest_route=\/wp\/v2\/types\/post"}],"author":[{"embeddable":true,"href":"https:\/\/deanrih.blog.binusian.org\/index.php?rest_route=\/wp\/v2\/users\/6678"}],"replies":[{"embeddable":true,"href":"https:\/\/deanrih.blog.binusian.org\/index.php?rest_route=%2Fwp%2Fv2%2Fcomments&post=25"}],"version-history":[{"count":3,"href":"https:\/\/deanrih.blog.binusian.org\/index.php?rest_route=\/wp\/v2\/posts\/25\/revisions"}],"predecessor-version":[{"id":32,"href":"https:\/\/deanrih.blog.binusian.org\/index.php?rest_route=\/wp\/v2\/posts\/25\/revisions\/32"}],"wp:attachment":[{"href":"https:\/\/deanrih.blog.binusian.org\/index.php?rest_route=%2Fwp%2Fv2%2Fmedia&parent=25"}],"wp:term":[{"taxonomy":"category","embeddable":true,"href":"https:\/\/deanrih.blog.binusian.org\/index.php?rest_route=%2Fwp%2Fv2%2Fcategories&post=25"},{"taxonomy":"post_tag","embeddable":true,"href":"https:\/\/deanrih.blog.binusian.org\/index.php?rest_route=%2Fwp%2Fv2%2Ftags&post=25"}],"curies":[{"name":"wp","href":"https:\/\/api.w.org\/{rel}","templated":true}]}}