• Congratulations to the Class of 2024 on your results!
    Let us know how you went here
    Got a question about your uni preferences? Ask us here

comp115/155 assignment 4 (1 Viewer)

...

^___^
Joined
May 21, 2003
Messages
7,723
Location
somewhere inside E6A
Gender
Male
HSC
1998
ok, last one was tough
but this one is a big wtf..

i mean, those weird terms are tough enough already, let alone using such an example to illustrate what they really meant..

i think this thread will grow exponetially as the due day approaches
 

hibs19

New Member
Joined
Feb 24, 2004
Messages
6
hi guys!!
i'm not sure about u guys but personally i hate comp!! i don't understand anything seriously:confused:!! this 4th assignment is heaps hard !! i have a frined in second yr and she said this is hard for 1st yr students!! wat is up with them and hard assignments!! if ANYONE has any advice or help in reagrds to how we can solve this crap assignment PLEASE PLEASE post it up here so we can all see it and figure out this last and finally crap comp assignment !! then we can all pass and transfer !! wohoooooo!!
any way please help someone!! :D
 

doe

Member
Joined
Jan 23, 2004
Messages
751
Gender
Undisclosed
HSC
N/A
hi guys

im happy to help but its easier for me if you give me a url to the assignment/question.

for this one, just be patient and read the question a few times untill you fully understand what its saying. none of the questions are that hard once you realise what you need to do. if your doing a comp degree, get used to these confusing specs, if you dont understand what is required, mail your lecturer. i usually send a few mails to my lecturer for each assignment, just to make sure i understand things correctly. as longs as you ask nicely and dont say stupid shit they will respond.

the four questions all can be solved in a similar way. the way you want to do them is in your function create an array that will store you results. For eg say we have an array of 10 integers, and we want to find the sum of all the integers in the array, excluding the item at the current position in the array.

<pre>
#include &lt;iostream&gt;

void
jiggy(int F, int L, int arr[])
{
int i, j, results[L];

for (i = F; i < L; i++) { //for every element in the input array
results = 0; //set initial sum to 0
for (j = F; j < L; j++) { //sum up all the other elements

if (j == i)
continue; //skip this element

results = results + arr[j];
}
}


for (i = F; i < L; i++)
cout << "skipping element " << i << ": " << results << endl;
}

int
main(void)
{
int i, arr[10];

for (i = 0; i < 10; i++)
arr = i;

jiggy(0, 10, arr);

return(0);
}
</pre>
 

doe

Member
Joined
Jan 23, 2004
Messages
751
Gender
Undisclosed
HSC
N/A
the general idea of answering the assignment questions

take the first one (inversions)

in jiggy(), results would be the number of items in arr[] that are greater than arr and come before it .. ie arr[F] to arr[i - 1].

then to return a value you just sum up the values in results[F] to results[L] and return that
 
Last edited:

hibs19

New Member
Joined
Feb 24, 2004
Messages
6
help

Hi..
doe u seem to know what ur doing and thats very very very nice of u for helping us!! however i'm still really confused and i don't understand wat an inversion does?? does anyone else feel confused?? how much have u guys done from this assignment!!
i hope u can help us some more thanx!!
 

redruM

Breathe and Stop
Joined
May 11, 2004
Messages
3,954
Gender
Male
HSC
2003
i couldnt explain inversion if i tried.

the wording of the question is pretty terrible.
 

doe

Member
Joined
Jan 23, 2004
Messages
751
Gender
Undisclosed
HSC
N/A
"The number of inversions for an element x in a list is the number of elements which are strictly greater than x, but come before x in the list. "

you've just got to have a bit of patience, and read over it a few times, and play with some examples. strictly greater than means ">" vs ">=".

say your list was 2 6 4 3 5 5 1

the number of inversions for 2 is 0
the number of inversions for 6 is 0
the number of inversions for 4 is 1
the number of inversions for 3 is 2 (ie 6 & 4, but not 2)
the number of inversions for 5 is 1 (6)
the number of inversions for 5 is 1 (6) - 5 is not strictly greater than 5
the number of inversions for 1 is 0

"The number of inversions in a list is the sum of the number of inversions of the elements in the list."

the number of inversions is: 0 + 0 + 1 + 2 + 1 + 1 + 0 = 5

your tutor is a good person to ask if you dont understand somethign too.
 
Last edited:

toknblackguy

Member
Joined
Nov 1, 2003
Messages
299
Gender
Male
HSC
2003
umm
wouldn't the number if inversions for 1 be all the other numbes before it? cause unless im' wrong...aren't all those numbers > 1??
 

hibs19

New Member
Joined
Feb 24, 2004
Messages
6
thanx.. now for another question!!

thanx for ur help doe..
i think toknblackguy is right about 1 also being included!! and i really understand inversions now so THANX heaps!! but can we get more help in regards to the rest of the assignment!! sorry to sound rude but i really really need to pass comp!! actually we all do !! so we can move on or transfer!! but thanx for everything !! how do we do the pair sum and the subsequence with maximum sum!! please help !! thanx;)
 

doe

Member
Joined
Jan 23, 2004
Messages
751
Gender
Undisclosed
HSC
N/A
hehe yeah, i changed the example to be "more clearer" after i typed it out, which went pretty well heh.

i cant really help you much more, the other questions can be solved in a similar fashion. you just have to work out the logic, which just takes a bit of patience, and maybe playing with an example on paper.

if you get really stuck just email your tutor or the lecturer. your tutor is paid to help you and will probably has consultation hours outside of tutorials where they hang around waiting for someone to come ask them questions. if you dont know who your tutor is, ask your lecturer eg "my tute is at monday at 7am, could you send my me tutors email and consultation time?"
 

toknblackguy

Member
Joined
Nov 1, 2003
Messages
299
Gender
Male
HSC
2003
Originally posted by toknblackguy
umm
wouldn't the number if inversions for 1 be all the other numbes before it? cause unless im' wrong...aren't all those numbers > 1??

i again ask my question: wouldn't the number of inversions for 1 be 6?
 

william

Member
Joined
Sep 3, 2003
Messages
126
Location
Eastwood
Gender
Male
HSC
2004
why didn't the number of inversion for 1 is not 6 but 0?
each one is greater than one and come before one!!
 

doe

Member
Joined
Jan 23, 2004
Messages
751
Gender
Undisclosed
HSC
N/A
Originally posted by doe
hehe yeah, i changed the example to be "more clearer" after i typed it out, which went pretty well heh.

...


yes. it is 6.
 
T

tactic

Guest
you people shouldnt really complain.. doesnt seem to bad compared to the uts dspp assignment 2 haha
 

redruM

Breathe and Stop
Joined
May 11, 2004
Messages
3,954
Gender
Male
HSC
2003
the hardest thing about it is being bothered to start. :(

like seriously, i've been putting it off since start of the week.
 

sukiyaki

emptiness
Joined
Nov 9, 2002
Messages
1,505
Location
westie
Gender
Female
HSC
2003
i havent started :(, can someone tell me what kinda coding to used?
 

Users Who Are Viewing This Thread (Users: 0, Guests: 1)

Top