User Tools

Site Tools


blog:fall2015:bboynton:journal

Table of Contents

Week One

the First week of class was interesting. No computers and one small white board. My C is very rusted. I am planning on starting the projects as soon as I can instead of putting them off till the last couple of days before the dead line. I also need to play around with lab46 again since I forgot most of it. I kind of understand the nodes and how to add new ones to the list with the tmps and next. Hopefully I do not forget before we get to them.

Week Three

For the third week of class we looked at the debugger tool for the gcc compiler. This tool will be very valuable to us in are attempts to code programs for data structures. We went over some of the basic options the debugger offers like list that displays the program in blocks, the command display which we can use to check variable at certain spots, step which runs the next line of the program, break which is used to set break points for the program to stop at like a certain line, and next which lets use run past functions that we are not interested in like scanf or printf. The debugger we can use to find run time errors or find why we are getting a segment fault which is a common run time error that I get when trying to use pointers and arrays mainly from simple mistakes that I have a hard time finding since I assume that the problem is larger than a simple mistake. The debugger will make finding this easier especially when we get to larger programs and looking at it line by line in nano or vim will take too long to find the problem. We also looked at the at the next project. This is getting into the data structures that we will be using but the project involves only pseudo code and pictures to help use grasp and understand things like a link list that we will be using in the future in C. The first project was also due on the 9th. That project helped me remember the syntax as my code was full of syntax errors that keep me from running the program or logic errors that I got with my if statements as I only used one = instead of the == that I need to check if it was equal to a certain value so it ran every if statement every time. I still have to get use to coding in C again and need to figure out how to get pictures of my drawings for the project due for week 4 from my phone to my lab46 so they can be submitted with my pseudo code. I think I can email it to my lab46 but I do not know how to get it from there to my src folder. I also believe that I can clone a repo from bit bucket to my lab46.

Week Four

For the fourth week of class week looked at projects. Both the one due the week before and the one due the next week (sln1). For the project dsi0 we looked different ways that people did the project and other ways of doing this. I was glad that my approach while not being the most effective or easiest was also not the most insane way of approaching the project. I understand that I am not as bad as I thought but also that I still have room to improve my coding skills and hope to do so over the course of this course. Along with looking at the last project on tuesday we looked at the sln1 project. We started by grabbing a copy of the project that contained all the files we needed for the project like the test and libraries along with the Makefile. We spent a lot of the time looking at the Makefile and what it does. There are multiple ways to use the make command that compiles the code we wrote along with everything else which I am very glad we have because compiling multiple files together is still confusing to me and I am sure I would make a mistake and overwrite my source file. We can make clean which gets rid of all the already compiled code so we can do a fresh start to make sure there is no problems. We can also make save which will back up our source code. Make submit which will submit the project for us (replacing the submit line). The makefile will help me with the creation saving and submitting of the source code for this project which is kind of some of the most important things. We also talked about some basic stuff for adding in a node to a singly linked list. On wednesday we looked at more of the sln1 project. This time we looked more into the project itself. We looked at the src folder in the project folder which is where the bulk of our coding is going to be done. We looked at the test that we have in the project folder that compile with our code so we can check if the code does what it is suppose to do which I am really glad to have for troubleshooting purposes. We also looked at the function malloc and how we will be using it. I normally mess up when using this function as I have only used it with pointers and pointers are not my strong suit. I have been reading up on pointers and watching videos to help explain it better but I am still having trouble. Since the ideas in this projected are linked to sln0 which I felt good about while doing it I feel like this project is going to easier to grasp then some of the other projects from C/C++. I was able to complete sln0 well before the deadline but I might be pushing the deadline for sln1 due to putting off starting which I need to stop and hope to start week 5s project on that Thursday after my sln1 is turned in.

Week Five

For the fifth week of class we focused mainly on the projects due that week and the one due the next week. On the 22nd we updated are sln1 project which included changes to the makefile to get rid of some bugs and improve the code. Applying the update was easy and took no time at all. Also we talked about using make clean after an update to make sure that the code we wrote still works and we were not getting false positives on the test programs. We also went over stuff about copying a node and having the copy’s after pointer to the same node so:

