Friday, August 7, 2015

C$50 Vacation Online Class Notes:

“everyone should learn how to program a computer… because it teaches you how to think”
>>Everyone should learn how to think so they can use computers haha.

binary sufficiently large alphabet to describe data, the decimal system extends from this.
description of binary
binary digit - bit
application programming interface

analytical deconstruction of coding mechanisms in everyday situations, e.g. finding someone’s name in a phone book.

Scrats - graphical programming language

Cryptography - scrambling of information

breakout - implementation of coding skills in game

efficiency in programming - mb and other considerations

finance - application of cs50 to websites

use of 3d printing in plastic and biological endeavors

32 halves of a 4 billion integer set will find any given integer

formalization of algorithms and contemporary nomenclature
use of conditions or branches to increase efficiency in coding, aka corner cases

variables store integers

Conditions handle corner cases

pseudocode use to handle problems
necessity for specificity in computer programming

Use of Scratch 2 for the purpose of familiarization with code structure

Boolean expressions - true or false questions
Moving from scratch to C
Loops - repetition
conditions - if.. else
BASIC and public accessibility to programming - pseudocode
source code - english like syntax more properly defined and formatted than pseudo code
-> compiler -> object code
compiler is a program which converts source code into object code which is in binary
printf - formatted printing, in C means that which is in parentheses will be printed to the screen
main, loops, 
int main(void) is normal initiation of general program coding
while (true) = forever
int counter = 0;
while (true)
printf(%d\n”, counter);
a loop may use for: for (i=0, i>0, i<10, i=10)
boolean expressions- use for greater than or less than statements
conditions - printing results from boolean expressions
hypervisor as a layering, allowing emulation of second operating system, in this class linux
Gedit - simple text editor 
Using C to make a program which can create a program
CD - change directory
ls- list
training wheels for the class are in cs50.h which is a header function
editing for errors: thinking about fundamental ideas
getchar- get command
getint- get integer
getstring- get word
equal sign will be equivalent to assign in the class


Outsourcing input in programming code

#include <stdio.h>
int main(void)
printf(“Hello, world\n”);
*/ to: *//

#include <cs50.h>
#include <stdio.h>
int main(void)
printf(“state your name\n”);
string s = GetString();     */ maybe? *//
printf(“Hello, world%s\n”, s);

UI- user interface
GUI - Graphical User Interface

header- including and downloading past functions stored on computer
default main - part of program which is executed first
printf- prints to screen
role of parentheses: surround inputs to the function
\n - new line
; - ends a statement

using DOS to move files and programs, access previous resources

escape sequence - begins with a “\” and initiates a specially procedure
%d, %i, %s, - place holder for decimal, integer, string
values can be stored
char - type of data
float is type of data
int is integer
long is for long long numbers

types of questions
bool - one or zero, yes or no
// is precursor to comment

loops: for, while, or do
variables: declaring variables and assigning values

int counter;
counter = 0;

#include <cs50.h>
#include <stdio.h>

int main(void)
printf(“Give me an integer: “);
int x = GetInt();
printf(“Give me another integer: “);
int y = GetInt();

printf(“The sum of %1 and %2 is %1f/n f = x + y”);

#include <cs50.h>
#include <stdio.h>

int main(void)
printf(“Give me an integer: “);
int n = GetInt();
If (n<0)
printf(“You picked a negative number “);
printf(“You picked a positive number”);

Bug - mistake in program
for (int i = 0; i < 10; i++)

Curly brace are needed for function

Mac bug in implementation of SSL: one line error
double goto fail; second executes no matter what

abstractions - solving problems without solving problems
look for the main function and follow code logically from there
print-> getstring -> PrintName
PrintName is written within the code, not pre-prorammed into C
prints hello, comma, name

using int and void
void does not return anything, it may print something
int will return an integer, eg. input cubed
the variable must be declared outside of the curly braces in which it is used, anything else will return an error, as the variable is referenced in a section of code in which it does not exist

This is the same reason that header files should almost always be at the top of the code

