Average Case Flashcards

1
Q

What is the intuition behind average case algorithms?

A
How well did you know this?
1
Not at all
2
3
4
5
Perfectly
2
Q

What is the definition of Expectation of variable T?

A
How well did you know this?
1
Not at all
2
3
4
5
Perfectly
3
Q

Find the expectation of T for the following:

A
How well did you know this?
1
Not at all
2
3
4
5
Perfectly
4
Q

Find the expactation of the following:

A
How well did you know this?
1
Not at all
2
3
4
5
Perfectly
5
Q

What is a Randomized Algorithm?

A
How well did you know this?
1
Not at all
2
3
4
5
Perfectly
6
Q

What is the randomized algorithm type: Las Vegas?

What is an example of this algorithm?

A
How well did you know this?
1
Not at all
2
3
4
5
Perfectly
7
Q

What is the randomised algorithm type; Monte Carlo?

A
How well did you know this?
1
Not at all
2
3
4
5
Perfectly
8
Q

What are the advantages/disadvantages of randomized algorithms in general?

A
How well did you know this?
1
Not at all
2
3
4
5
Perfectly
9
Q

What are the advantages/disadvantages of Las Vegas algorithms?

A
How well did you know this?
1
Not at all
2
3
4
5
Perfectly
10
Q

What are the advantages/disadvantages of Monte Carlo algorithms?

A
How well did you know this?
1
Not at all
2
3
4
5
Perfectly
11
Q

Why does it make more sense to think about expected time instead of worst-case time for Las Vegas algorithms?

A
How well did you know this?
1
Not at all
2
3
4
5
Perfectly
12
Q

In general, how is MySQL used in PHP?

A
How well did you know this?
1
Not at all
2
3
4
5
Perfectly
13
Q

What are JSPs?

For scripting languages in general, what benefits that does provide?

A

Java Server Pages (JSP):

Like PHP, JSPs consist of static elements (normally text and HTML) and JSP “Elements” that generate dynamic content.

JSPs provide:

  • Language for developing text-based pages that describe how to process a request to create an HTML response
  • A means of accessing server-side objects
    • to provide a means of generating the dynamic content using information nt directly avail to the JPS
  • A mechanism for extending the JSP language
    • Which helps simplify repeated taskss and for future evolution of JSP technology

Which means:

  • Separates the “user interface” (html) from content generation (script code)
  • so we can change the page layout without changing code generating the dynamic content
    • easier and faster development of web applications
    • Decreased maintenance effort for web applications
      • hence lower cost, more reliable
How well did you know this?
1
Not at all
2
3
4
5
Perfectly
14
Q

What tags enclose a Java expression that is to be evaluated for JPS?

A

The time is

How well did you know this?
1
Not at all
2
3
4
5
Perfectly
15
Q

JSP support the embedding of short sequences of Java code, what do we call them?

What tags are used ot do this?

A

Called “Scriptlets”, these are embedded in HTML pages

Done with the tags (not that the ‘=’ sign is missing)

The time is:

NOTE: The declaration persists across tags

How well did you know this?
1
Not at all
2
3
4
5
Perfectly
16
Q

In general how would JSP be used to access submitted form data?

A

request.getParameter(“fname”) %>

The object request is built into JSPs and refs to the HTTP request recived by the webserver from the web browser (which contains the form data).

17
Q

With JSPs and declarations, what does one need to remain mindful of?

A

Declarations are only processed once

Any declared data must be guarded to prevent invalid concurrent access

  • because there are multi-threaded
  • access must be synchronized
18
Q

How would you use JSPs to include another page?

A

could have body here

This is an example of using predefined tags

19
Q

What are ASPs?

A

Active Server Pages

  • This is mircrosoft’s JSP “equivalent”
  • Capabilities of JSPs and ASPs are very similar
  • JSPs are tied to java, ASPs are more flexible
    • ASP.net allows any .net language
20
Q

What is required of the web server to run ASP scripts

A

An ASP-enabled web server supports the execution of server-sive ASP scripts

Such a server will invoke the ASP processory whenever a file with a .asp sufffix is encountered

  • These need to be in an ASP enabled folder
21
Q

In the ASP “Programming” model, what objects are available for use in ASP scripts?

A
22
Q

At it’s most basic level what is the ASP Application object?

A

