• YOU can help the next generation of students in the community!
    Share your trial papers and notes on our Notes & Resources page

2007 help (1 Viewer)

crammy90

Member
Joined
Mar 26, 2006
Messages
264
Gender
Male
HSC
2008
its hard for me to check whether i got this right cuz i dont really understand algs lol
my answers
21
b
ii)
Table = 6 is removed
There would have to be a section of code between lines 10-30 where the user input is obtains for "table" i.e.
get user input for "table"
- The inputted value would become the value for variable "table".
For a range of values, the SW would ask after getting the variable value for table something like "what range would you like your times for this table?"
- the first value entered would be the value for "LOW", the next the value for "HIGH". The line (counter + 1) would be changed to just (counter).
- Counter would be set to LOW value
The FOR loop would then appear as
FOR LOW to HIGH
PRINT (counter) "x" "table_entered"*Table_entered
NEXT
they did theres really differently...

c)
i)
I did water_quantity as integer. does it have to be real u rekon?

ii) No idea of files lol i blabbed heaps:
A sequential file must be read in the order written. There will be many users using this river and so many data items will be placed into this file (i.e. a string of integers containing the water usage of each customer, folowed by delimiters and ending with a sentinel value).
The advantage of this type of file would be that the length wouldnt have to be pre-defined. New water usage values could be written for each user constantly and the file would just keep extending. This is an advantage over Random Access Files (RAF), where the file's length must be defined and the length of each data item defined (what is the name of each part of a file :S is it a data item lol). Water usage numbers and their lengths would be of varying lengths for each person so it would be hard to pre-define the length of each data item in a RAF.
Sequential files provide the luxury of being able to have these data items of varying length
Writing to the file aside, reading to the file may be quiet difficult with the sequential. Linear searches would have to be performed on the file meaning if a particular users rates are at the end, all previous sections are read into memory first.
It would be hard to match the user in the UserDetails file with their usage in the sequential file. One method of doing this would be that the programmer allocates a particular character to each user i.e. a * for Harry, % for greg. These symbols would be written to the file preceeding the water usage value; delimiters separating them. i.e. in a TAB delimited file:
* TAB Harry TAB % TAB greg sentinel value.
This, however, means redundant storage of these characters.
RAF would allow for easier matching as each user would be allocated their own index in the file. Their values would all be written into this index; delimiters used to separate these values. When searching for a particular user's waterUsage values, their index is retrieved and only that index need be read into memory. This is fast, but the length of each indexed data item would have to be large to cater for all future values.

AHA doesnt look that big on paper mind you. And yes i finished the paper in time lol still had a halfa.
Is any of that right? like how files work? i thought i understood them from help in another forum but yeh i dont think i do again lol....

23
b
ii)
they say all numbers would be prime. I thought it would never leave the loop to return to main as isprime never gets turned to false as it cant enter the IF as i,j = 0 which is not <>0 :S
iii)
BEGIN SUB Factors(n)
FOR count <=n
If count is a factor of n
Print count
End if
Next
End SUB

is that too simple?

TOPIC
a
ii) I dont understand how u know what number is negative and which is positive. I jsut did the multiplication with those numbers and got the correct answer...
How do u know that the 00001111 number isnt in 2's com aswell as the question says evaluate the 2's comp..
the im sweet on
doubt any1 would reply to this long message ahaha
 
Last edited:

Rampager

Member
Joined
Jun 4, 2008
Messages
100
Gender
Male
HSC
2008
I'll just do q21. cause I was about to go to sleep, and i'll edit this in the morning/afternoon:

Q21) c)

i) The error occurs when the FOR loop assigns the value "12" to Counter, the algorithm will then print "13 x 6" = "82", this is not intended in the design specifications of the program.

It can be fixed by simplying changing two lines:
30. FOR Counter 1 to 12
40. PRINT Counter, "x 6 =", Counter*Table

ii) Similiar to yours

BEGIN PrintTables
Get startingTable from user
Get endingTable from user

FOR TimesTable = startingTable to endingTable
..FOR Counter = 1 to 12
....PRINT Counter, "x", TimesTable, "=", TimesTable*Counter
..NEXT Counter
NEXT TimeTable

END PrintTables