Scope - local vs. global
extant in variables
representation of information:
types: char, int, float, double, long long
char - one byte, character, 8 bits
int - 4 bytes, or 32 bits, highest number that can be represented is 4 billion
float - 4 bytes, or 32 bits, only have a finite amount of precision
double - 8 bytes, but still finite, problematic in graphics or mathematical formulas
long long - 8 bytes, 2X an int

integer overflow
0 will come after 255

floating-point precision: will throw decimals away in the event an int is used 
use floating values instead, and the decimal will be returned
imprecision will occur at a certain point, however
this creates some severe and legitimate side effects 
Ariane rocket built for the ESA was too fast and overloaded the software which was not prepared to handle the problem
Patriot missile in first Gulf War, suffered the same problem
both iraqi wobble allowed failure of patriot system, as well as a software glitch which prevented tracking of incoming missiles when the radar system was in operation for a “long time”
a tenth of a second could not be expressed in binary


decoder ring and algorithm associated
strings - memory
structuring the string into a box^^^

string s = GetString();
for (int i = 0; i < strlen(s);  ++i)
printf(“%c\n”, s[i]);

will not compile: needs header files
add: #include <stdio.h> for for and printf and <cs50.h> for string
strlen is in directory not included in header, short for string length
use man (for manual) strlen to find directory: #include <string.h>

if (s != NULL) should be added after GetString in order to prevent program crashing from improper input

!= - does not equal

to improve design, n should be substituted for strlen(s), this is more cumbersome in the program, but will use less cycles of the computer and is a superior design

i++ is the same as i +=1

ASCII American Standard Code for Information Interchanges

for (int i = 65; i <65 + 26; i++) //establishes a loop, which will continue for 26 cycles

It becomes necessary to then treat the i as a char, which allows transcription of the numeric value into a character or series of characters.

&& - and

if (s[i] >= ‘a’ && s[i] <= ‘z’)
*/ This allows the program to determine whether an input is a lower case letter or not, by adding 32 to the letter or subtracting 32 from the letter (char), this will change a lowercase letter to an uppercase letter or vice-versa, topper requires #include <ctype.h>*//

so this comes in : printf(“%s\c”, toupper(s[i]));
which simplifies the if and else statement somewhat, but this is where the function refers to, and what it looks like within the original directory

importance of planning in memory allocation:
rather than typing zamyla_|_| and depressing enter to begin on the next line, a computer will represent an end of a string in memory with a great number of zeros so zamyla\0belinda\0gabe\0daven\0
a string in a row of boxes in C is known as an array
array - contiguous sequence of similar data types


int main(void)
int age1 = GetInt();
int age2 = GetInt();
int age3 = GetInt();
//do something with those numbers

The program, however, is limited: if more than 3 or less than 3 ages show up, the program will crash, requiring a rewrite of the code every time it is posted
this can be avoided by declaring a variable each time, which will be saved, say, as i

command-line arguments
encryption algorithm, such as ROT-13, simply rotation 13
examples include caesar, vigenere, the latter of which is more secure and requires a different rotation for each letter

int main (void)
mkdir pset2 - creates a directory
so far main cannot take any arguments, it returns void
int argc, string argv[] can replace void, will allow understanding of what a string is under the hood
arrays use square brackets which are used to declare the size of the array
argv- argument vector, array of arguments, above it is used as a string of arguments
command line arguments:
argc is an int, can be any number
argv is an array, will have multiple values e.g.. argv[0], argv[1] etc…
argc will count the number of strings associated to argv, so cd hello: argc = 2 but hello.c argc =1
#include <cs50.h>
#include <stdio.h>
int main(int argc, string argv[])
printf(“hello, %s\n”, argv[1]);
by manipulating this number in the brackets, unfettered access may be gained into memory which should not be accessed
#include <cs50.h>
#include <stdio.h>
int main(int argc, string argv[])
if (argc == 2)
printf(“hello, %s\n”, argv[1]);
return 0;
return 1;
This serves as a sanity check, which will ensure that only the memory allocated to the program is accessed

string - array of chars

so in each indexes there are array of chars

%c is placeholder for char
syntax - argv[i][j] i denotes the string, j will denote the char within that string to display

CPU cycles necessary for integer order to be established
all of the algorithms are fundamentally equally efficient, because there is a more efficient manner of carrying out the sorting:
others include