It represents the entire web application, conisisting of the various pages and associated scripts

It is initialized by the web server when the first client requests a related file

There is only a single Application object for a given application running on a server (even if there are many users)

  • which of course would allow for sharing of information between clients
23
Q

What is an Application object’s physical manifestation?

A

All the .asp files in it’s corresponding [virtual] directory

  • virtual directory = the directory name as viewed by the suers of the system via the web
    • A web server often maps from a virtual directory to a different physical directory
      • /images to /etc/httpd/images
24
Q

Each Application object maintains colelctions of application-level variables and objects that have been added to it.

How are they accessed?

A

Collections are essentiall object-based associative arrays

Application.Contents - contains the share variables

Application.StaticObjects - maintains the object references

Elements in collections can be manipulated by it’s position index or the associated key

  • Assignment
    • Application.Contents.Item(“pi”) = 3.14
  • Reference
    • pi=Application.Contents.Item(“pi”)
    • pi=Application.Contents.Item(7)
  • Or using the shortcut
    • Application.contents(“pi”)
    • Application(“pi”)
25
Q

Application.Contents contains the shared variables, because they are shared what do we need to implement?

A

Synchronization

  • Application.lock
  • Application.unlock

Note: this locks the ENTIRE contents of the collection so perfman hit can be VERY HIGH

Example below:

26
Q

In HTTP the Request and the Response are actually objects.

Request provides access to all the information contained in the HTTP request.

The Request object maintains this information in a number of collections.

What are the collections of interest to us?

A

Request.Form

Request.QueryString

Request.ServerVariable

Request.Cookies

27
Q

What does the collection Request.Form contain?

How do you access this information?

A

contains all the information about the parameters recieved via an HTTP POST request.

Request.Form.Item(“fname”) - to get the string entered on the form in the input field with the name “fname”

or, more commonly Request.Form(“fname”)

28
Q

What is contained in the collection Request.QueryString?

How is it accessed?

A

Request.QueryString contains all the informatuon about the parameters recieved via an HTTP GET request.

Accessed by:

Request.QueryString(“fname”)

or Request.QueryString.Item

29
Q

What collection does Request.ServerVariables contain?

How is it accessed?

A

Contains all the information about the server’s environment variablles that pertain to the current HTTP request.

There’s a huge list but here are the most important ones:

30
Q

What does the collection Request.Cookies contain?

A

Contains all the information about any cookies recieved from the webclient application

Cookies: Are a means by which per-client information can be maintained over time

  • Because web servers are stateless, so the state (or data state) is stored at the client in cookies.
31
Q

In general what does the Response object allow you to do?

A

Allows your ASP script to send its response back to the web client.

Allows you to control:

  • HTTP response message headers
  • HTTP response message body
  • when and how the response is sent
32
Q

What are the most important properties (not methods) in the Response object?

A
  • Response.Buffer - wether the response is to be buffered or sent to the client as generated
    • useful when sending large responses such as images, sound files
  • Response.Expires - Content expiry time
  • Response.CacheControl - Cache control
  • Response.Cookies.Item - cookies
33
Q

What ar ethe methods defined for the Response object?

A
34
Q

What is the ObjectContext object and what does it provide?

A

Provides for “transactional execution”

Transactional Execution: guarantees tha either all parts of the “transaciton” complete successfully or none of the affects of any of the parts are applied (“ACID properties”)

  • Technically what normally happens is that completed partial-effects are undone
35
Q

What is transactional execution useful for, provide an example

A
36
Q

How does the code work for ObjectContext to ensure transactional execution?

A

To indicate the code that should be transcation is set by:

In these script you explicitly test by use of:

ObjectContext.SetAbort - if one fails

ObjectContext.SetComplete - after the final one succeeds.

You must specify code to be executed when a transaction aborts or completes

OnTransactionAbort( )

OnTransactionCommit( )

37
Q

What is the Session object and what does it provide?

A

Provides a way for per-user interaction information to be stored

  • shopping carts as an example
38
Q

What is the Server object and what does it provide?

A

It acts as a catch-all for various additional capabilities

Server.ScriptTimeout : used to limit execution time of the corresponding script

  • Used to prevent rougue scripe code consuming too much of a server’s resources
    • which is a simple DNS attack

It also provides the attached methods/abilities:

39
Q
A