(2)→(4)tmp→(9)→NULL

tmp2=cpnode(tmp)

(4)tmp2→(9)

From there we can change the after to point to something else like the 2 so we can copy and insert a node from a list then back into the list. We also talked about NULL and how we should make sure to set things to NULL because we can check if something is set to NULL. Because it can be checked we can use it for troubleshooting and debugging purposes.

We got the next project sll0 which we could only get after we completed the code for the sln1 since the code in sll0 depends on our code we wrote for mk.c cp.c and rm.c. We also have the option to use the code we wrote or the already compiled code that Matt wrote for it.

The project sll0 is a little confusing to me with how everything works. I understand that “my list” contains all the nodes but putting the nodes into my list is where I am confused. I know that first points to the first node and last points to the one that points to a NULL so we have a start and a end point for the list with just quick reference. I get warnings when I try to make a node at first but the code still works. By works I mean it passes the test so I hope it is not a false positive.

On thursday I found out that other of the students had the a similar problem as I did. While they had a zero at the beginning of their list mine would drop the value from the last list and replace it with a zero. I was able to stop this from happening by removing my rmnode function call from the call. Matt said to someone else that their was caused by a memory leak but I do not know if mine was the same thing. I do not know why the rmnode function would cause a problem since it sets thing to NULL and not zero which are not the same thing.

Thursday was a work in class day so we did not go over anything new. We did go over some cases that we should check for in our code which are:

case 1: a NULL list ex:mylist=NULL;

case 2: empty list ex:mylist[first→NULL/last→NULL]

case 3: list of one ex: mylist[first→(1)/last=NULL]

case 4: list of more than 1 ex: mylist[first→(1)→(2)→(3)→NULL←last]

I did not get very much done during the class. I ended up helping a classmate make improvements to his sln1 so his node-display2.c would work better even though he already submitted sln1 the night before. It was good practice for reading code that is not mine and understanding what is going on and troubleshooting it. He was having a problem with a zero appearing at the start of his list. After playing around for a bit got it to stop giving us the 0 but instead gave us two of the first node. It turned just to be his order for his inputs and his assigning of the input to a node’s info was weird. He was assigning an input into a node before he got the input from the user. simple stuff that took a while. I still need practice troubleshooting and I am not very good with the debugger.

Week Six

Week six of data structures was not full of new stuff. Did look at some grade stuff though. Matt has made a “status” command for use. This command can allow us to see the grades we got on our projects. Along with grades we can see if we have an opus entry for each week also what days we missed if any. This was on tuesday along with review for sln1 mainly the copy node function. We talked about setting our tmps to NULL when we declare them. We also talked about checking for NULL empty or normal list before we continue on with the rest of the code. This prevents problems we could run into like segment faults. After we finished talking about sln1 we looked at sll1. Sll1 had five parts append display backwards search copy and compare. Compare looks to be the hardest of the functions to write. This may just be that we have hexadecimal numbers we have to deal with and i'm not comfortable with hexadecimal numbers in C.

On Thursday we went over something called metrics. This is a graph Matt made based on when the class worked on the projects and for how long we work on it for. It is interesting to see and I am sure I will check it out every week. After we looked at the first metrics we decided to do a work day again. I was able to get all the way through display backwards with no problems. After that I was able to get most of search done. I figured out it had to do with an infinite loop that caused a segment fault. For copy I I also ran into a problem for segment fault. This was because I forgot to check for a NULL list when I started. I checked for an empty list first with myList→first!=NULL and since myList had no first in it, it would seg fault this was fixed by putting an if statement with myList==NULL then a else if for myList→first!=NULL. All my other problems had to do with typing myList→after instead of myList→first or last, or mylist instead of myList. So most of the time it had to do with my own spelling mistakes or misuse of words in the code that caused my problems not that I do not understand the function. I am grasping the concept for linked list and nodes and I am having a good time coding these projects. My work load is starting to fall into a schedule so I hope to get the projects done sooner than the due date.