“Shellshock” internet crash
Command line shell, allows programmers to launch programs and features, spying as well
2/3 of all web servers were placed at risk
action: matching, monitering web virals
“born again shell”
is also  a programming language: allows defining your own commands, hello() { echo “hello, world”; }
will create a shell program which prints hello, world
historically, present for over 20 years
in mac: env x=‘() { :; }; echo vulnerable’ bash -c :
this will return whether the computer is vulnerable to bash viruses
rm -rf * instead of vulnerable will delete all files in specified directory
Security requires complete coverage, attack requires only one entry point

reflections on trusting trust

n log (n)
log base 2 of 8 is 3

on input of n elements
if in < 2
sort left half of elements
sort right half of elements
merge sorted halves
 T(n) = T(n/2)+T(n/2)+O(n)
ultimately equals O n log n
that pseudocode is recursive, that is to use cycling

adds numbers 1 through n

int sigma(int n);

int main(void)
int n;
printf(“Positive integer please: “;
n = GetInt();
while (n>0)
int answer = sigma(n);
printf (“%i\n”, answer);
//avoids risk of an infinite loop below
int sigma(int m)
if (m <= 1)
return 0;
return (m + sigma(m - 1));

int sum = 0;
for (int i =1; i <= m; i++)
sum += i;
return sum;

// necessity to access this outside of the loop

initialized data
initialized data
environment variables

this idea of recursion can cause some problems and will come back in later classes in which programs require hierarchy in trees: there is a necessity not to exceed available memory by allowing these trays of memory to pile on excessively

void swap(int a, int b)
int tmp = a;
a = b;
b = tmp;

shows necessity for a 3rd content, tmp, to enable a swap of two variables, a and b
when using in a program, the swap values must be returned to the main, and transferred to the original variables

gdb - a program which can be added before running programs to find bugs
syntax: (gdb) run or next or print (variable)

this can be manipulated to explore the program in full and find what the computer thinks is going on at various points and variables throughout the program, line by line

Monday, August 3, 2015

Picky Eaters: the Plant or the Person?

This research published by Nancy Zucker at the Department of Psychiatry and Behavioral Sciences, Duke Medical School in conjunction with a team of researchers through Duke University Press examines the mental stability of picky eaters in a careful manner. Evaluation of  current and prospective mental stability are both provided and family stability is also examined. This provides an insight into one of the most pervasive of human relations with botanical life: nutrition. Causality of the disorder is  examined or determined as severity of the disorder correlates appropriately with severity of associated mental illnesses and leaves logical deduction of coincidence slim; the success of early and aggressive intervention is highlighted, and the research suggests appropriate action while acknowledging the limitations provided by such a study.
Selective eating disorder has been chosen for the research because of its overwhelming prevalence, and with the data provided in the study, the overwhelming consequences of inaction. It is worth noting that 14-20% of young children suffer from the disorder and co-occurring psychological illness can be seen demonstrated in a medically appropriate manner. The crisis is apparent: nearly 2/3 of these parents who have afflicted children have reported that the disorder was not addressed appropriately by medical professionals. While the research is limited, it is also longitudinal and fills a scientific gap in investigation into the nature of this disorder, a gap which the authors attribute the inaction of medical professionals to.
While the research does not directly address the plant-based eating choices of the children themselves, a systematic evaluation of the families is also done: children with selective eating disorder were significantly more likely to have mothers with mental health histories and those with moderate selective eating disorder (about 3% of the sample) were significantly more likely to have mothers with substance abuse histories. This plays into the psychoactive role of many plant-based compounds which can create physical dependence and demonstrates their effects on the families and individuals around those who make these illegal choices. The research is critical to that of plant biology because both taste and texture of foods are identified as factors in the development of the disorder, and the crisis has been created in which some children may eat enough to sufficiently fit criteria of weight gain and avoid more traditional diagnosis while still not obtaining enough nutrients from plant or animal-based food and drink to maintain psychological or physical health. Finally, it should also be noted that children with severe selective eating disorder have more than twice the rate of depression or social anxiety as those without though those with moderate selective eating disorder, though these diagnoses were substituted with an association with, not necessarily causal, symptoms of ADHD and separation anxiety not seen in severe cases.

Works Cited: