Eat Study Love

먹고 공부하고 사랑하라

python search 5

The K Weakest Rows in a Matrix(Array,Binary Search,Sorting,Heap (Priority Queue),Matrix)

https://leetcode.com/problems/the-k-weakest-rows-in-a-matrix/description/You are given an m x n binary matrix mat of 1's (representing soldiers) and 0's (representing civilians). The soldiers are positioned in front of the civilians. That is, all the 1's will appear to the left of all the 0's in each row.A row i is weaker than a row j if one of the following is true:The number of soldiers in row..

Coding_Practice 2024.11.28

Review 6 - Python Search(Linear / Binary) & Sort(Selection / Insertion)

https://eglife.tistory.com/72 Review 5 - Python OOP(Objected Oriented Programming)https://eglife.tistory.com/68 Review 4 - Python File I/Ohttps://eglife.tistory.com/67 Review 3 - Loop & Set,Tuple,Dictionaries,Mutabilityhttps://eglife.tistory.com/66 Review 2 - Python의 기본 Module , Classhttps://eglife.tistory.com/65 Review 1 - Pyeglife.tistory.com 머리 박고 달리자~ 이번엔 파이썬 Search다. 이 이후로 내용이 째끔 머리 복잡할듯 헌데..

SW 만학도/Python 2024.07.05

9-2 . Recursion으로 Binary Search의 여러가지 Case 코딩해보기

1) Binary Search 에서 List 는 이미 Sort 되어 있지만 찾고자 하는 Value가 Duplicate 되어 있을 때 - Middle을 찾았을 때 Term만 좀 While문으로 만져주면 될 거 같다. - Recursion으로도 구현할 수 있을 거 같긴 한데.. 일단 While문으로! Recursion을 이용해서도 해당 코드를 구현해보았다. 다소 조잡한 감이 있어도 코드는 잘 돌아가서 다행이다..ㅎㅎ 특이점으론, Recursion 함수를 잘 만들어 놓고 해당 함수를 binary_search에 넣었을 때 자꾸 무한루프를 돌면서 코드가 버벅거렸다. 이유를 찾아보니.. recursion함수를 binary_search에서 사용할 때에도 return을 이용해서 사용해야 하는데 그냥 함수만 Call해서..

SW 만학도/Python 2024.03.17

9-1 . Binary Search의 여러가지 Case 코딩해보기

1) Binary Search 에서 List 는 이미 Sort 되어 있지만 찾고자 하는 Value가 Duplicate 되어 있을 때 - Middle을 찾았을 때 Term만 좀 While문으로 만져주면 될 거 같다. - Recursion으로도 구현할 수 있을 거 같긴 한데.. 일단 While문으로! https://eglife.tistory.com/27 낄끼빠빠~ Recursion 구현글 첨부 9-2 . Recursion으로 Binary Search의 여러가지 Case 코딩해보기 1) Binary Search 에서 List 는 이미 Sort 되어 있지만 찾고자 하는 Value가 Duplicate 되어 있을 때 - Middle을 찾았을 때 Term만 좀 While문으로 만져주면 될 거 같다. - Recursi..

SW 만학도/Python 2024.03.17

9. Computational Complexity & Searching (Big O with Search/Sort in Python)

프로그램을 돌리는데 시간이 얼마나 소요될 지에 대한 공부이다. 일일히 모든 시간을 다 측정할 수 없으니 Programming에선 자잘한 거 빼고 큰 단위 N으로 Time Complexity를 계산한다. -ex) Linear_search / Selection_sort Linear_Search # Linear Search에서 Timex Complexity 계산해보기 ​ def linear_search(lst:list,value:int) -> int : for i in range(len(lst)): if lst[i] == value: return i return -1 ​ lst = [0,1,4,5,-1,6,100] print(linear_search(lst,9)) print(linear_search(lst,5..

SW 만학도/Python 2024.03.17