Week Seven

This is the weeks before break and during break week.

projects due: sll2, sll3, sll4

10/6/15

on Tuesday before break we talked about sll2. We went over the assignment and the functions we had to write. There were obtain clear remove swap and sort. Clear uses the remove node function to make a populated list into an empty list. remove list uses clear to an empty list then makes a NULL list. So it just remove just a larger scale version of remove node. Obtain is just taking a certain node out of a list and reconnect the list. This will be used in swap and sort to make it easier. Swap just switches two nodes in a list which can be used in sort since it has to take the nodes and move them after we obtain the nodes we are switching we just have to reconnect them which is very easy with just a few tmps. Calling swap in the sort function will allow us to move nodes around without having to reconnect them manually each time. Along with talking about the project we also talked more about empty and NULL list. Along with that came with talking about having things like mylist=NULL and mylist2=mylist so meaning that mylist2=NULL. But if we do mylist=mklist() and mylist2=mylist we have mylist2 pointing to the same empty list that mylist is pointing to. We also talked about double node pointers we have to do (*tmp) to use it for after or info. So it stands that for triple pointers it would be (**tmp).

10/8/15

We started talking about projects sll2 and sll4 which are due 2 weeks after break. Sll3 is a smaller project. It just has use put a qty to insert, append,obtain, and mklist. Now sll4 is very interesting. We are moving from looking at a list as a bunch of nodes and are now looking at lists of list or groups. We are adding another level to the programs. I do not think we will go pass making groups of list and manipulating them. For sll4 we have to write a make group, remove group, list append, list obtain,list display,list get pos and list set pos. Now this I am guessing are very similar to the ones we use for nodes and the lists but now the list are the nodes. Now we have list pointers for after. I have not spent much time working on these as I was focus on sll2 and getting my ideas about those functions but I am very excited to try these.

I wish i could say I worked on the projects all week over break but sadly I did not. I spent sometime doing some work on paper and bouncing ideas around but could not find time to sit down at my computer and type up some real C code for them. I have a pretty good idea about how these functions work. Im sure I can get them done before the due date.

Week Eight

Week eight was not filled with a lot of new skill learning or learning new forms of list.

sll2 recap: Working through sll2 which I thought was going to be easy turned into problem after problem sort and swap were where most of the problems happened. I am not sure if it was my logic that was causing things to break but I had segment faults occurring in my other programs like insert or copy list. The insert was due to the fact that in swap node it would swap nodes that were right next to each other but since the nodes were obtained then inserted at at a tmp that was not in the list anymore. Copy list I am still a little confused why it was segfaulting. I was able to get all but sort list to pass all the unit test. I will be working on trying to get the copy list working the way it should when I find the time.

10/20/15

Tuesday we looked at some drawings to help understand the obtain. Basically all it is, is the setting of a nodes after to tmp then linking the list so the node we want is no longer any other node’s after. This is really easy to understand in picture form and I am glad that we can draw them.

After it was a work on in class day. This gave me time to work and finding all the conditions I had to look for when calling obtain and get some basic structure for the logic in place.

Swap list took a little more work doing. I had to check for: Either being first or last both of them being first and last (ie item1=first item2=last/item2=first item1=last) if they were next to each other(reason why insert was seg faulting / had to be checked in each other check)

if they were not at the first or last

Sll3 and sll4 are due on at the end of the 28th. I have been trying to get sll3 done but am getting trouble with qty only returning 0. I have not had to the time to spend a lot of time looking as why but hopefully I will find it soon. I think it has something to do with how I am using the qty in the functions. Hopefully it will be easy to find cause staying up all night coding leads to a lot mistakes that takes a long time to correct.

Week Nine

