언젠가는 되어있겠지
데이터 공부 노트
언젠가는 되어있겠지
전체 방문자
오늘
어제
  • 분류 전체보기 (410)
    • Programming (14)
      • Python (6)
      • Algorithm (8)
    • OS (9)
      • Linux (9)
    • DBMS (2)
      • MySQL (2)
    • IoT Apps (6)
      • AppInventor (5)
      • Arduino (1)
    • LeetCode (151)
      • Easy (136)
      • Medium (13)
      • Hard (2)
    • Course (207)
      • [IBM] Data Science (9)
      • [IBM] Data Engineering (5)
      • [Inflearn] Pandas (12)
      • [Inflearn] Public Data Anal.. (8)
      • [Kaggle] Data Science (49)
      • [Youtube] Informations (2)
      • [Coursera] Machine Learning (40)
      • [Progrmiz] Data Structure A.. (15)
      • [DataQuest] Data Engineerin.. (67)
    • Data Engineering (20)
      • [Data Quest] Handling Datas.. (16)
      • [Data Quest] Data Pipeline (4)
    • Certificate (0)
      • 빅데이터 분석기사 (0)
    • SQLD (0)
    • 하고 싶은 이야기 (0)
    • 소설 (0)

블로그 메뉴

  • 홈
  • 태그

공지사항

인기 글

태그

  • Data Science
  • Kaggle Course

최근 댓글

최근 글

티스토리

hELLO · Designed By 정상우.
언젠가는 되어있겠지

데이터 공부 노트

Course/[Progrmiz] Data Structure Algorithm

[Introduction] What is algorithm?

2022. 8. 8. 15:22

1. What is Algorithm?

In computer programming terms, an algorithm is a set of well-defined instructions to solve a particular problem. It takes a set of input(s) and procedures the desired output. For example, An algorithm to add two numbers :

 

  1. Take two number inputs
  2. Add numbers using the + operator
  3. Display the result

 

2. Qualities of a Good Algorithms

  • Input and output should be defined precisely
  • Each step in the algorithm should be clear and unambiguous
  • Algorithms should be more effective among many different ways to solve a problem.
  • An algorithm shouldn't include computer code. Instead, the algorithm should be written in such a way that it can be used in differnt programming language.

 

3. Examples of Algorithms

3.1 Add two numbers entered by the user

Step 1 : Start 
Step 2 : Declare variables num1, num2, and sum.
Step 3 : Read values num1 and num2
Step 4 : Add num1 and num2 and assign the result to sum. sum <- num1 + num2
Step 5 : Display sum
Step 6 : Stop

3.2 Find the largest number among three numbers

Step1 : Start
Step2 : Declare variables a, b and c. 
Step3 : Read variables a, b and c. 
Step4 : If a > b 
            If a > c 
                Display a is the largest number. 
            Else 
                Display c is the largest number. 
        Else 
            If b > c 
                Display b is the largest number. 
            Else 
                Display c is the largest number. 
Step5 : Stop

3.3 Find Roots of a Quardratic Equation \(ax^{2} + bx + c = 0\)

Step 1: Start
Step 2: Declare variables a, b, c, D, x1, x2, rp and ip;
Step 3: Calculate discriminant
         D ← b2-4ac
Step 4: If D ≥ 0
              r1 ← (-b+√D)/2a
              r2 ← (-b-√D)/2a 
              Display r1 and r2 as roots.
        Else     
              Calculate real part and imaginary part
              rp ← -b/2a
              ip ← √(-D)/2a
              Display rp+j(ip) and rp-j(ip) as roots
Step 5: Stop

3.4 Find the factorial of a number

Step 1: Start
Step 2: Declare variables n, factorial and i.
Step 3: Initialize variables
          factorial ← 1
          i ← 1
Step 4: Read value of n
Step 5: Repeat the steps until i = n
     5.1: factorial ← factorial*i
     5.2: i ← i+1
Step 6: Display factorial
Step 7: Stop

3.5 Check whether a number is prime or not

Step 1: Start
Step 2: Declare variables n, i, flag.
Step 3: Initialize variables
        flag ← 1
        i ← 2  
Step 4: Read n from the user.
Step 5: Repeat the steps until i=(n/2)
     5.1 If remainder of n÷i equals 0
            flag ← 0
            Go to step 6
     5.2 i ← i+1
Step 6: If flag = 0
           Display n is not prime
        else
           Display n is prime
Step 7: Stop

 

4. Source of the course

https://www.programiz.com/dsa/algorithm

 

What is an Algorithm?

In computer programming terms, an algorithm is a set of well-defined instructions to solve a particular problem. It takes a set of input(s) and produces the desired output. For example, An algorithm to add two numbers: Take two number inputs Add numbers us

www.programiz.com

 

'Course > [Progrmiz] Data Structure Algorithm' 카테고리의 다른 글

[DS1] Stack  (0) 2022.08.10
[Introduction] Divide and Conquer Algorithm  (0) 2022.08.09
[Introduction] Asymptotic Notations  (0) 2022.08.08
[Introduction] Why Learn DSA?  (0) 2022.08.08
[Introduction] Data Structure and Types  (0) 2022.08.08
    'Course/[Progrmiz] Data Structure Algorithm' 카테고리의 다른 글
    • [Introduction] Divide and Conquer Algorithm
    • [Introduction] Asymptotic Notations
    • [Introduction] Why Learn DSA?
    • [Introduction] Data Structure and Types
    언젠가는 되어있겠지
    언젠가는 되어있겠지

    티스토리툴바