Tampilkan postingan dengan label Pemodelan Komputasi. Tampilkan semua postingan
Tampilkan postingan dengan label Pemodelan Komputasi. Tampilkan semua postingan

Senin, 01 Oktober 2018

Latihan Soal Pemodelan Untuk Komputasi : Repetition Atau Pengulangan

Latihan Soal Pemodelan untuk Komputasi : Repetition atau Pengulangan


Latihan Soal


Kelipatan 3

Buatlah algoritma untuk menampilkan n (n>=1) buah kelipatan 3 yang pertama!


Faktor 

Buatlah algoritma untuk menampilan semua faktor dari bilangan bundar x! Faktor-faktor ini harus ditampilkan dari yang terbesar hingga yang terkecil!

State


  • Perhatikanlah flowchart di bawah ini! Tentukanlah berapa saja nilai r hingga alhasil loops berakhir! 



  • Permasalahan apa yang diselesaikan oleh flowchart tersebut? Coba jalankan flowchart tersebut untuk n = 20 dan m = 30


Faktorial

Buatlah flowchart untuk menghitung nilai dari n faktorial (n!)!

Bunga Tabungan

Jika diketahui bunga beragam pertahun yaitu n persen, dan tabungan awal yaitu y, di tahun ke-berapakah tabungan menjadi 2y? Buatlah flowchart-nya dengan memakai loop!

Fibonacci

Buatlah algoritma untuk mencari bilangan Fibonacci ke-i. Bilangan Fibonacci ke-1 yaitu 0, Bilangan Fibonacci ke-2 yaitu 1, dan untuk setiap bilangan Fibonacci ke-i (i>2), Bilangan Fibonacci ke-i diperoleh dengan menjumlahkan Bilangan Fibonacci ke-(i-1) dengan Bilangan Fibonacci ke-(i-2). Berikut ini yaitu deret Fibonacci: 0, 1, 1, 2, 3, 5, 8, …

Jawaban Latihan Soal

Kelipatan 3


Faktor




Faktorial



Atau


Bunga Tabungan




Fibonacci




Sumber http://wikiwoh.blogspot.com

Pemodelan Untuk Komputasi : Logical Operator & Selection Dan Referensi Soal ( Bahasa Inggris )

Pemodelan untuk Komputasi : Logical Operator & Selection dan Contoh Soal ( Bahasa Inggris )




Introduction of Logic Operator & Selection

The university bookstore has a Kilobyte Day sale every October 24, giving an 8 percent discount on all computer accessory purchases if the price is less than $128, and a 16 percent discount if the price is at least $128. Write a agenda that asks the cashier for the original price and then prints the discounted price.


Solution
  • Check whether a condition is true or false à Is the price less than $128? (the answer is true or false).
  • Select only an alternative to be done and ignore any other alternative(s)



Relational Operator & Expressions


In order to make a decision, we need to know a condition that makes an alternative is chosen. In many cases, the condition involves comparing values. To compare values, we need :
  • Relational operator : an operator that is used to tests the relationship between two values.
  • Relational expressions : expression using relational/logical operator, the result of this expression is true or false



Relational Operator


Example

  • price < 128 (price is less than 128)
  • price >= 128 (price is greater than 128)
  • price = 128 (price equals to 128)
  • price ≠ 128 (price does not equal to 128)


Relational Expression

  • Relational expressions : expression using relational/logical operator, the result of this expression is true or false
  • Logical operator (AND, OR, NOT)
  • Example: the price <= 128 AND today = SUNDAY





Algorithms of Relational Expression



Use IF statement in our algorithm if it needs to choose between some different steps/alternatives. After the IF statement, we also need to write the conditions that are needed to be checked.

IF (conditions) then steps

The conditions are written using the relational expression. Example:

IF(price <=128) then discount = 0.08 * price

To choose an alternative, algorithm can have a compound conditions. Use the logical operator to make compound conditions. Example:

IF nilai >70 AND nilai <80 then nilaiHuruf = B





IF – ELSE

  • IF-ELSE statement chooses between two alternatives.
    • IF (conditions) then steps
    • ELSE steps
  • Example :
    • IF (nilaiHuruf=E) then status = tidak lulus
    • ELSE status = lulus


Example




Flowchart of Relational Expression

We use the diamond to symbolize the selection in flowchart. The diamond will have some branches. We can add the condition inside the diamond.

E.g. price<=128



Examples


Vowel or Consonant

Write the algorithms and draw the flowchart to check if a letter is a vowel or a consonant.





MAX

Write the algorithms and draw the flowchart to find maximum between two numbers






Exercise 1


Relational Operator



Some operators checks about the relationship between two values and these operators are called relational operators. Given two numerical values your job is just to find out the relationship between them that is (i) First one is greater than the second (ii) First one is less than the second.


Triangle