This week marked the end for the singly linked list and the start of the doubly linked list and nodes. We started class on tuesday by talking about the doubly linked list. The code for them seems very straightforward. The biggest difference was the prior pointer that the nodes now have. With this new pointer we have to make sure we set it to the correct place otherwise the list would not be right. Also this removes a need for a get pos and set pos function as we just have to reference the after and prior pointers to do things like append and insert. One of the biggest problems I am going to face is the use of return codes instead of a list pointer. Setting up the checking statements for each condition will take some time and planning. After those it will be very similar to the code for the old singly linked lists. For thursday we worked on so code for the doubly linked list. We found we can do things like nodes prior after = newnode and that would insert a new node at the current nodes spot without having to set tmps everywhere. After we looked at code and drawings we had a worki in class day. I was able to get most of the checking statements set up for make during that time. I had to put off working on it over the weekend due to some test I had to study for and hopefully it goes smoothly and I meet the deadline.

Sll4 caused some big problems for me. I had trouble with the insert append and obtain. I am still lost in why I was getting these problems. I think it has something to do with my code from before was broken. I could not really figure it. I am excited to start over for these new projects and getting to make better code instead of the mess I had before.

Week Ten

We started working with doubly linked list and nodes. I am feeling very good about these. The big difference is the prior pointer each nodes have. dll0 turned out very well. I only had problems with time and find. Find did what it was suppose to do but I had trouble finding how to make it keep its spot in the list for a resume function. I was able to get dln0 working completely with few problems. The biggest problem I have is the return statements. I am not sure why but it does not sit well with me. I am able to work through them it just takes alittle bit of work. Tuesday we talked about dll1. This is just making more list functions for doubly linked list. Thursday was a work on stuff day. I was able to get most of the obtain done in that time. So far since then I was able to get obtain 100 percent empty 100 percent and remove 100%. I think I have compare almost completely. The only problem I am facing is setting deference is to a value. I am sure this is a very simple problem to fix but I am just over looking. I am not looking forward to sort as I was not able to complete that one before on the singly list projects. I feel like this time might be different as my main problem before was with other code that I wrote for other functions breaking and seg faulting. Fallout 4 is coming in an hour so hopefully my grades do not drop. Fallout hype.

Week 11

Coding has been going well for the most part. Not finishing display before is coming back to haunt me as I have to code it again with new functions. The idea of printing out ascii characters instead of the number values seems like it would be easy to but in. Have a if statement for forward and backwards/with or without spacing then a if for ascii or number values. No problem. Putting qty into the old code gave me some trouble as I forgot that it is →qty=*number* and not just qty=*number*. This took me way longer to figure out then I would like. Always for getting the same things. I feel like I am doing solid work on these projects as far as the list and nodes are concerned. We are started to work on stacks now along with the list and nodes. I am scared of these as the are confusing. I think a stack is a similar to a list but we can only access it in a backwards order. I have not really had a good look at the functions that use the stacks but I am pretty sure that we can use list functions on them. Obtain insert and append all went very well for the doubly linked list. It went a lot smother then the singly list versions. This mainly do to the fact that they are like the same code. This time the I just had to worry about the priors pointing in the right place. I also ran into a slight problem with my code in that the unit test would give the functions the wrong list and then compare it to a result that was based on the right list. I do not know if this is because of my old code I did not finish.

Week 12

Data structures has been going well. I am quite surprised at how well really. The last couple of projects have been iffy. I think mainly because I did not give myself enough time to really work out the code step by step. I feel like my code could be a lot shorter but I understand the basics of each. Since we are nearing the end of the semester we have not really covered new topics in class. We talked about queues which I got really easy once I understood that the list was already there so I did not need to create the list each time just simply give it a pointer name. I was even able to get it done early since the due date was moved till after break. Speaking of break I wish I could say that I coded the whole time and finished the next project. I really wish I could but I can not. So hopefully I can start and finish it before the this Thursday. I feel pretty good about stacks. My understand is that it is like a opposite to queues. So instead of changing the last of the under laying list we are looking at the first then we want to add things we have to append them at the last of list and when we grab we grab from the start of the list.

blog/fall2015/bboynton/journal.txt · Last modified: 2015/12/01 04:46 by bboynton