Hi i will share the notes i obtain from my lecture
Sorting can be done 2 ways, ascending or descending.
I learnt 5 ways of sorting :
- bubble sort
- selection sort
- insertion sort
- quick sort
- merge sort
Bubble,selection and insertion all took a lot of time to do that is because they compare every single array element with the other.
while quick and merge sort are faster and they use recursive function to do them.
Searching is an action to retrieve information based on particular key from saved information
Key is used to differentiate between one data and the other, Key must be unique so there is no duplicate key inside a data.
Several searching methods are : Linear, Binary, Interpolation
- Linear search : compares each element inside an array with the key
- Binary search : find data using its binary, but the data needs to be sorted first
- Interpolation data : also works on sorted array, searching technique is done with the approximate location of data.
Sunday, December 16, 2018
File Processing
Hi I want to share notes i get from my lecture
C sees files as stream, what is stream? Stream is a sequence of character, all input and output data is stream.
There are 2 types of file, text file and binary files.
- Text file is saved in text format or ASCII FILE
- Binary file is saved by storing numerical data in affixed format
Buffer area : a part of a memory used as a temporary space before data is moved to a file.
if file is opened with fopen it will need to be closed with fclose
you can either read,write or append data from a file in C.
- read = store file in c
- write = to place a new data in the file
- append = to update new data to the file
C sees files as stream, what is stream? Stream is a sequence of character, all input and output data is stream.
There are 2 types of file, text file and binary files.
- Text file is saved in text format or ASCII FILE
- Binary file is saved by storing numerical data in affixed format
Buffer area : a part of a memory used as a temporary space before data is moved to a file.
if file is opened with fopen it will need to be closed with fclose
you can either read,write or append data from a file in C.
- read = store file in c
- write = to place a new data in the file
- append = to update new data to the file
Recursion and Function
Hi so today I will tell you what i,ve learned from my class.
The programming method i am learning now is modular programming, which divides a problem to a smaller set of problem to make it easier to solve.
Modular programming major benefit is to make it easier for us to know if there are some mistakes in our program and easier for us to fix the problem.
Function : a set of programming statements which are gathered because they do the same action
There are 2 types of function : library function and user defined function
-library function : function that is provided by C compiler
-user defined function : self defined function by the author
You can use function by passing parameter to the function from your main module.
Variable to be used by the functions can be either local or global variable.
Global variable : variable that can be used by every function.
Local variable : variable that can only be used by a certain function
The programming method i am learning now is modular programming, which divides a problem to a smaller set of problem to make it easier to solve.
Modular programming major benefit is to make it easier for us to know if there are some mistakes in our program and easier for us to fix the problem.
Function : a set of programming statements which are gathered because they do the same action
There are 2 types of function : library function and user defined function
-library function : function that is provided by C compiler
-user defined function : self defined function by the author
You can use function by passing parameter to the function from your main module.
Variable to be used by the functions can be either local or global variable.
Global variable : variable that can be used by every function.
Local variable : variable that can only be used by a certain function
Subscribe to:
Comments (Atom)