Contribooting some questions 'cus marathon thread
1) Name the THREE main stages involved in the translation of a programming language. (2)
2) Explain the use of a parse tree and token passing in the second stage of translation (4)
3) Compare the structured development approach with the agile approach (4)
4) What are the differences between pre-test, post-test and counted loops (3)
5) Write a EBNF expression that will allow for: One or more letters, a digit, zero or more letters, zero or more digits, letter, one or more digits. For example, this would be a legal expression: GIIQANASK8K2 (4)
Have fun guys.
1) Lexical Analysis, syntactical analysis, code generation
2) The second stage of compilation is syntactical analysis. In this stage the 'grammar' of the high level language is checked to confirm that all statements are valid. Syntactical analysis converts the strings of tokens created in the lexical analysis stage into a parse tree. A parse tree is a sequence of tokens that is organised in a manner similar to a railroad diagram, parse trees break statements of blocks of code into branched structures. For example a parse tree for:
IF a DO
ELSE IF b DO
b
ENDIF
Would first place the token representing the if statement, it would then branch into the tokens representation the two conditions.
(not sure what exactly you mean by token passing, hoping I covered it in that)
3) The structured approach is strictly sequential and each stage of the software development process must be complete before the next one can be begun. This is unlike the agile approach where stages of development can often overlap and are repeated, as new features are added or refined.The structured approach allows task to be devided easily for large teams, something which is not possible in an agile approach where small teams are usually used. The agile approach has heavy user involvement throughout the development process whilst the structured approach usually only has user involvement during the defining and understand, and testing and evaluating stages. In a structured approach early mistakes can be very expensive if discovered latter on as often a large amount of code most be redone or redesigned, agile approaches are much more felixable with such errors.
4) Both pre and post-test loops test a condition to determine whether to continue looping. Pre-test loops test this condition at the start of every loop, including before the first loop. It is possible for a pre-test loop to execute 0 times, whilst a post-test loop which checks the condition at the end of every loop must run once. A counted loop runs a set number of times, checking a condition at neither the start nor the end.
5)(assuming definition of letter and digit is provided)
expression = <letter>{<letter>}<digit>{<letters>}{<digit>}<letter>{<digit>}
For the next question, no one has answered this yet:
A software development company has been commissioned to create a train time tabling program, which will provide live timetable updates to user on an Android Smartphone platform. The timetable apps will receive gps locations of trains, as well as timetabled stops and display trains eta at any given station. The apps will also allow users to calculate the time taken to travel between two different trains.
The app will also be used by first responders to locate trains in the event of an emergency.
a) The company decides to use a combination of two development approaches. Describe which two approaches would work the best for this app, and why it would be better to use two approaches then just a single approach. Justify your answer. (6)
b) Draw a context diagram of the system. (2) [My favourite way of doing this electronically is to use the free tool, dia]
C) The smartphone app will contain a file called stops which is a sequential, unsorted file containing records. The records consist of four fields: train_number, which indicates the train the stops is for; stop_number which indicates the order the train stops at the station; station_name which stores the name of the station, and distance which stores the distance from the previous station in meters.
Trains stop for two minutes at each station, and then travel at a constant 30km/h.
i. Create a data dictionary for the fields in the record. (4)
ii. Write an algorithm for the module timeTo(currentTime, currentStopName, trainNumber) which uses the stops file to determine what time the train will arrive at it's next stop. (7)
Also some questions from the hardware option:
1) Simplify (AB + AB)A (2)
2) Create a truth table for D = (AB + AC)BC (3)