Tuesday, May 26, 2015

edX: - HarveyMuddX: CS002x Programming in Scratch

This is a fun course to try out. I have learnt quite a few things from it and though it may seem to be more geared towards children, adults can join in and will probably find Scratch to be a useful program. I think it brings out the child in everyone of us and it is one of the better edX courses.


Monday, May 18, 2015

edX: - HarvardX: CS50x3 Introduction to Computer Science - week 3 Continue

Obama was not totally wrong when it came to answering a Computer Science question.



bubblesort
(n(n-1))/2
big O    - eg  order of n^2   or O(n^2)

O(n) - finding maximum number in a list
O(log n)  -eg  phonebook -approximately decreases  problem in half every step - list has to be sorted 
O(1)  -  constant

lower bound (n) or   Ω(n)  - eg  bubblesort
lower bound (1)  - phonebook
selection sort -    upper bound and lower bound of n^2
insertion sort -  upper bound and lower bound of n^2
merge sort - eg sort left, sort right and merge  O(n log(n))  which is much faster

Creative Commons License
This work is licensed under a Creative Commons Attribution-NonCommercial 4.0 International License.

Sunday, May 10, 2015

edX: - HarvardX: CS50x3 Introduction to Computer Science - week 3

Main functions, command line arguments and sorting  are covered . There are some fun examples of sorting here.







main with argv[] - array of strings
2 chunks of memory


./hello-3 Zamyla     with argv[1]
if no name  - null
argv[5000]  - segmentation fault - touched segment of memory we should not have

error checking   - argc==2
any number of arguments beside 2, program will exit

string - array of char
argv-1      This will print each argument, one per line 
argv-2    get the jth char in the string

sorting- bubble sort, selection sort, insertion sort




Creative Commons License
This work is licensed under a Creative Commons Attribution-NonCommercial 4.0 International License.

Sunday, May 3, 2015

edX: - HarvardX: CS50x3 Introduction to Computer Science - week 2 Continue

Strings and arrays are covered. At the end is a humorous clip from the movie " Spaceballs".






string - char
strlen needs string.h library
not enough memory
null if something goes wrong
check for null
ASCII
integer to char
capitalize
ctype library functions - toupper and islower
https://reference.cs50.net/   info for functions in libraries
arrays
strings end with \0

Creative Commons License
This work is licensed under a Creative Commons Attribution-NonCommercial 4.0 International License.