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.

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

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.

void -  all of this time, specifies that this program, when run,can only be run via its name.
You cannot type any other words or numbers after the program's name when running it. So, for instance, if the program were compiled into a file called hello, you could do ./hello, but that is it

suppose that we actually want to start writing programs that are little more versatile, and, frankly, a little more like the commands that you've been getting, hopefully, a little bit accustomed to.
Like cd space Dropbox.

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

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
integer to char
ctype library functions - toupper and islower
https://reference.cs50.net/   info for functions in libraries
strings end with \0

Sunday, April 26, 2015

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

More about  functions and data types are discussed in the lecture while at the end, is the tragic story about the Patriot missile which was caused by a  floating point arithmetic error. 

Some short notes here on the lecture:-

can omit curly braces when using one line of code
ssl - encrytpion
regulations about cs50
abstraction - encapsulates
int - returns an integer
implementing get positive int for error checking
int n in the proper braces
scope - local vs global
data types - char,int, etc
char - 1 byte or 8 bits - 256 total values
int - 4 bytes -  4 billion values
float 4 bytes, double 8 bytes, long long  8 bytes
overflow - 0 comes after 255 for 8 bit values
problems related to float

Sunday, April 19, 2015

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

Right at the end is the touching story of Saroo Brierly which  is going to be made into a film soon.

Some short notes here on the lecture:-

make - make object code
printf is in stdio.h
main - default entry point
paranthesis - holds what is used in printf
double quotes - surround phrase
\n- newline
;   -   finishing a statement
make - finding the file and convert to object code
clang - compiler
clang hello.c - ls to list contents of directory - a.out
mv a.out hello  and then -lcs50
in stdio.h   more to printf
escape sequences
%i is a placeholder for integer
types of variables - float, int , char
in cs50 library - string and bool - Getstring etc
condition  - if condition   { do this }
boolean expression   -  if condtion  and/or another condtion is true needs && and ||
switches - like if else but use cases
loops  -  for, do while
variables need to be defined
a program to do addition with  int x=Getint();
condition-0.c  -  if, else  at first but could not detect zero so if , else if and else used

Sunday, April 12, 2015

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

A  history of Paul Allen and Bill Gates and their path to programming the Altair 8800 is read out by two students.  String variable is introduced in this lecture.

Some short notes here on the lecture:-

source code
object code  0 and 1

while (true) - can run forever
for loop - iterate from 0 to 10
variable - store something
counter - counts forever
boolean expressions  eg    if x>y
condition - compares

compiler - eg gcc
standard environment linux  - a hypervisor
cs50 appliance - gedit

make - triggers the compiler - saves 0 1and1 in a file called hello
./hello runs 
\n is actually new line
string s   %s
printf is part of stdio.h
cs50.h library has functions