A long time ago, the Egyptians figured out that a triangle with sides of length 3, 4, and 5 had a right angle as its largest angle. Given the length of the sides of triangle, you must determine if the triangles have a similar property. The given lengths are always increasingly ordered.


Distance



Two wombats stand on a position in cartesian system of coordinates. Based on their position, we can determine if they are close friends or not. We can say that two wombats are close friends if their distance is less than or equals 200. Write the algorithms and the flowchart to determine if two wombats are close friends.


The Queen Problem


Given the positions (row and col number) of two queens on a chessboard. Your job is to write the algorithm and draw the flowchart to check if the two queens can attack each other.

Sumber http://wikiwoh.blogspot.com

Minggu, 30 September 2018

Pemodelan Untuk Komputasi : Selection Ii, Nested-If, Multiway-If, Dan Pola Soal ( Bahasa Inggris )

Pemodelan untuk Komputasi : Selection II, Nested-IF, Multi-IF, dan Contoh Soal ( Bahasa Inggris )






Introduction of Selection II



The Richter scale is a measurement of the strength of an earthquake. Every step in the scale, for example from 6.0 to 7.0, signifies a tenfold increase in the strength of the quake. We can categorize the scale into 5 categories: Category A (most structures fall), B (many buildings destroyed), C (many buildings considerably damaged, some collapse), D (damage to poorly constructed buildings), and E (no destruction of buildings). Write the kegiatan to categorize the Ritcher scale!



Notes :

  • Is it enough to use only if-else structure to solve the previous problem?
  • We need more than one alternative to categorize the Ritcher scale.
  • Solution: use multiway if-else or nested if


Algorithms of Multiway IF – ELSE 


We can use multi-way IF – ELSE if there are several alternatives that are needed to be chosen by our algorithm. 

IF (conditions) then steps 
ELSE-IF (conditions) then steps 
… 
… 
... 
ELSE stepsFlowchart: Multiway IF – ELSE 

Flowchart of Multiway IF – ELSE




Multiway IF – ELSE Example



Algoritmic Table



Flowchart






Nested IF

Nested IF is an if statement inside another. Any masalah that involves a multiway IF – ELSE can be solved using Nested IF. Furthermore, there are no differences between multiway IF – ELSE and Nested IF

Nested IF Example



Examples

Tax Regulation

Write an algorithm and draw the flowchart to calculate the income tax based on this regulation!



Algorithm: Tax Regulation



Exercise 1


Salary

You are given the salaries of these 3 employees working in the accounts department. You have to find out the minimum salary of those employees. Write the algorithms and draw the flowchart!



The Colors

In RYB colors, there are three primary colors: red, blue, and yellow. We can make a secondary color by mixing up two primary colors. We can create green by mixing up the blue and the yellow. The orange is created by mixing up red and yellow. The purple is created by mixing up red and blue. 

Given two primary colors, make an algorithm to find out what is the secondary color created by those primary colors !




Leap Year

Write an algorithm and draw the flowchart to determine if a year is a leap year. A leap year is a calendar day containing one additional day. These extra days occur in years which are multiples of four (with the exception of years divisible by 100 but not by 400).





Zapping

My TV remote is almost broken. Only △ and ▽ are working. My TV has 100 channels conveniently numbered 0 through 99. They are cyclic, in the sense that if I’m on channel 99 and press △ I’ll go to channel 0. Similarly, if I’m on channel 0 and press ▽ I’ll change to channel 99. I would like a kegiatan that, given the channel I’m currently watching and the channel I would like to change to, tells me the minimum number of button presses I need to reach that channel. 

Write the algorithm and draw the flowchart!



How Old Are You

Given two dates: current date and a birth date of a person. Write your algorithm and draw the flowchart to calculate how old a person is! Assume that there are no invalid date (current date is < birth date). 

Example: 
  • Current Date: 12/11/2007 
  • Birth Date: 01/01/1984 
  • Age: 23


Chocolate Bar



We want to make a package of goal kilos of chocolate. We have small bars (1 kilo each) and big bars (5 kilos each). Count the number of small bars to use, assuming we always use big bars before small bars. Output -1 if it can't be done. 

Example : 



Sumber http://wikiwoh.blogspot.com

Sabtu, 29 September 2018

Pemodelan Untuk Komputasi : Algoritmic Thinking Atau Berpikir Secara Algoritmik, Beserta Referensi Soal

Pemodelan untuk Komputasi : Algoritmic Thinking atau Berpikir Secara Algoritmik, beserta Contoh Soal ( Bahasa Inggris )



Introduction of Problem Solving

In the absence of computer 



In the presence of computers


  • How can computers solve human problems? 
  • More essential question : How can computers understand human problems? 
  • Two approaches : programming + intelligent systems 


Software Development Process




Algorithms



