Sort
·
data structure
sort: to arrange something in an order to use fast algorithms ex. binary search, array should be sorted 1. bubble sort - not used very much (there are a lot of better algorithms) - select first 2 items of an array and compare them > if left is bigger than the right, swap them > do the same with index 1, 2 > repeat …. > when it reaches the end of an array, the first cycle of bubble sort ends > do..
Type of Time Complexity (Big O notation)
·
data structure
1. Constant time complexity constant time algorithm: regardless of input size, number of steps are determined. time complexity = O(1), O(2), … 2. Linear time complexity linear search algorithm has a time complexity of O(N) time complexity = O(N) N: number of inputs linear search algorithm: time complexity = O(N) 3. Quadratic time complexity (2차 시간) - happens when a function has nested loops(중첩 반..
Search Algorithms (Binary Search/ Linear Search)
·
data structure
Algorithms: Search, Sort, …. Linear Search - check from index 0 - linear time complexity: as input size grows, running time also increase in a linear way Binary Search - only works on sorted array - sorted array: items on an array are sorted. adding items on a sorted array takes more time than one that is not - searching process starts from the middle of the array
Array
·
data structure
배열 생성 시 배열의 길이(size)를 지정해야 함 (JS, Python의 경우 언어에서 이 부분을 핸들링해주기 때문에 길이를 지정하지 않고 생성 가능) Characteristics of array - 0-indexed: array’s elements are indexed from 0 - very fast when reading data, but slow in searching/adding/deleting Types of Operation and how it works - Read: give index number of an element and get it > super fast - Search: find the element the user wants > have to check every eleme..