Computer Science/Discrete mathmatics

[이산수학] Combinatorics and Probability 조합론과 확률 2주차

dev seon 2023. 9. 13. 19:00

Combination 조합

토너먼트 : 5개의 팀이 있을 경우 각 팀은 4번의 경기를 치룬다. 즉 5*4번의 경기를 치룬다.

겹치는 경우를 제외해준다.

n(n-1)/2

게임의 종류 1. 첫번째 팀 포함 게임수 n-1 / 2. 첫 번째 팀 빼고 T(n)

-> T(n)=(n-1)+T(n-1)=(n-1)+(n-2)+....+2+1+0

from itertools import combinations

for c in combinations("abcdefgh", 2):
	print("".join(c))

집합 S에 대하여 k-조합은 k크기의 S의 부분 집합이다.

 

파스칼의 삼각형

 

C=dict()

for n in range(8)
	C[n, 0]=1
    C[n, n]=1
    
    for k in range(1,n:
    	C[n, k]=C[n-1, k-1]+C[n-1, k]
        
 print(C[7,4])

Row sum=2^n

 

coursera Introduction to Discrete Mathematics for Computer Science 과정 중

 Combinatorics and Probability 2주차 내용 정리