<?xml version="1.0"?>
<feed xmlns="http://www.w3.org/2005/Atom" xml:lang="en-GB">
	<id>https://wiki.kram.nz/index.php?action=history&amp;feed=atom&amp;title=SE250%3Alab-4%3Amgha023</id>
	<title>SE250:lab-4:mgha023 - Revision history</title>
	<link rel="self" type="application/atom+xml" href="https://wiki.kram.nz/index.php?action=history&amp;feed=atom&amp;title=SE250%3Alab-4%3Amgha023"/>
	<link rel="alternate" type="text/html" href="https://wiki.kram.nz/index.php?title=SE250:lab-4:mgha023&amp;action=history"/>
	<updated>2026-08-28T04:49:59Z</updated>
	<subtitle>Revision history for this page on the wiki</subtitle>
	<generator>MediaWiki 1.46.0</generator>
	<entry>
		<id>https://wiki.kram.nz/index.php?title=SE250:lab-4:mgha023&amp;diff=6129&amp;oldid=prev</id>
		<title>Mark: 18 revision(s)</title>
		<link rel="alternate" type="text/html" href="https://wiki.kram.nz/index.php?title=SE250:lab-4:mgha023&amp;diff=6129&amp;oldid=prev"/>
		<updated>2008-11-03T05:19:36Z</updated>

		<summary type="html">&lt;p&gt;18 revision(s)&lt;/p&gt;
&lt;p&gt;&lt;b&gt;New page&lt;/b&gt;&lt;/p&gt;&lt;div&gt;Right.So I&amp;#039;d typed up my lab report and I tried embedding an image and the whole thing got deleted for some reason.So here we go again...&lt;br /&gt;
&lt;br /&gt;
At the start of the lab, I was unsure as to what the symbol &amp;#039;-&amp;gt;&amp;#039; did. I guess it was very obvious for everyone else in the lab but I think I&amp;#039;m really weak at 250 and so I didn&amp;#039;t really know what I was doing for a long time.I tired looking for explanations in my lecture notes but I could not figure out what it really did. So I took the help of the tutor and I was told that -&amp;gt; is either referring to a head or tail.&lt;br /&gt;
&lt;br /&gt;
For example, in the case of &amp;#039;list-&amp;gt;head&amp;#039;, it&amp;#039;s referring to the first element in the linked list &amp;#039;box&amp;#039;. On the other hand, &amp;#039;list-&amp;gt;tail&amp;#039; is referring to the element the tail is pointing to.&lt;br /&gt;
&lt;br /&gt;
I tried uploading my diagram but it failed again. I think I&amp;#039;ll try again later.&lt;br /&gt;
&lt;br /&gt;
After understanding what -&amp;gt; did, i tried question one which as quite ok...This was my code:&lt;br /&gt;
&lt;br /&gt;
  int length(Cons* list) {&lt;br /&gt;
 	int index=0;&lt;br /&gt;
 	for ( ; list != nil; list = list-&amp;gt;tail){&lt;br /&gt;
 		index++;&lt;br /&gt;
 	}&lt;br /&gt;
 	printf(&amp;quot;%d\n&amp;quot;, list-&amp;gt;tail);&lt;br /&gt;
 	return index;&lt;br /&gt;
  }&lt;br /&gt;
 &lt;br /&gt;
I tried to Build it but i got an error saying that I had to include a file called &amp;quot;stdafx&amp;quot;. So i tried the following:&lt;br /&gt;
 #include &amp;quot;stdafx.h&amp;quot;&lt;br /&gt;
and then when i tried to build it again, it popped up an error that it could not find any such file. I then asked for the tutors help.We realised that I hadn&amp;#039;t been logged on onto my home directory and that my program was saved in the C:\ which was not what we wanted. We tried locating my home drive but it wasn&amp;#039;t found. So we saved the file on my USB drive and then tried  building the code from there. It then worked and popped up errors from the rest of my program. I&amp;#039;m not too good at writing code in C and I tried revising the lecture notes to see where I was going wrong...&lt;br /&gt;
&lt;br /&gt;
Initially I had:&lt;br /&gt;
&lt;br /&gt;
    int element_t first(Cons* list){&lt;br /&gt;
    	&lt;br /&gt;
   	if (element_t != nil){&lt;br /&gt;
  		printf(&amp;quot;%d\n&amp;quot;, element_t);&lt;br /&gt;
  	}&lt;br /&gt;
  	else return 0;&lt;br /&gt;
    }&lt;br /&gt;
&lt;br /&gt;
which is wrong. I don&amp;#039;t think I had understood the question properly. What I needed was to return the first element of the linked list and this was nto doing that. How I refer to the first element should have been by using list-&amp;gt;head as the tutor had taught me earlier. I tried modifying the code accordingly and this is what I got:&lt;br /&gt;
&lt;br /&gt;
  int element_t first(Cons* list){&lt;br /&gt;
 	&lt;br /&gt;
 	if (list-&amp;gt;head != nil){&lt;br /&gt;
 		printf(&amp;quot;%d\n&amp;quot;, list-&amp;gt;head);&lt;br /&gt;
  	}&lt;br /&gt;
 	else return 0;&lt;br /&gt;
 }&lt;br /&gt;
