Java Doc for valid procedures in stochastic Processes, Exams of Microeconomics

Document for java Running Programs, threading, processing, multiprocesses, lists, abstracts, discretes

Typology: Exams

2016/2017

Uploaded on 10/02/2017

samuel-m-bia
samuel-m-bia 🇺🇸

1 document

1 / 5

Toggle sidebar

This page cannot be seen from the preview

Don't miss anything!

bg1
Chapter 4 (Algorithms):
An algorithm has both time and space requirements
You should express the complexity of an algorithm in terms of its problem size
Problem size is defined as the number of items an algorithm processes
For large values of n (n2 + n ) / 2 behaves like n^2
If an algorithm requires 7 basic operations for an algorithm with a problem size of n, the
algorithmic complexity is O(1)
Time complexity for adding an entry to a fixed-size array-based bag ADT is O(1)
Time complexity for adding an entry to a linked-based bag is O(1) (add to Front)
Worst-case time complexity for searching a linked-based bag ADT for a particular entry is O
(n)
Chapter 5:
When you remove an item from a stack, you remove it from the top
In your reading, the pop and peek methods throw runtime exception when the stack is empty.
An expression that has correctly paired delimiters is called a balanced expression
At the time a method is called during program execution, the activation record is pushed onto
the
program stack
INFIX TO POSTFIX
Chapter 6
The node that is easiest to access in a linked-chain is the head Node
In the Ch 6 linked-chain implementation of a Stack ADT, the performance of
popping an entry from the stack is O(1)
In the Ch 6 linked-chain implementation of a Stack ADT, when a node is
popped from the stack the original rst node is deallocated, no longer
referenced, and second node will be new rst node
In the Ch 6 array-based implementation of a Stack ADT, the entry peek
returns may be found at the last occupied location in the array
In the Ch 6 an array-based implementation of a Stack ADT, what value for the
topindex of the stack indicates that it is empty? -1
Recursive methods need a base case
What is the output of the following program when the method is called with 4?
void unknown(int n)
{
System.out.print("?");
if (n > 0)
unknown(n-1);
}
?????
The eciency for recursively traversing a chain of linked nodes is O(n)
What question should you keep in mind when debugging a recursive method?
pf3
pf4
pf5

Partial preview of the text

Download Java Doc for valid procedures in stochastic Processes and more Exams Microeconomics in PDF only on Docsity!

Chapter 4 (Algorithms):

• An algorithm has both time and space requirements

• You should express the complexity of an algorithm in terms of its problem size

• Problem size is defined as the number of items an algorithm processes

• For large values of n (n^2 + n ) / 2 behaves like n^

• If an algorithm requires 7 basic operations for an algorithm with a problem size of n, the

algorithmic complexity is O(1)

• Time complexity for adding an entry to a fixed-size array-based bag ADT is O(1)

• Time complexity for adding an entry to a linked-based bag is O(1) (add to Front)

• Worst-case time complexity for searching a linked-based bag ADT for a particular entry is O

(n)

Chapter 5:

• When you remove an item from a stack, you remove it from the top

• In your reading, the pop and peek methods throw runtime exception when the stack is empty.

• An expression that has correctly paired delimiters is called a balanced expression

• At the time a method is called during program execution, the activation record is pushed onto

the

• program stack

• INFIX TO POSTFIX

Chapter 6

• The node that is easiest to access in a linked-chain is the head Node

• In the Ch 6 linked-chain implementation of a Stack ADT, the performance of

popping an entry from the stack is O(1)

• In the Ch 6 linked-chain implementation of a Stack ADT, when a node is

popped from the stack the original first node is deallocated, no longer referenced, and second node will be new first node

• In the Ch 6 array-based implementation of a Stack ADT, the entry peek

returns may be found at the last occupied location in the array

• In the Ch 6 an array-based implementation of a Stack ADT, what value for the

topindex of the stack indicates that it is empty? -

• Recursive methods need a base case

• What is the output of the following program when the method is called with 4?

• void unknown(int n)

• System.out.print("?");

• if (n > 0)

• unknown(n-1);

• The efficiency for recursively traversing a chain of linked nodes is O(n)

• What question should you keep in mind when debugging a recursive method?

• Does each base case produce a result that is correct for that case?

• Are there enough base cases?

• Is at least one of the cases a base case that has no recursive call?

• What is the output of the following program when the method is called with 4?

  • void unknown(int n)
  • {
  • if (n > 0)
  • {
  • (^) System.out.print("?");
  • unknown(n-1);
  • }
  • }

What is the output of the following program when the method is called with 4?

  • void unknown(int n)
  • {
  • if (n > 0)
  • unknown(n-1);
  • System.out.print("?");
  • }

• How many recursive calls will be made if the following method is called with

6 from main?

  • void greeting(int n)
  • {
  • if (n > 0)
  • {
  • System.out.println("Hello!");
  • greeting(n-1);
  • (^) }
  • }

• 6 recursive calls

• When too many recursive calls are made creating more activation records

than the allocated program memory can handle, what kind of error occurs?

• stack overflow

Chapter 7:

• If iteraton has ended, the next method throws a NoSuchElementException

• After a call to remove, the nextPosition data field should be decremented

• Insertion Sort (o n^2) wort and average. Basically make mini lists of

everything and when traversing insert to necessary place. Chapter 10:

• Subclass = derived class

• Super class = base class

• If the SortedList class inherited the remove by position method from the LList

class

• we would not have to implement it again

• Because SortedList is derived from LList, you write super.add(newPosition,

newEntry) to invoke the add operation of the ADT list

• If you plan for a future subclass to be allowed to manipulate a class’s data

fields, provide protected methods to enable the subclass to do this safely and efficiently.

• To prevent a subclass from overriding protected methods, we declare them to

be final

• When you declare a method to be protected and final, who can access it?

subclass

• What issue should you weigh when considering an implementation for an

ADT? Exec time, memory usage, extensibility

• Circular array literally just move around in a circle array index = (index + 1)

% N

public int binary(int n) {

int d = 0;

int power = 0;

while (true) {

if (n == 0) {

break;

else {

int temp = n%10;

d += temp*Math.pow(2,power);

n = n/10;

power++;

return d;