Then i'd just add a little note at the end saying "User should input the same number twice for a single times table" and be done with it. That's worth 3 marks

Q21) d)

i)
RECORD UserDetails
.Set UserName as String
.Set UserAddress as String
.Set TypeOfUse as String [although looking at answers they have this as Boolean, nfi]
.Set WaterQuantity as Real
END RECORD UserDetails

ii) This question sucks some monstrous ballsacks. I'm not sure if you would get the 4 marks for your answer. I would write:

Sequential Access is the process of traversing a file one data element at a time until the EOF marker/required Data Element is reached.
Random Access indexes all the individual data elements in the file to allow for direct access to these elements.

Sequential Access would be more effective to read/write to the file as the entire file must be accessed and updated at the same time, the end of the month. Direct Access also requires a lot more processing power and memory capacity in order to store all the indexes of the data elements and find them within the file. Sequential Access would also be more effective in performing searches/sorts, as the entire file must be read in order to calculate averages/highest/lowest amounts of monthly water usage.

Fuck, I've got nothing, yea that question is shit, sorry.


Q23) b)

i) The purpose of the "isprime" variable is to act as a boolean condition in the WHILE loop, if it was not present in the WHILE loop, once a number is found to be not-prime, the loop would continue regardless and hence slow down the program.

ii) If 'j' was initialised to '1' it would always be a factor of the number being checked, as '1' is a factor of any number, and hence the number would always be returned as 'not-prime'

iii)

BEGIN PrintFactors(n)
j = 1
factors = ""
WHILE j < n:
..IF mod(n,j) == 0:
....factors = factors + j + " "
..j = j + 1
END WHILE
PRINT factors
END PrintFactors(n)

Example: 6
Enters loop, factors = ""
Determines 1 is a factor, adds '1' to factors, factors is now "1 "
hits 2, adds '2' to factors, factors is now "1 2 " (notice how a space is added after each)
etc.

I did it this way instead of just "print j" because the question set it out as the numbers right next to each other, but thats just me being a pedantic motherfucker :p

Q25) a)

ii) 11111101 x 00001111

The first number "11111101" is negative, because its first (8th bit) is a "1"

Let me try to explain that abit better, imagine if you had to 7 in binary:
0111 = 7
Two's Complement:
1001 = -7

Another example, using 127
0111 1111 = 127
Two's Complement:
1000 0001 = -127

Notice the pattern yet? Yup, basically, two's complement is sign-modulus, except presented differently, the first bit (on the left) indicates the sign of the number.

It is worth noting if you ever want to talk about it, that two's complement can represent -128, while sign-modulus and one's complement can only represent -127.

Two's Complement:
Only one value of 0: 0000 0000
Can represent -128: 1000 0000 = -128
One's Complement:
Two values of 0: 0000 0000 and 1111 1111
Can represent -127: 1000 0000 = -127
Sign-Modulus:
Two values of 0: 0000 0000 and 1000 0000
Can represent -127: 1111 1111 = -127


^^ Holy shit, massive tangent.

So, back to the question:

Converting 1111 1101 to it's positive form:
0000 0010 + 1 = 0000 0011

0000 1111 x
0000 0011
---------------
..0000 1111 +
00001 1110
--------------- =
00010 1101

Flip that shit back, since we already flipped it once, add 1.
= 1 1101 0011

Ignore the ninth bit, its a 8-bit expression:
= 1101 0011


Hope that clears it up for you Crammy :)
 
Last edited:

crammy90

Member
Joined
Mar 26, 2006
Messages
264
Gender
Male
HSC
2008
Rampager said:
I'll just do q21. cause I was about to go to sleep, and i'll edit this in the morning/afternoon:

Q21) c)

i) The error occurs when the FOR loop assigns the value "12" to Counter, the algorithm will then print "13 x 6" = "82", this is not intended in the design specifications of the program.

It can be fixed by simplying changing two lines:
30. FOR Counter 1 to 12
40. PRINT Counter, "x 6 =", Counter*Table

ii) Similiar to yours

BEGIN PrintTables
Get startingTable from user
Get endingTable from user