&lt;br /&gt;
I&amp;#039;m still not sure if this is completely right, but I guess I understand what I&amp;#039;m trying to do, although I&amp;#039;m not sure how to put it down in code (although that&amp;#039;s partly the point!).I also have an error(which is bad) that says:&lt;br /&gt;
Error	1	error C2061: syntax error : identifier &amp;#039;first&amp;#039;. Unfortunately I&amp;#039;m quite terrible at code so I&amp;#039;m unsure of what to do. &lt;br /&gt;
&lt;br /&gt;
The next question was to write a function for element_t second(Cons*). I figured that perhaps this time I was to use &lt;br /&gt;
list-&amp;gt;tail. So this is the code I ended up writing:&lt;br /&gt;
&lt;br /&gt;
 int element_t second(Cons* list){&lt;br /&gt;
 	&lt;br /&gt;
 	if (list-&amp;gt;tail != nil){&lt;br /&gt;
 		printf(&amp;quot;%d\n&amp;quot;, list-&amp;gt;tail);&lt;br /&gt;
 	}&lt;br /&gt;
 	else return 0;&lt;br /&gt;
 }&lt;br /&gt;
&lt;br /&gt;
Again I&amp;#039;m not sure if this is right. I have an error when I build it that says:&lt;br /&gt;
&lt;br /&gt;
Error	1	error C2061: syntax error : identifier &amp;#039;second&amp;#039;	&lt;br /&gt;
&lt;br /&gt;
For the next part,viz.,code to see if they have exactly the smae elements this was my code:&lt;br /&gt;
&lt;br /&gt;
 int equal(Cons *list1, Cons *list2){&lt;br /&gt;
 	true=1;&lt;br /&gt;
 	false=0;&lt;br /&gt;
 	if ((length(Cons *list1)) == (length(Cons *list2))){&lt;br /&gt;
 		return true;&lt;br /&gt;
 	}&lt;br /&gt;
 	else return false;&lt;br /&gt;
 }&lt;br /&gt;
&lt;br /&gt;
Again this is just comparing the lengths and not checking if the elements are the same and in identical order.So, this code is wrong.&lt;br /&gt;
&lt;br /&gt;
I&amp;#039;m really not sure how to put down ideas in code. I get very confused with all the names and symbols that it stops making sense to me. I guess that&amp;#039;s because I&amp;#039;m new to the whole programming thing and never done anything like this before.I&amp;#039;ve seen a pattern in all my labs.For the first 15 mins I don&amp;#039;t have any idea of what I&amp;#039;m doing. I try understanding the question and try to avoid asking for help right in the beginning as I want to see if I can understand it myself. I try many different things in vain. Then inevitably, I ask for help. What I need at the start of every lab is to be started off. Call it &amp;#039;starting trouble&amp;#039;, but if someone tells me where I&amp;#039;m going, I get the point after that. But if I don&amp;#039;t get that initial push, I&amp;#039;m lost throughout the entire lab. This is exactly what happened today. I thought I&amp;#039;d wait and try to figure it out myself and didn&amp;#039;t ask for help initially because I guess we were supposed to know all that was in the lab handout. So since I didn&amp;#039;t reach out for that initial push, I had no clue if what I was doing was right or wrong. By the end of the hour, I was still in the second question, and although I needed help, I hesitated because I felt 1 hour was too long a time to spend on a &amp;#039;simple&amp;#039; question. I perhaps was afraid to ask for help as I was lagging behind.This is where I went wrong. I should have just put up my hand however late it was and admit that I was stuck. I guess I thought that if I asked for help, it would be assumed that I&amp;#039;m not trying hard enough and applying my mind to the problem. But that is not the case. I really try hard to understand and see what the question is asking but somehow, this whole &amp;#039;data structures&amp;#039; topic hasn&amp;#039;t clicked for me. I&amp;#039;m yet to assimilate it all. Yet to absorb it and see where it is heading. This is the reason why I am lost in labs because although I try really hard to come up with something, I have no background knowledge to fall back on to see whether I&amp;#039;m on the right track. In fact, I don&amp;#039;t know what the right track is at all. I usually have no strategy.Because I&amp;#039;m not sure what to do. I need that initial hint to get started.Just a push in the right direction. This is my problem and that is why I haven&amp;#039;t been very efficient in this lab. I guess this is just me, but I find the lectures a little brief and &amp;#039;high level&amp;#039; for me to assimilate. There is no time to chew upon things in the lecture as everyhting is being introduced so quickly.I find them a little too fast. I guess this is because of my lack of previous experience in C. The whole thing is just so new and abstract to me that I find it hard to take away everything that is covered in the lectures and put it to practice in the lab.&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
::* !!!  Ask around for Shrek, David or Hannah during the labs.  We&amp;#039;re cool to help you out.  Are you AP or something?  [[User:ssre005|Shrek]]&lt;br /&gt;
::*  Hey, youre not the only one thats lost, if thats any consolation. :)&lt;br /&gt;
::* hey guys, Medha is a AP student, so obviously this stuff is pretty hard for her since she hasn&amp;#039;t done 131 like us. &lt;br /&gt;
::* Message to medha: We love u :D Dont worry, u&amp;#039;ll be fine. if the lecturer/tutor are not much help in the labs, just ask any of us students :) this is Samar and Archana btw hehe :D&lt;/div&gt;</summary>
		<author><name>Mark</name></author>
	</entry>
</feed>