====== Data Structures Day by Day Class Journal ====== ××××××××××××××××××××××××××××××××××××××××××××××××××××××××××××××××××××××××××××××××××××××××××××××××××××××××××××××××××××××××××××××× === 8/28/13 - Day 1 === Today was the first day of class. Matt went over some syllabus stuff and talked about what we will be doing in the class. **Things we will be reviewing:** - //Pointers// - //Structs// - //Anything else Matt covers// ××××××××××××××××××××××××××××××××××××××××××××××××××××××××××××××××××××××××××××××××××××××××××××××××××××××××××××××××××××××××××××××× ===8/29/13 - Day 2=== **Making an irc bubble:** - command screen - irssi -/server irc To join a specific channel type /join "channel name" (//class channel is csci//) **Irc fun commands:** -//roll:// -//flip:// -//define:// -//weather:// __CTRL-a d to get out of a bubble__ __screen -r to get back into a bubble__ Use //cd src// to get into the main work folder //cd// is used to change directories //mkdir// can be used to create folders open a text file with the text editor and command //nano "filename".c// As review today we wrote a program with pointers to remind ourselves what the heck a pointer does/is. The program is in lab46/src/data and is named pointer1 and pointer2 ××××××××××××××××××××××××××××××××××××××××××××××××××××××××××××××××××××××××××××××××××××××××××××××××××××××××××××××××××××××××××××××× === 8/30/13 - Day 3 === First started out by reiviewing those beautiful things in c that we call datatypes! ^ signs ^ data type ^ size in bytes ^ | signed | char | 1 | | unsigned | char | 1 | | signed | short int | 2 | | unsigned | short int | 2 | | signed | int | 4 | | unsigned | int | 4 | | signed | long int | 8 | | unsigned | long int | 8 | | signed | long long int | 8 | | unsigned | long long int | 8 | | signed | float | | | unsigned | float | | unsigned | double | | | signed | long double | | In class we have worked on a program that finds the sizes and bounds of all the data types. this can be found in the data folder under the name numbers1.c Homework: complete the program worked on in class for the other data types. also: attempt to determine some of the bounds using a logical solution tips: ^ string modifier ^ data type ^ |%d | signed int | |%u | unsigned int | |%hu | half(short)unsigned int | |%hhu | half half(half short goes to char)| |%lu | long | |%llu | long long | |%f | float | |%lf | long float (double) | ^ operators ^ logic ^ |& | bitwise and | |<< left shift | left shift | |>> right shift | right shift | || | bitwise or | |! | not | | ^ | xor | In the homework I found that a long int and a long long int have the same size of 8 bytes. This might be due to the system specifications of lab46. Also, I have found that you cannot use signed or unsigned modifiers on float or double data types. ××××××××××××××××××××××××××××××××××××××××××××××××××××××××××××××××××××××××××××××××××××××××××××××××××××××××××××××××××××××××××××××× === 9/4/13 - Day 4 === Starting class reviweing structs Struct is used to store multiple data types (unlike an array which can only store 1 data type) Exaple prorgram in data folder named struct1.c Use typedef to use your structs faster such as: //typedef struck person Person; //struct person People[8]; //without typedef Person People[8]; //using typedef// ××××××××××××××××××××××××××××××××××××××××××××××××××××××××××××××××××××××××××××××××××××××××××××××××××××××××××××××××××××××××××××××× === 9/5/13 - Day 5 === Today we learned about lists. Lists are useful because they allow us to basically create dynamic arrays. This means that we can make it longer by simply adding another node onto or in our list. We are also able to delete nodes. We worked on an example program exemplifying lists which can be found under the name struct1.c ××××××××××××××××××××××××××××××××××××××××××××××××××××××××××××××××××××××××××××××××××××××××××××××××××××××××××××××××××××××××××××××× === 9/6/13 - Day 6 === Started class checking off our opus, and first project. Then we furthered our knowledge of lists by learning out to insert a node in the middle of our list. This can be seen in the modification made to list1.c ××××××××××××××××××××××××××××××××××××××××××××××××××××××××××××××××××××××××××××××××××××××××××××××××××××××××××××××××××××××××××××××× === 9/11/13 - Day 7 === Today we did more stuff with our singley linked lists. Added functionality to insert nodes. We have to make a special case for when we insert before the first node. The code we used to do this was: //if(input == 0) \\ { \\ printf("Enter a value to insert: \n"); \\ scanf("%d", &input); \\ tmp2=(Node*)malloc(sizeof(Node)); \\ tmp2->value=input; \\ tmp2->next=NULL; \\ tmp2->next=tmp; \\ list=tmp2; \\ } \\ // ××××××××××××××××××××××××××××××××××××××××××××××××××××××××××××××××××××××××××××××××××××××××××××××××××××××××××××××××××××××××××××××× === 9/12/13 - Day 8 === Today we did even more with our singley linked lists. We looked at adding functionality to remove a certain node. We realised when doing this that we must make a case for if you want to remove the first node. ××××××××××××××××××××××××××××××××××××××××××××××××××××××××××××××××××××××××××××××××××××××××××××××××××××××××××××××××××××××××××××××× === 9/13/13 - Day 9 === I was not in class today, however I heard that Matt has started to talk about doubly linked lists. I have been working on my menu for my list program. All of the functionalities we worked on in class were made into actual functions. I made a menu that calls certain functions depending on user imput in main. *PLEASE REMEMBER NEXT TIME TO CHECK FOR ; AFTER FUNCTION PARAMETER! MOST ANNOYING SYNTAX ERROR EVER! m( \\ ××××××××××××××××××××××××××××××××××××××××××××××××××××××××××××××××××××××××××××××××××××××××××××××××××××××××××××××××××××××××××××××× === 9/18/13 - Day 10 === Today has been a work day to finish up our single list stuff. I worked through a few problems with my menu system with Matt such as figuring out how to compare a string with user imput. I was trying to compare //variable to atoi("string")// need to do this: //ifstrcasecmp,(inputvariable, "string")==0// ××××××××××××××××××××××××××××××××××××××××××××××××××××××××××××××××××××××××××××××××××××××××××××××××××××××××××××××××××××××××××××××× === 9/19/13 - Day 11 === Worked on completing my singly linked list today including my append function and clear function. ××××××××××××××××××××××××××××××××××××××××××××××××××××××××××××××××××××××××××××××××××××××××××××××××××××××××××××××××××××××××××××××× === 9/20/13 - Day 12 === Finished my singly linked list program besides the sorting function. I have a good idea of how I will make the sort function but have decided that it will be more beneficial to get a big chunk of the doubly linked list done first. ××××××××××××××××××××××××××××××××××××××××××××××××××××××××××××××××××××××××××××××××××××××××××××××××××××××××××××××××××××××××××××××× === 9/25/13 - Day 13 === I have what should be a working display backwards function made. I will test in the future once I have my program actually functioning void displayb(List *myList) { Node*tmp=myList->start; Node*tmp2=tmp; myList->start->prev=NULL; int input=0; int counter=0; while (tmp -> next != NULL) { tmp2 = tmp; tmp = tmp -> next; tmp->prev=tmp2; counter++; } while (tmp != NULL) { printf("[%d] %d ->", counter, tmp->value); tmp = tmp->prev; counter = counter-1; } printf("NULL\n"); } ××××××××××××××××××××××××××××××××××××××××××××××××××××××××××××××××××××××××××××××××××××××××××××××××××××××××××××××××××××××××××××××× === 9/26/13 - Day 14 === Working more on doubly linked lists. (Mainly the menu). The menu now is fully functional and even keeps track of the number of operations, lists, and commands run. ××××××××××××××××××××××××××××××××××××××××××××××××××××××××××××××××××××××××××××××××××××××××××××××××××××××××××××××××××××××××××××××× === 9/27/13 - Day 15 === ar -rcs libdll.a listops.o display.o gcc -g -o main main.c -ldll -L. gdb ./main ××××××××××××××××××××××××××××××××××××××××××××××××××××××××××××××××××××××××××××××××××××××××××××××××××××××××××××××××××××××××××××××× === 10/2/13 - 10/4/13 === What happened to this week! I noticed it was missing and I have no idea what had happened. So weird! ××××××××××××××××××××××××××××××××××××××××××××××××××××××××××××××××××××××××××××××××××××××××××××××××××××××××××××××××××××××××××××××× === 10/9/13 - Day 19 === __Stacks:__ pop() - takes the top of item off the stack\\ push() - puts an item on the top of the stack\\ peek() - shows us the top of the stack\\ top - pointer always located at top of stack\\ mkstack() - creates new stack __In our list:__ - Add an "int qty;" to your list struct\\ - Update list functions to current list qty\\ - Add a mklist() function List *mklist();\\ ××××××××××××××××××××××××××××××××××××××××××××××××××××××××××××××××××××××××××××××××××××××××××××××××××××××××××××××××××××××××××××××× === 10/10/13 - Day 20 === Running quite behind now. Still have a ton of doubly linked list stuff to do and feeling like I'm starting to get lost a little in the new stuff. Stacks seem to be quite a simple concept, in fact they seem basically like a list with just limiting the functionality but I have not had a chance yet to get to working on it. ××××××××××××××××××××××××××××××××××××××××××××××××××××××××××××××××××××××××××××××××××××××××××××××××××××××××××××××××××××××××××××××× === 10/11/13 - Day 21 === Working on random things today. ××××××××××××××××××××××××××××××××××××××××××××××××××××××××××××××××××××××××××××××××××××××××××××××××××××××××××××××××××××××××××××××× === 10/23/13 - Day 22 === __ Queue's__ -Have both a front and back pointer\\ -Think of as a buffer\\ -enqueue and dequeue\\ -LIFO, FILO, FIFO, LILO\\ -Queue *mkqueue(bufsize)\\ -Queue *enquee(Queue *, Node *)\\ -Node *dequeue(Queue **)\\ -struct queue\\ -{\\ - List *data;\\ - Node *front;\\ - Node *back;\\ - int bufsize;\\ -};\\ -typedef struct queue Queue;\\ ××××××××××××××××××××××××××××××××××××××××××××××××××××××××××××××××××××××××××××××××××××××××××××××××××××××××××××××××××××××××××××××× === 10/24/13 - Day 23 === Today I will hopefully finish the doubly linked list stuff and move to the stacks and queues. I have just finished updating my opus and now it is time to do some major work. Too bad Jason is out of state today :-( Finally finished my doubly linked list program except for the sort function. Took many hours. I learned quite a bit through error correction though, which I will definitely remember for next time. I would start the stacks today; however, it is already closing in on 4pm so I will begin implementing my stack code tomorrow. I'm very happy though that my doubly linked list program is basically done and full functional. ××××××××××××××××××××××××××××××××××××××××××××××××××××××××××××××××××××××××××××××××××××××××××××××××××××××××××××××××××××××××××××××× === 10/25/13 - Day 24 === After talking with Paul, I have realized I need to modify about 2 functions to be able to modify the empty list (doubly linked list program). My original design scheme was to make it so that no operations could be formed on an empty list; however, it seems that Matt wants the operations to be available whenever(except before you have made a list). I have started fixing those and fixing a mini bug I found in the menu gui. ××××××××××××××××××××××××××××××××××××××××××××××××××××××××××××××××××××××××××××××××××××××××××××××××××××××××××××××××××××××××××××××× === 10/30/13 - Day 25 === Today we are learning trees/graphs. Binary trees - each row with have 2^x children/parents with x being the #row ur on. left most value is lowest value while right most is highest start with a value, take next value and if it is lower it becomes left child parent to the previous value or if it is higher it becomes the right child to the previous parent. I want to try to use recursion to make this. I am going to want to make a node create function that goes through an array of values and uses the next value to determine if its the previous value's prev or next depending on if it it is less or greater. It will run through all the values by calling the function within the function. I will need to create a new struct for tree nodes which will contain a value, a prev pointer, and a next pointer.\\ ××××××××××××××××××××××××××××××××××××××××××××××××××××××××××××××××××××××××××××××××××××××××××××××××××××××××××××××××××××××××××××××× === 10/31/13 - Day 26 === Today I completed the tree function and implemented it into my menu. Next I will have to create a display function for the tree. The function I made is this: Tree *treebuild(Tree *myTree,int values[],Node *tmp, int k, int arraycount)\\ { if(k == 0) { myTree=(Tree*)malloc(sizeof(Tree)); myTree->Root=create(values[k]); tmp=myTree->Root; k++; } else { if(values[k] > tmp->value) { if(tmp->next!=NULL) { tmp=tmp->next; } else { tmp->next=create(values[k]); tmp = myTree->Root; k++; } } else if(values[k] < tmp->value) { if(tmp->prev!=NULL) { tmp=tmp->prev; } else { tmp->prev=create(values[k]); tmp = myTree->Root; k++; } } else { k++; } } if(k