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
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: