Update
This commit is contained in:
parent
d031b584e2
commit
1bdfbe36f8
14 changed files with 1792 additions and 1772 deletions
12
exercises.md
12
exercises.md
|
@ -183,7 +183,11 @@ Bear in mind the main purpose of this quiz is for you to test your understanding
|
|||
80. If [capitalism](capitalism.md) is bad why are people migrating into capitalist countries such as [USA](usa.md)?
|
||||
81. Why are low quality videos "blocky"?
|
||||
82. What's the next number in the following sequence? 0, 1, 5, 19, 65, 211, 665, 2059, 6305, 19171, 58052, ???
|
||||
82. Did you enjoy this quiz?
|
||||
83. Programming language specifications sometimes purposefully leave some behavior undefined -- for example [C](c.md) specification says that if you declare a local variable (variable inside a function), its initial value is undefined, even though the specification could have simply said the value of such variable has to be always zero which might be safer for programmers. Why do specifications purposefully choose to leave some things undefined like this?
|
||||
84. What does [GNU](gnu.md) (Richard Stallman's project) stand for?
|
||||
85. Is political correctness and censorship ever justified?
|
||||
86. Firstly convert the expression *x + (1 + 2) / (3 - 4)* to [postfix notation](postfix.md) (also reverse Polish notation). State some major advantages of postfix notation against infix notation. Now please state disadvantage of postfix notation, especially that which would be significant if we e.g. use it for expression such as *myFunc(x,y,myFunc2(z))*.
|
||||
87. Did you enjoy this quiz?
|
||||
|
||||
### Answers
|
||||
|
||||
|
@ -269,7 +273,11 @@ Bear in mind the main purpose of this quiz is for you to test your understanding
|
|||
80. For the same reason mosquitoes fly into the mosquito killer lamps -- they have microscopic brains.
|
||||
81. Possibly for several reasons but the most prominent one is likely that video codecs typically try to save space by not saving every frame of the video as a picture but rather encode movements of small blocks into which keyframes (static pictures saved at relatively low "FPS") are chopped. This exploits temporal redundancy -- the fact that frames close in time are similar to one another, i.e. that knowing one frame we can most likely get approximate version of the next frame by splitting the current frame into blocks and just moving them around a bit. Of course this doesn't work perfectly and low bitrate or nontypical scenes can make the blocks highly visible. It would be possible to come up with similar methods that don't use blocks and may look prettier but rectangular blocks of pixels are very easy and fast to work with and the results look good enough, so they are usually used. Another reason for blockiness of videos may be e.g. that the keyframes themselves are compressed with some lossy JPEG-like compression that makes them "blocky".
|
||||
82. 175099, formula for the series is *3^n - 2^n*.
|
||||
83. yes
|
||||
83. To allow efficient implementations. By saying "we don't force you to do this" the specification gives those who implement it a freedom to do it in the most efficient way possible, depending on the specific technology they have at hand. Of course this can get tricky, but correctly choosing what to define versus what to leave undefined leads to very efficient languages. Imagine for example an instruction manual for making a boat: it may also leave the choice of its body shape up to you, you will choose the best shape depending on your situation (You want a stable boat? Fast boat? Cheap boat? Is this shape easier to make from material you have at hand? Etc.).
|
||||
84. GNU is Not Unix.
|
||||
85. no
|
||||
86. *x 1 2 + 3 4 - / +*; Advantages are for example not needing brackets at all and simple parsing and evaluation, for example we don't have to care about operator precedence. Disadvantages may be e.g. lower readability; we also have to know each operator's arity because from postfix notation it can't be deduced -- with infix notation expression *myFunc(x,y,myFunc2(z))* it is clear that *myFunc* takes 3 arguments and *myFunc2* takes 1, but if we convert it to postfix notation, we get *x y z myFunc2 myFunc3*, from which it isn't clear how many arguments each function takes.
|
||||
87. yes
|
||||
|
||||
## Other
|
||||
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue