본문 바로가기

IT/ETC

Arrays and Sorting Algorithms (week2)

반응형

Preprocessing – #include <stdio.h>

Compiling - programming language converts codes to assembly language for computer to understand

Assembling – using assembling code and converts to 10101010100101001010s(machine code, object code)

Linking – linking step links all the imported files, stdio.h + cs50.h + yourfile.h.

at step linking, converting all imported files into machine code and about to link them together

These days, people call these four steps compiling to be general.

 

Ram, random access memory, only runs when electricity is being charged to the device. This is the place where all the programs store memory temporary, copying the data from physical storage device and pasting it to ram. Much faster to access file from ram than from physical storage space every time you access a file.

 

Continuous memory is represented as an array. Array helps design wise and helps sufficiency.  

Printing one character at a time

 

Capitalizing all characters

 

Printing ascii per character
Prints typed arguments including program name and types all character of that argument

 

using returns

Main contains return key, just implicitly. For example, when an error occurs, a number might appear like -27, a programmer has defined the error as return -27 for that certain problem.

 

Sorting Algorithms

 

Bubble sort – repeatedly swapping the adjacent element if they are in the wrong order. For every turn, the searching size will decrease from the last place of an array.

 

Selection sort – repeatedly finding the minimum element from unsorted order. For every turn, the first place of an array increases.

How O(n^2)is calculated
Beautiful time complexity graph

Merge sort - a divide and conquer algorithm, it divides the array in two halves, and if the array is sorted, it merges with sorted arrays. O(n log n)

 

Insertion sort, gnome sort both have O(n^2) time complexity.

 

반응형

'IT > ETC' 카테고리의 다른 글

C Programming Language(week1, problem set)  (0) 2019.12.30
Memory (week3)  (0) 2019.12.27
C Programming Language(week 1)  (0) 2019.12.25
Computational Thinking & Scratch – Intro to Computer Science(week 0)  (0) 2019.12.25
The Shawshank Redemption review  (4) 2019.12.16