The origin of the word "Algorithm"is came from 9th Century Persian Mathematician, Abu Abdullah Muhammad ibn Musa Al-Khwarizmi. Algorithms is a very basic and (probably) the most important thing on the world of computer. It is a well-defined computational procedure to solve computational problems. It takes some value as input. It produces some value as output. 


Input and Output


  • Input : Data or values to be processed by algorithm in order to solve the problem
  • Output : data or values that are produced by the algorithm in order to solve the problem


Data

There are so many kind of data. Based on the values that are contained by the data, we can classify data as:
  • Numeric data : measurable (real number, integer, etc) 
    • Example : time, height, weight, amount, etc 

  • Non-numeric data : qualitative data, letters, symbol, true or false 
    • Example : course name, course code, marital status, etc


Variable

Sometimes, we need to store our data. When we do this, we need some variable. For example:

  Adding two numbers 

  • Input: 
    • The first number, an integer, stored in a variable called firstNumber 
    • The second number, an integer, stored in a variable called secondNumber 
    • You can calculate the result of addition operation and store it as new data into a variable called result. 

  • Output: result


Example of Algorithm

The Area of Circle



The Glass Problem

Womoes has 2 children. His first child is Womorange and the second one is Womberry. Womorange doesn’t want to drink anything but orange juice from his blue glass. Womberry doesn’t want to drink anything but strawberry juice form his transparent glass. On Monday before school, Womoes put the orange juice in transparent glass and strawberry juice in the blue glass. Help Womoes to swap the juices! They only have one blue glass and one transparent glass, but they have unlimited number of glasses with any kind of colors.



Exercise 1


For each duduk perkara below, write the algorithms to solve the problem! 

  • In 2018 you save your Rp x in a bank and you get 5% interest each year, in what year will you have more than Rp 2x? You never withdraw your money after the first time you save it. 

  • Wobung learns a new language. Every i-th day, he learns i number of new words. How many words will he learn after a year?

  • Womfarmer has a garden. The garden is a rectangle-shape garden. He divided the garden into two parts as shown below. Womfarmer plants sunflower in circle part and rose in blue part. If the width, the length of garden, and the radius of circle area are given, write the algorithms to find the area of blue part ! 




Flowchart

Type of diagram that represents an algorithms, workflow or process. It shows the steps as boxes of various kinds, and their order by connecting the boxes with arrows. It illustrates a solution model to a given problem. They are used in analyzing, designing, documenting or managing a process or aktivitas in various fields.

The two most common types of boxes in a flowchart are :
  • A processing step, usually called activity, and denoted as a rectangular box. 
  • A decision, usually denoted as a diamond.
 
Flowchart: Some Building Blocks and Fundamentals




Flowchart Example: Addition




Exercises 2



Write the algorithms and the flowchart to solve each duduk perkara below: 

  • A train can travel 50% faster than a car. Both start from point A at the same time and reach point B 75 kms away from A at the same time. On the way, however, the train lost about 12.5 minutes while stopping at the stations. What is the speed of the car ?

  • Three families share a garden. They usually clean the garden together at the end of each week, but last week, family C was on holiday, so family A spent 5 hours, family B spent 4 hours and had everything done. After coming back, family C is willing to pay $90 to the other two families. How much should family A get? You may assume both families were cleaning at the same speed. 

  • Two students appeared at an examination. One of them secured 9 marks more than the other and his marks was 56% of the sum of their marks. The marks obtained by them are… 

  • Out of 7 consonants and 4 vowels, how many words of 3 consonants and 2 vowels can be formed? 

  • What is the angle between the minute hand and the hour hand of a clock when the time is 4.20? 

  • The sum of ages of 5 children born at the intervals of 3 years each is 50 years. What is the age of the youngest child? 

  • What least number must be added to 1056, so that the sum is completely divisible by 23 ? 

  • Today is Monday. What day will it be after 61 days? 

  • The difference between a two-digit number and the number obtained by interchanging the positions of its digits is 36. What is the difference between the two digits of that number? 

  • We have three different integers, x, y and z, You are asked to find the values for x, y and z for given values of A, B and C which satisfy the following three relations: 
    • x + y + z = A 
    • xyz = B 
    • x^2+y^2+z^2=C 

  • A man standing at a point P is watching the top of a tower, which makes an angle of elevation of 30º with the man's eye. The man walks some distance towards the tower to watch its top and the angle of the elevation becomes 60º. What is the distance between the base of the tower and the point P? 

  • Two numbers are respectively 20% and 50% more than a third number. What is the ratio of the two numbers? 

  • A, B, C subscribe Rs. 50,000 for a business. A subscribes Rs. 4000 more than B and B Rs. 5000 more than C. Out of a total profit of Rs. 35,000, how much does A receive?

Sumber http://wikiwoh.blogspot.com