FOR TimesTable = startingTable to endingTable
..FOR Counter = 1 to 12
....PRINT Counter, "x", TimesTable, "=", TimesTable*Counter
..NEXT Counter
NEXT TimeTable

END PrintTables

Then i'd just add a little note at the end saying "User should input the same number twice for a single times table" and be done with it. That's worth 3 marks.
thanks heaps man.
ur gonna kill sdd sami aha
2007 had the best SW developers view of hardware 1 page and little datastreams aha
 

Rampager

Member
Joined
Jun 4, 2008
Messages
100
Gender
Male
HSC
2008
Haha, I just updated my post to reflect the rest of the questions. I'll admit Crammy, you're making me work, I haven't even touched SDD to study yet, haha.

Yea I liked that year for SW Developers View, haha, except a) iii). I fucking hate it when they ask us to explain how fractions are represented.
 

crammy90

Member
Joined
Mar 26, 2006
Messages
264
Gender
Male
HSC
2008
thanks heaps man really appreciate this lol
ii) 11111101 x 00001111

The first number "11111101" is negative, because its first (8th bit) is a "1"
so when it says 2 compliments expression, that means that 11111101 is 2's comp yeh?
and 0000111 number is left normal yeh?
and we can do this calculation by ignoring overflow....
how did i get the same answer by not inverting n shit :S

did we learn about files in class :S
i swear miss didnt teach us aha
with a sequential, just say your searching for a record (linear ofcourse), is each record put into ram, determined whether it is the match, and then removed if not and the next read into ram :S or can u perform a search for the target record without reading anything into ram and then just read that record.
And just say u wanted to sort the sequential file alphabetically, could u load every record into ram, giving each record its own index in ram, sort on a particular field, and then write it all to the sequential file in order :S
and whats really got my confused with that question is
you have one file with the users details, and another file with their values of water used. How do they know what values are corresponding to each user if they arent indexed (like i could see how if it was RAF you could write each persons values to their corresponding index and then when you need to get their values you just load their index and all their values are in their yeh? but with sequential, theres nothing to indicate who the values to belong to. their just values :S.
 

Rampager

Member
Joined
Jun 4, 2008
Messages
100
Gender
Male
HSC
2008
Yup, when it says "evaluate the following 8bit two's complement expression" both binary numbers are already in their two's complement form.

You can do: 1111 1101 x 0000 1111, and you would get the same answer, the only reason you'd convert the first number into it's positive form is because it makes the multiplication easier.

Think about some real decimal numbers, this is what you did:
-5 x 5 = -25

This is what I did:
-5 x 5, I treat the first number as +5 because I find it easier to do multiplication wtihout negative numbers (I'm weird like that, yo.)
5 x 5 = 25
But since I swapped the sign of the first number, I should swap the sign of the result
= -25

Y'dig homes?




I think you might be digging too far into the Sequential/Direct access hole. I suggest just reading up on Google if you want to get deeper into it :p I didn't learn too much about it, too be honest. Although a quick google search returns "Sequential-access files are faster if you always access records in the same order. Random-access files are faster if you need to read or write records in a random order. " which is suitable for the question.

I guess in this question you can just assume the actual values of water used is automatically linked to each user in a sequential manner, e.g.

UserDetails:
bob smith farmer 200 (usage from file) / john doe worker 100 (usage from file) / etc
WaterUsage:
(bob smith's usage) / (john doe's usage) / etc

In this case it would be easier to just go through it sequentially and add the values as you, I guess. *shrug*

The only thing left I can say is check out the board of studies notes, and what the CSTA said: http://skilani.com/wp-content/uploads/2008/10/2007solutionsdd.doc

Well, since it came up in 2007, I'm banking that it won't come up in 2008, so huzzah. :p
 
Last edited:

crammy90

Member
Joined
Mar 26, 2006
Messages
264
Gender
Male
HSC
2008
Rampager said:
UserDetails:
bob smith farmer 200 (usage from file) / john doe worker 100 (usage from file) / etc
WaterUsage:
(bob smith's usage) / (john doe's usage) / etc
so basically ur saying that bobs would ALWAYs hvae to be written before johns and then it would just traverse along the file picking out every second 1 (if only bob and john are in therE) cuz ever second1 is johns. eh i give up on files.
thanks man
 

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

Top