======Data Structures Journal====== ====AUG 28, 2013==== Discussed in class: dynamic memory allocation syntax error logical error runtime error Talked about the games Free cell, Forty thieves, and eight off. ====AUG 29, 2013==== TURTLE DAY!!!! "mv - command to 'move' files" Discussed in class: Pointers Class Chat room Review roll: flip: define: 'word' weather: 'zip' Opus Review Mercurial Repo's hg add hg push Created/added classroom chats made directories 'structures' ptr.c #include #include int main( ) { int a, *b; a=12; // b=&a; fprintf( stdout, "[a] address is: 0x%X\n", &a ); fprintf( stdout, "[a] contains: %d\n", a ); // fprintf( stdout, "[a] dereferences to: %d\n", a); fprintf( stdout, "[b] address is: 0x%X\n", &b ); fprintf( stdout, "[b] contains: 0x%X\n", b ); fprintf( stdout, "[b] dereferences to: %d\n", *b); return(0); } ====AUG 30, 2013==== numberfun.c #include #include int main( ) { signed char sc=0; unsigned char uc=0; printf(" a signed char is %hhu bytes\n", sizeof(sc)); printf(" lower bound is: %hhd\n", ((unsigned char)(sc-1)/2+1)); printf(" upper bound is: %hhd\n", ((unsigned char)(sc-1)/2)); printf(" --------------\n"); printf(" an unsigned char is: %hhu bytes\n", sizeof(uc)); printf(" lower bound is: %hhu\n", uc); printf(" upper bound is: %hhu\n", uc-1); printf(" --------------\n"); return(0); } %d - signed int %u - unsigned int %hu - half(short) unsigned int %hd - half(short) signed int %hhu - half half (short short) unsigned int %hhd - half half (short short) signed int %lu - long unsigned int %ld - long signed int ====SEP 4, 2013==== struct.c #include #include int main( ) { struct person { char *name; int age; long int id; }; typedef struct person Person; //struct person People[8]; Person People[8]; int i=0; for (i=0;i<8;i++) { printf("Enter person #%d's name:", (i+1)); People[i].name=(char*)malloc(sizeof(char)*20); scanf("%s", People[i].name); printf("Enter %'s age:", People[i].name); scanf("%d", &People[i].age); printf("Enter %s's id number:", People[i].name); scanf("%d", &People[i].id); } i=-1; while(i==-1) { printf("Look up data for person #:"); scanf( "%d", &i ); if(!((i>=0)&&(i<=7))) { printf("Invalid person #. Try again!\n"); i=-1; } } printf( "Name: %s\n", People[i].name); printf( "Age: %d\n", People[i].name); printf( "ID: %d\n", People[i].id); return(0); ====SEP 5, 2013==== TURTLE DAY!!!! "You can check your file permission with ls -l" structnode.c #include #include struct node { int value; struct node *next; }; typedef struct node Node; int main() { int input = 0; Node *list, *tmp; list = tmp = NULL; while (input != -1) { printf("Enter a value(-1 to end):"); scanf("%d", &input); if (input != -1) { if (list == NULL) { list = tmp = (Node *) malloc(sizeof(Node)); tmp->next = NULL; list->next = NULL; } else { tmp->next = (Node *) malloc(sizeof(Node)); tmp->next->next = NULL; tmp->next->value = input; tmp = tmp->next; } } } tmp = list; while (tmp !=NULL) { printf("%d ->", tmp->value); tmp = tmp->next; } printf("NULL\n"); return (0); } ====SEP 11, 2013==== GNU nano 2.2.4 File: linkedlist_2.c #include #include struct node{ int value; struct node *next; }; typedef struct node Node; int main() { int input = 0; int seeker; Node *list, *tmp, *tmp2; list = tmp = tmp2 = NULL; while( input != -1 ) { printf("Enter a value (-1 to end): "); scanf("%d", &input); if( input != -1) { if( list == NULL ) { list = tmp = (Node*)malloc(sizeof(Node)); tmp->next = NULL; list->value = input; } else { tmp->next = (Node*)malloc(sizeof(Node)); tmp->next->next = NULL; tmp->next->value = input; tmp = tmp->next; } } } tmp = tmp->next; input++; } printf("NULL\n"); //Insert into list printf("Which node would you like to insert before: "); scanf("%d", &input); tmp = list; for( seeker = 0; seeker < (input-1); seeker++ ) tmp = tmp->next; if( input==0) { printf("Enter value for new node:"); scanf("%d", &input); tmp2 = (Node*)malloc(sizeof(Node)); tmp2->value = input; tmp2->next = NULL; tmp2->next = tmp; list = tmp2; } else { printf("Enter a value to insert: "); scanf("%d", &input); tmp2 = (Node*)malloc(sizeof(Node)); tmp2->value = input; tmp2->next = tmp->next; tmp->next = tmp2; } tmp = list; input = 0; while( tmp != NULL ) { printf("[%d] %d\n", input, tmp->value); tmp = tmp->next; input++; } return(0); } ====SEP 12, 2013==== TURTLE DAY!!!! _ .-./*) _/___/ `. U U 'You can change your file permissions with 'chmod'.' REMOVE NODE, NOT DELETING BUT JUST MAGIC!!! tmp=list; input<-node # to remove; for(seeker=0; seeker<(input-1); seeker++); { tmp=tmp->next; } tmp2=tmp->next; tmp->next=tmp2->next; tmp2->next=NULL; [ display list ] ====SEP 19, 2013==== TURTLE DAY!!!! _ .-./*) _/___/ `. U U 'You can check the current directory by typing 'pwd'.' ====SEP 26, 2013==== _ .-./*) _/___/ `. U U 'You can copy files with the 'cp' command.' WHA WHOOOOOOOOOOO!!!! First day being back from kid being sick... OMG FREEDOM!!! ====OCT 2, 2013==== WORKING ON ASSESSMENT ====OCT 3, 2013==== WORKING ON ASSESSMENT ====OCT 4, 2013==== WORKING ON ASSESSMENT ====OCT 9, 2013==== STACKS!!!!!!!!!!!!!! Main Operations pop() - takes the top item off the stack push() - puts an item on the top of the stack peek() - shows us the top of the stack Pointers top - pointer always located at top of stack mkstack() - creates new stack stack.h #ifndef _STACK_H #define _STACK_H #include "dll.h" struct stack { List *data; Node *top; int size; }; typedef struct stack Stack; Node *pop(Stack*); Node *push(Stack*, Node*); Stack *mkstack(int); Node *peek(Stack*); #endif stactops.c #include "stack.h" Stack *mkstck(int size) { Stack *myStack; myStack=(Stack*)malloc(sizeof(Stack)); myStack->size=size; myStack->data=mklist(); myStack->top=myStack->data->end; return(myStack); } push.c #include "stack.h" void push ( Stack **myStack, Node *newNode ) { if((*myStack)->size<(*myStack->qty)) { (*myStack)->data=append((*myStack)->data,(*myStack)->data->end, newNode); (*myStack)->top=(*myStack)->data->end: } } ====OCT 10, 2013==== TURTLE DAY!!!! _ .-./*) _/___/ `. U U 'You can use 'ncal' to look up the date of easter.' lab46:/var/public/data/fall2013$ POP!!!!!!! pop.c include "stack.h" Node *pop(Stack **myStack) { Node *tmp; if ((*myStack)!=NULL) { tmp=getNode(&(*myStack)->data, (*myStack)->data->end); (*myStack)->top=(*myStack)->data->end; } return(tmp); } #include "stack.h" Stack * push(Stack *myStack, Node *newNode) { if((*myStack->size <= 0) || (myStack->data->qty < myStack->size)) { (*myStack)->data = append((*myStack)->data, (*myStack)->data->e$ (*myStack)->top = (*myStack)->data->end; } return(myStack); ====OCT 11, 2013==== main.c #include #include "stack.h" int main() { Node *tmp; Stack *myStack(0); myStack=mkstack(0); tmp=create(); tmp->value=fgetc(stdin); fgetc(stdin); while(tmp->value !='\n') { myStack=push(myStack, tmp); tmp=create(); tmp->value=fgetc(stdin); fgetc(stdin); } printf("Linked list has %d nodes\n", myStack->data->qty); printf("String is: "); do { tmp=pop(&myStack); if(tmp !=NULL) { printf("%c", tmp->value); } } while (tmp !=NULL); printf("\n"); return(0); } ====OCT 16, 2013==== Work day, work day, every one loves a work day, a work day, a workday..... clear node command.... Node *clear(Node *list) { Node *tmp = list; Node *tmp2; int count; while(tmp!=NULL) { tmp=tmp->next; count++; } tmp=list; for(; count>0 ; count--) { tmp2=tmp->next; tmp->next=NULL; free(tmp); tmp=tmp2; } return(NULL); } ====OCT 17, 2013==== TURTLE DAY!!!! _ .-./*) _/___/ `. U U 'You can look up the manual page for a command by typing 'man command'.' on a Lab46 terminal: cd /var/public/data/fall2013/Linkedlistimp To copy into your ~/src/data/directory: make copy ... or copy it manually to your destination of choice Make help.... lab46:~/src/data$ make help ****************[ Data Structures List Implementation ]***************** ** make - build everything ** ** make debug - build everything with debug symbols ** ** ** ** make testing - build unit tests ** ** make testing-debug - build unit tests with debugging symbols ** ** make libs - build all supporting libraries ** ** make libs-debug - build all libraries with debug symbols ** ** ** ** make clean - clean; remove all objects/compiled code ** ** make help - this information ** ************************************************************************ lab46:~/src/data$ make debug make[1]: Entering directory `/home/cgaines/src/data/src' make[2]: Entering directory `/home/cgaines/src/data/src/list' ar rcs ../../lib/liblist.a make[2]: Leaving directory `/home/cgaines/src/data/src/list' make[2]: Entering directory `/home/cgaines/src/data/src/node' gcc -Wall -I ../../inc -DDEBUG -g -c cp.c gcc -Wall -I ../../inc -DDEBUG -g -c mk.c gcc -Wall -I ../../inc -DDEBUG -g -c rm.c ar rcs ../../lib/libnode.a cp.o mk.o rm.o make[2]: Leaving directory `/home/cgaines/src/data/src/node' make[2]: Entering directory `/home/cgaines/src/data/src/stack' gcc -Wall -I ../../inc -DDEBUG -g -c peek.c peek.c: In function 'peek': peek.c:6: warning: control reaches end of non-void function gcc -Wall -I ../../inc -DDEBUG -g -c pop.c gcc -Wall -I ../../inc -DDEBUG -g -c push.c gcc -Wall -I ../../inc -DDEBUG -g -c stackops.c ar rcs ../../lib/libstack.a peek.o pop.o push.o stackops.o make[2]: Leaving directory `/home/cgaines/src/data/src/stack' make[1]: Leaving directory `/home/cgaines/src/data/src' ====OCT 18, 2013==== __Queue__ - a very British line... - sometimes known as buffer enqueue - you enter the back of the line dequeue - you emerge from the front of the line __Stack__ FIFO - first in first out LILO - last in last out Queue *mkqueue(bufsize) Queue *enqueue(Queue *, Node *) <- Node *dequeue(Queue **); struct queue { List *data; Node *front; Node *back; int bufsize; }; typedef struct queue Queue; lab46:/var/public/data/fall2013$ lab46:/var/public/data/fall2013/Linkedlistimp ====OCT 30, 2013==== Binary Tree (is not really a family tree because a family tree can have more then two) vvvvvv vvvvv vvvv vvv vv v o - root one parent - two children, then children having children... so on and so forth. (family tree of nodes) * pre-order traversal (polish notation) - [[http://upload.wikimedia.org/wikipedia/commons/d/d4/Sorted_binary_tree_preorder.svg]] * in-order traversal -[[ http://upload.wikimedia.org/wikipedia/commons/7/77/Sorted_binary_tree_inorder.svg]] * post-order traversal (reverse polish notation(RPN)) - [[http://upload.wikimedia.org/wikipedia/commons/9/9d/Sorted_binary_tree_postorder.svg ]] BUILD A BINARY TREE PROGRAM!!!! ====OCT 31, 2013==== {{:opus:fall2013:cgaines:happy-halloween.gif?200|}} {{ :opus:fall2013:cgaines:6a00d8341bfadb53ef00e54f76f4638833-640wi.jpg?300 |}} _ .-./*) _/___/ `. U U 'You can check your main by using 'alpine'.' ====NOV 7, 2013==== _ .-./*) _/___/ `. U U 'You can compile a C program with 'gcc'.' WORKDAY!!!! ====NOV 13, 2013==== It is another work day!!!!! MWAHAHAHAHAHAHAHAHAHAHAHAHA! {{ :opus:fall2013:cgaines:index.jpg?300 |}} ====NOV 14, 2013==== TURTLE DAY!!!! _ .-./*) _/___/ `. U U 'You can view the standard MOTD by typing 'motd'.' ====NOV 15, 2013==== "LET'S GET READY TO RUMBLEEEEEEEEEEEEEEEEEEEEEEEEEEEEEEEEEEEEEEEEEEEE!!!!!" {{ :opus:fall2013:cgaines:871646.jpg?300 |}} __Preview to EoCE__ lab46:/var/public/data/fall2013/EoCE/ll_oop_reimp$ ls Makefile inc lib src testing lab46:/var/public/data/fall2013/EoCE/ll_oop_reimp$ cd inc lab46:/var/public/data/fall2013/EoCE/ll_oop_reimp/inc$ ls list.h node.h queue.h stack.h lab46:/var/public/data/fall2013/EoCE/ll_oop_reimp/inc$ cd /var/public/data/fall2013/EoCE/ll_oop_reimp/ lab46:/var/public/data/fall2013/EoCE/ll_oop_reimp$ cd lib lab46:/var/public/data/fall2013/EoCE/ll_oop_reimp/lib$ ls lab46:/var/public/data/fall2013/EoCE/ll_oop_reimp/lib$ cd /var/public/data/fall2013/EoCE/ll_oop_reimp/ lab46:/var/public/data/fall2013/EoCE/ll_oop_reimp$ ls Makefile inc lib src testing lab46:/var/public/data/fall2013/EoCE/ll_oop_reimp$ cd src lab46:/var/public/data/fall2013/EoCE/ll_oop_reimp/src$ ls Makefile btree list node queue stack lab46:/var/public/data/fall2013/EoCE/ll_oop_reimp/src$ cd /var/public/data/fall2013/EoCE/ll_oop_reimp/ lab46:/var/public/data/fall2013/EoCE/ll_oop_reimp$ cd testing lab46:/var/public/data/fall2013/EoCE/ll_oop_reimp/testing$ ls Makefile stacktest.cc lab46:/var/public/data/fall2013/EoCE/ll_oop_reimp/testing$ __stacktest.cc__ #include #include "stack.h" int main() { Node *tmp = new Node; Stack *myStack = new Stack(0); tmp -> setValue(fgetc(stdin)); fgetc(stdin); while(tmp->getValue() != '\n') { myStack -> push(tmp); tmp = new Node(fgetc(stdin)); fgetc(stdin); } fprintf(stdout, "linked list has %d nodes\n", myStack -> getListSize()); fprintf(stdout, "String is: "); tmp = myStack -> pop(); while (tmp != NULL) { fprintf(stdout, "%c", tmp -> getValue()); delete tmp; tmp = myStack -> pop(); } while(tmp != NULL); fprintf(stdout, "\n"); return(0); } ====NOV 21, 2013==== _ .-./*) _/___/ `. U U 'You can check your group affiliations by typing 'group'.' Some of my book collection that will be saving me from destruction. But not self destruction. {{ :opus:fall2013:cgaines:books.jpg?300 |}} GNU nano 2.2.4 File: linkedlist_2.c #include #include struct node{ int value; struct node *next; }; typedef struct node Node; int main() { int input = 0; int seeker; Node *list, *tmp, *tmp2; list = tmp = tmp2 = NULL; while( input != -1 ) { printf("Enter a value (-1 to end): "); scanf("%d", &input); if( input != -1) { if( list == NULL ) { list = tmp = (Node*)malloc(sizeof(Node)); tmp->next = NULL; list->value = input; } else { tmp->next = (Node*)malloc(sizeof(Node)); tmp->next->next = NULL; tmp->next->value = input; tmp = tmp->next; } } } tmp = list; input = 0; while( tmp != NULL ) { printf("[%d] %d\n", input, tmp->value); tmp = tmp->next; input++; } printf("NULL\n"); //Insert into list printf("Which node would you like to insert before: "); scanf("%d", &input); tmp = list; for( seeker = 0; seeker < (input-1); seeker++ ) tmp = tmp->next; if( input==0) { printf("Enter value for new node:"); scanf("%d", &input); tmp2 = (Node*)malloc(sizeof(Node)); tmp2->value = input; tmp2->next = NULL; tmp2->next = tmp; list = tmp2; } else { printf("Enter a value to insert: "); scanf("%d", &input); tmp2 = (Node*)malloc(sizeof(Node)); tmp2->value = input; tmp2->next = tmp->next; tmp->next = tmp2; } tmp = list; input = 0; while( tmp != NULL ) { printf("[%d] %d\n", input, tmp->value); tmp = tmp->next; input++; } return(0); } ======Data Communications Journal====== ====AUG 28, 2013==== RASPBERRY PI!!!!! ====AUG 29, 2013==== Trying to learn more about this Pi. Raspberry Pi YouTube videos and tutorials by Tim Rogers. [[https://www.youtube.com/playlist?list=PL1747FFF819ED0F28]] ====AUG 30, 2013==== Learning Raspberry Pi history... [[http://www.raspberrypi.org/about]] Thinking about children and their use of technology. ====SEP 4,2013==== {{ :opus:fall2013:cgaines:gpios.png?300 |}} ====OCT 2, 2013==== Got project 1 completed with two fellow class mates Create a GPIO file access: echo 11 > /sys/class/gpio/export Configure the Pin Direction (In/Out): echo out > /sys/class/gpio/gpio11/direction Write a value to turn on the LED using the GPIO11: echo 1 > /sys/class/gpio/gpio11/value Now your led should be ON!!! Write a value to clear the LED using the GPIO11 echo 0 > /sys/class/gpio/gpio11/value Now your led should be OFF!!! Delete the created GPIO (11) echo 11 > /sys/class/gpio/unexport You are able to access to GPIO using python or any programming language. We wrote a python script to show how. Download Open a new terminal and execute the script wget https://sites.google.com/site/semilleroadt/raspberry-pi-tutorials/gpio/ADT_blink.py python ADT_blink ====OCT 11, 2013==== Redone in C.... #include "rpi.h" int main() { if(map_peripheral(&gpio) == -1) { printf("Failed to map the physical GPIO registers into the virtual memory space.\n"); return -1; } // Define pin 7 as output INP_GPIO(7); OUT_GPIO(7); while(1) { // Toggle pin 7 (blink a led!) GPIO_SET = 1 << 7; sleep(1); GPIO_CLR = 1 << 7; sleep(1); } return 0; } ======HPC Experience I Journal====== ====AUG 28, 2013==== Project ideas..... Organize shelves and move them. fix docking stations. ====AUG 29, 2013==== Organize shelves, look for containers, verify prices with affordability. ====SEP 26, 2013==== Working on patterns for Velcro-ing the Docking Station to lab tables. Looking at plastic containers for storage of cables and computer parts. ====OCT 4, 2013==== Bought some plastic containers for storage. Working on organization and bundling cords. Walmart still does not have the Velcro I need to properly mount the docking stations to the desks. Will continue to organize and obtain more plastic containers. ====OCT 10, 2013==== Placed Velcro on the bottom of most of the plugable docking stations on the tables. STATION TWO is tied down at the moment. One broken plugable on STATION TWO that needs to be fixed. STATION THREE has been all done. {{:opus:fall2013:cgaines:1378345_10151789138222670_539757379_n.jpg?300|}} {{:opus:fall2013:cgaines:1385054_10151789138227670_264554970_n.jpg?300|}} ====OCT 16, 2013==== Cables are all wrapped up and a new empty box. {{ :opus:fall2013:cgaines:1379576_10151799953272670_1900233585_n.jpg?300 |}} {{ :opus:fall2013:cgaines:1394792_10151799953277670_595451228_n.jpg?300 |}} More cables and boxes to go through. ====NOV 22, 2013==== Half way complete, more of a couple semesters kinda work. {{ :opus:fall2013:cgaines:storage.jpg?300 |}} ====DEC 4, 2013==== Newest Project idea. Lady I work for broke my man's laptop. Never fixed a laptop screen, so going to try fixing that, and turn it into a childrens' play laptop, of script games. Give me something to do during the winter so I don't lose my mind constantly cleaning. {{ :opus:fall2013:cgaines:computer.jpg?300 |}}