June 28, 2013

KBP chapter 16

Review Questions
1. What are the three primary uses of symbolic logic in formal logic?
-To express propositions, to express the relationships between propositions, and to describe how new propositions can be inferred from other propositions that are assumed to be true.

2. What are the two parts of a compound term?
- Functor and ordered list of parameters.

3. What are the two modes in which a proposition can be stated?
- One in which the proposition is defined to be true, and one in which the truth of the proposition is something that is to be determined. In other words, propositions can be stated to be facts or queries.

5. What are antecedents? Consequents?
-Antecedents are right side of a clausal form proposition. Consequent is left side of a clausal form propositions.

6. Give general (not rigorous) definitions of resolution and unification.
-Resolution is the inference rule that allows inferred propositions to be computed from given propositions, thus providing a method with potential application to automatic theorem proving. 
Unification is the process of determining useful values for variables.

9. What does it mean for a language to be nonprocedural?
-Language in which the programs do not exactly state how a result is to be computed but rather describe the form of the result.

11. What is an uninstantiated variable?
-A variable that has not been assigned a value.

13. What is a conjunction?
-Conjunctions contain multiple terms that are separated by logical AND operations.

Problem Set
1. “All predicate calculus propositions can be algorithmically converted to clausal form”. Is this statement true or false? Explain.
-This statement is true. Nilsson (1971) gives proof that this can be done, as well as a simple conversion algorithm for doing it.

2. Describe how a logic programming language is different from a general programming language.
-Programming that uses a form of symbolic logic as a programming language, unlike other general programming language, is often called logic programming; languages based on symbolic logic are called logic programming languages, or declarative languages.

8. Critically comment on the following statement: “Logic programs are nonprocedural”.
- It is true, because logical programs use lots of different processes based on its conditions. If a certain logical requirement is true, then a program will execute the corresponding process, instead of procedurally executing the statements.

KBP Chapter 15

2. What does a lambda expression specify?
-The predicate function is often given as a lambda expression, which in ML is defined exactly like a function, except with the fn reserved word, instead of fun, and of course the lambda expression is nameless.
5. Explain why QUOTE is needed for a parameter that is a data list.
-To avoid evaluating a parameter, it is first given as a parameter to the primitive function QUOTE, which simply returns it without change.
6. What is a simple list?
- A list which membership of a given atom in a given list that does not include sublists.
7. What does the abbreviation REPL stand for?
-REPL stand for read-evaluate-print loop.
11. What are the two forms of DEFINE?
-The simplest form of DEFINE is one used to bind a name to the value of an expression. This form is (DEFINE symbol expression) The general form of such a DEFINE is (DEFINE (function_name parameters) (expression)
13. Why are CAR and CDR so named?
-The names of the CAR and CDR functions are peculiar at best. The origin of these names lies in the first implementation of LISP, which was on an IBM 704 computer. The 704’s memory words had two fields, named decrement and address, that were used in various operand addressing strategies.
 Each of these fields could store a machine memory address. The 704 also included two machine instructions, also named CAR (contents of the address part of a register) and CDR (contents of the decrement part of a register), that extracted the associated fields. It was natural to use the two fields to store the two pointers of a list node so that a memory word could neatly store a node. 
Using these conventions,the CAR and CDR instructions of the 704 provided efficient list selectors. The names carried over into the primitives of all dialects of LISP.
18. What is tail recursion? Why is it important to define functions that use recursion to specify repetition to be tail recursive?
-A function is tail recursive if its recursive call is the last operation in the function. This means that the return value of the recursive call is the return value of the nonrecursive call to the function. It is important to specify repetition to be tail recursive because it is more efficient(increase the efficiency).
19. Why were imperative features added to most dialects of LISP?
- LISP began as a pure functional language but soon acquired some important imperative features to increased its execution efficiency.
26. What is type inferencing, as used in ML?
-Type inference refers to the automatic deduction of the type of an expression in a programming language. If some, but not all, type annotations are already present it is referred to as type reconstruction.
29. What is a curried function?
-Curried functions a function which a new functions can be constructed from them by partial evaluation.
30. What does partial evaluation mean?
- Partial evaluation means that the function is evaluated with actual parameters for one or more of the leftmost formal parameters.
32. What is the use of the evaluation environment table?
-A table called the evaluation environment stores the names of all implicitly and explicitly declared identifiers in a program, along with their types. This is like a run-time symbol table.
33. Explain the process of currying.
- The process of currying replaces a function with more than one parameter with a function with one parameter that returns a function that takes the other parameters of the initial function.
8. How is the functional operator pipeline ( |> ) used in F#?
answer: The pipeline operator is a binary operator that sends the value of its left operand, which is an expression, to the last parameter of the function call, which is the right operand. It is used to chain together function calls while flowing the data being processed to each call.
9. What does  the following Scheme function do?
(define ( y s lis)
(( null? lis) ‘ () )
((equal? s (car lis)) lis)
(else (y s (cdr lis)))
answer: y returns the given list with leading elements removed up to but not including the first occurrence of the first given parameter.
10.What does  the following Scheme function do?
(define ( x lis)
(( null? lis) 0 )
(( not(list? (car lis)))
((eq? (car lis) #f) (x (cdr lis)))
(else (+1 (x (cdr lis))))))
(else (+ (x (car lis))  (x (cdr lis))))
-x returns the number of non-#f atoms in the given list

KBP Chapter 14

6. What is exception propagation in Ada?
-Exception propagation allows an exception raised in one program unit to be handled in some other unit in its dynamic or static ancestry. This allows a single exception handler to be used for any number of different program units. This reuse can result in significant savings in development cost, program size, and program complexity.
9. What is the scope of exception handlers in Ada?
-Exception handlers can be included in blocks or in the bodies of subprograms, packages, or tasks.
10. What are the four exceptions defined in the Standard package of Ada?
-There are four exceptions that are defined in the default package, Standard:
- Constraint_Error
- Program_Error
- Storage_Error
- Tasking_Error

11. Are they any predefined exceptions in Ada?
12. What is the use of Suppress pragma in Ada? 
-The suppress pragma is used to disable certain run-time checks that are parts of the built-in exceptions in Ada.
14. What is the name of all C++ exception handlers?
-Try clause.
30. In which version were assertions added to Java?
-Assertions were added to Java in version 1.4.
31. What is the use of the assert statement?
-The assert statement is used for defensive programming. A program may be written with many assert statements, which ensure that the program’s computation is on track to produce correct results.
32. What is event-driven programming?
-Event-driven programming is a programming where parts of the program are executed at completely unpredictable times, often triggered by user interactions with the executing program.
33. What is the purpose of a Java JFrame?
-The JFrame class defines the data and methods that are needed for frames. So, a class that uses a frame can be a subclass of JFrame. A JFrame has several layers, called panes.
34. What are the different forms of assert statement?
-There are two possible forms of the assert statement:
 a.assert condition;
 b.assert condition : expression;
1.What mechanism did early programming languages provide to detect or attempt to deal with errors?
-Early programming languages were designed and implemented in such a way that the user program could neither detect nor attempt to deal with such errors. In these languages, the occurrence of such an error simply causes the program to be terminated and control to be transferred to the operating system.
2.Describe the approach for the detection of subscript range errors used in C and Java.
-In C subscript ranges are not checked. Java compilers usually generate code to check the correctness of every subscript expression. If any exception generates, then an unchecked exception is thrown.
6.In languages without exception-handling facilities, it is common to have most subprograms include an “error” parameter, Which can be set to some values representing “OK” or some other value representing “error in procedure”. What advantage does a linguistic exception-handling facility like that of Ada have over this method?
-There are several advantages of a linguistic mechanism for handling exceptions, such as that found in Ada, over simply using a flag error parameter in all subprograms. One advantage is that the code to test the flag after every call is eliminated. Such testing makes programs longer and harder to read. Another advantage is that exceptions can be propagated farther than one level of control in a uniform and implicit way. Finally, there is the advantage that all programs use a uniform method for dealing with unusual circumstances, leading to enhanced readability.
7.In languages without exception-handling facilities, we could send an error-handling procedure as parameter to each procedure that can detect errors than must be handled. What disadvantage are there to this method?
- There are several disadvantages of sending error handling subprograms to other subprograms. One is that it may be necessary to send several error handlers to some subprograms, greatly complicating both the writing and execution of calls. Another is that there is no method of propagating exceptions, meaning that they must all be handled locally. This complicates exception handling, because it requires more attention to handling in more places.
14. Summarize the arguments in favor of the termination and resumption models of continuation.
-The resumption model is useful when the exception is only an unusual condition, rather than an error. The 
termination model is useful when the exception is an error and it is highly unlikely that the error can be corrected so that execution could continue in some useful way.

June 27, 2013

KBP Chapter 13

Rickvian aldi / 1601253441 / 02PCT

Review question

1. What are the three possible levels of concurrency in programs?
-Instruction level, Statement level, and Unit level
2. Describe the logical architecture of an SIMD computer.
-Computers that have multiple processors that execute the same instruction simultaneously
3. Describe the logical architecture of an MIMD computer.
-Computers that have multiple processors that operate independently but whose operations can be synchronized
4. What level of program concurrency is best supported by SIMD computers?
-Instruction concurrency level
5. What level of program concurrency is best supported by MIMD computers?
-Unit concurrency level.
6. Describe the logical architecture of a vector processor.
-Vector processors have groups of registers that store the operands of a vector operation in which the same instruction is executed on the whole group of operands simultaneously
7. What is the difference between physical and logical concurrency?
-Physical concurrency – Multiple independent processors (multiple threads of control)
Logical concurrency – The appearance of physical concurrency is presented by time-sharing one processor (software can be designed as if there were multiple threads of control)
8. What is a thread of control in a program?
-A thread of control in a program is the sequence of program points reached as control flows through the program
12. What is a heavyweight task? What is a lightweight task?
-Heavyweight tasks execute in their own address space. Lightweight tasks all run in the same address space – more efficient
Problem Set
1. Explain clearly why competition synchronization is not a problem in a programming environment that supports coroutines but not concurrency.
Competition synchronization is not necessary when no actual concurrency takes place simply because there can be no concurrent contention for shared resources.  Two nonconcurrent processes cannot arrive at a resource at the same time.
2. What is the best action a system can take when deadlock is detected?
When deadlock occurs, assuming that only two program units are causing the deadlock, one of the involved program units should be gracefully terminated, thereby allowed the other to continue.
3. Busy waiting is a method whereby a task waits for a given event by continuously checking for that event to occur. What is the main problem with this approach?
The main problem with busy waiting is that machine cycles are wasted in the process.
4. In the producer-consumer example of Section 13.3, suppose that we incorrectly replaced the release(access) in the consumer process with wait(access). What would be the result of this error on execution of the system?
Deadlock would occur if the release(access) were replaced by a wait(access) in the consumer process, because instead of relinquishing access control, the consumer would wait for control that it already had.

KBP chapter 12

Rickvian Aldi / 02PCT / 1601253441
Assignment By Mr. Tri Djoko Wahjono

Review Questions

1. Describe the three characteristic features of object-oriented languages.
-Abstract data types, Inheritance and Polymorphism.

2. What is the difference between a class variable and an instance variable?
-The difference between instance and class variables is. Class variables only have one copy that is shared by all the different objects of a class, whereas every object has it’s own personal copy of an instance variable. So, instance variables across different objects can have different values whereas class variables across different objects can have only one value.

3. What is multiple inheritance?
-the inheritance which allows a new class to inherit from two or more classes

4. What is a polymorphic variable?
-A polymorphic variable can be defined in a class that is able to reference (or point to) objects of the class and objects of any of its descendants

5. What is an overriding method?
-Overriding method is a method that purpose is provide an operation in the subclass that is similar to one in the parent class, but is customized for objects of the subclass.

7. What is a virtual method?
-Virtual method is a function or method whose behavior can be overridden within an inheriting class by a function with the same signature.

8. What is an abstract method? What is an abstract class?
-An abstract method is one that does not include a definition (it only defines a protocol). An abstract class is one that includes at least one virtual method. An abstract class cannot be instantiated

9. Describe briefly the eight design issues used -in this chapter for objectoriented languages.
The Exclusivity of Objects
Are Subclasses Subtypes?
Type Checking and Polymorphism
Single and Multiple Inheritance
Object Allocation and Deallocation
Dynamic and Static Binding
Nested Classes
Initialization of Objects

10. What is a nesting class?
-Nesting class is a class whose definition appears inside the definition of another class, as if it were a member of the other class.

11. What is the message protocol of an object?
-Message protocol of an object is the entire collection of methods of an object

problem set

1.What important part of support for inheritance is missing in java?
java does not support the private and protected derivation of c++.One can surmise that the Java designers believed that subclasses should be subtypes,
which they are not when private and protected derivations are supported. Thus,
they did not include them.

5. Compare the class entity access controls of C++ and Ada 95.
C++ has extensive access controls to its class entities. Individual entities can be marked public, private, or protected, and the derivation process itself can impose further access controls by being private. Ada, on the other hand, has no way to restrict inheritance of entities (other than through child libraries, which this book does not describe), and no access controls for the derivation process.

10.explain one advantage of inheritance.
-The advantage is able to reuse the declared class in other name, an inheritance class will inherit all method , attribute inside the class without declaring the same class again. It also reduce the code length.

11.Compare inheritance and nested classes in C++. Which of these supports an is-a relationship?
-clearly inheritance that support is-a relationship. Inheritance offer a solution to both the modification problem posed by abstract data type can inherit the data and functionality of some existing type
nested classes are only used for data hiding, it does not inherit.

KBP chapter 11

Rickvian Aldi / 02PCT / 1601253441
Assignment By Mr. Tri Djoko Wahjono

Review Questions 1. What are the two kinds of abstractions in programming languages?
- Process abstraction and Data abstraction.

2. Define abstract data type.
-An abstract data type is a data structure, in
the form of a record, but which includes subprograms that manipulate its data.

3. What are the advantages of the two parts of the definition of abstract data
-It is a weapon against complexity; a means of making large and/or complicated programs more manageable.

4. What are the language design requirements for a language that supports
abstract data types?

-The representation of objects of the type is hidden from the program units
that use the type, so the only direct operations possible on those objects are
those provided in the type’s definition.
-The declarations of the type and the protocols of the operations on objects
of the type, which provide the type’s interface, are contained in a single
syntactic unit. The type’s interface does not depend on the representation
of the objects or the implementation of the operations. Also, other program
units are allowed to create variables of the defined type.

5. What are the language design issues for abstract data types?
-The first design issue for abstract data types is the form of the container for the interface to the type.
-The second design issue is whether abstract data types can be parameterized.
-The third design issue is what access controls are
provided and how such controls are specified.

15. What is the purpose of a C++ constructor?
-constructors are used to initialize the data members of newly created objects. A constructor
may also allocate the heap-dynamic data that are referenced by the pointer
members of the new object.

17. Where are all Java methods defined?
-Methods in Java must be defined completely in a class.

26. Why does Java not have destructor?
-destructor are obviated by Java’s implicit garbage collection

27. Where are all Java methods defined?
-Methods in Java must be defined completely
in a class.

28. Where are Java classes allocated?
-from the heap and
accessed through reference variables.

30. What is a friend function? What is a friend class?
-Friend functions have access to the private entities of the class where they are declared to be friends.Friend class is a class that can access the private entities of the class which has friend function in it.
37. What is the name of all Ruby constructors?
-Constructors in Ruby are named initialize.

Problem Set
4. What are the advantages of the nonpointer concept in Java?
-Any task that would require arrays, structures, and pointers in C can be more easily and reliably performed by declaring objects and arrays of objects. Instead of complex pointer manipulation on array pointers, you access arrays by their arithmetic indices. The Java run-time system checks all array indexing to ensure indices are within the bounds of the array. You no longer have dangling pointers and trashing of memory because of incorrect pointers, because there are no pointers in Java.

10.Which two conditions make data type “abstract”?
answer :
-The representation of objects of the type is hidden from the program units that use the type, so the only direct operations possible on those objects are those provided in the type’s definition.
-The declarations of the type and the protocols of the operations on objects of the type, which provide the type’s interface, are contained in a single syntactic unit. The type’s interface does not depend on the representation of the objects or the implementation of the operations. Also, other program units are allowed to create variables of the defined type.

11. Why is destructor of C# rarely used?
-Although C# allows destructors to be defined, because it uses garbage collection
for most of its heap objects, destructors are rarely used.

12.How are classes in Ruby are made dynamic?
-Classes in Ruby are dynamic in the sense that members can be added at
any time. This is done by simply including additional class definitions that
specify the new members. Moreover, even predefined classes of the language,

15. Give one capability that Java 5.0 provides which C# 2005 does not.
-One capability that Java 5.0 provides that C# 2005 does not is wildcard classes.

June 25, 2013

Cara Daftar Google Maps Untuk Lokasi Bisnis Anda

Google Maps dapat membantu pelanggan untuk menemukan lokasi bisnis anda dengan sangat mudah. Untuk memastikan anda tidak kelewatan kesempatan ini dalam pembuatan website bisnis anda, anda harus daftar Google Maps terlebih dahulu dan menambahkan informasi tentang bisnis anda agar pelanggan anda dapat menemukan lokasi bisnis anda dengan Google Maps.
Untuk daftar Google Maps itu sebenarnya gampang plus aman. Tidak semua orang dapat mendaftarkan bisnis anda di Google Maps, karena akan ada proses konfirmasi yang benar-benar aman untuk mengkonfirmasikan bahwa anda adalah si pemilik bisnis yang menambahkan informasi bisnis ke Google Maps tersebut.

Cara Daftar Google Maps Untuk Lokasi Bisnis Anda

Langkah #1
Kunjungi Google Maps , Klik link yang bertuliskan “Put your Business on Google Maps.”
Langkah #2
Login ke akun Google anda. Bila anda belum punya, pilih “Create an account now” dan ikuti saja langkah-langkahnya hingga anda memiliki akun Google baru.
Langkah #3
Klik link yang bertuliskan “List your business.”
Langkah #4
Pilih negara dan tuliskan nomor telepon bisnis anda di tempat yang sudah disediakan. Jika Google memiliki informasi apapun yang berhubungan dengan telepon anda, Google akan menampilkan informasi telepon tersebut untuk anda edit. Jika tidak, anda akan dapat menambahkan nomor telepon bisnis anda yang baru.
Langkah #5
Tambahkan bisnis anda ke Google Maps dengan klik link “Add a new listing.”
Langkah #6
Masukan informasi bisnis anda, seperti nama perusahaan, alaman, telepon, dan alamat website. Klik “Next.”
Langkah #7
Masukan lagi informasi untuk bisnis anda, seperti jam kerja, foto-foto atau video yang dapat membantu mempromosikan bisnis anda.
Langkah #8
Pastikan informasi bisnis yang anda kirimkan sudah benar, lalu klik “Submit”. Setelah anda selesai mendaftarkan bisnis anda, anda akan dapat melihatnya secara online.
Apabila anda mengubah informasi bisnis anda, Google Maps akan memverifikasikan bahwa anda adalah si pemilik bisnis dengan mengirimkan surat atau melalui telepon. Anda akan mendapatkan kode konfirmasi untuk dimasukkan secara online kemudian menyelesaikan pengaturan informasi anda.
Apapun jenis website yang anda miliki, Google Maps akan sangat berguna untuk membantu pengunjung website anda dalam menemukan lokasi bisnis anda. Jadi, ayo daftar Google Maps dari sekarang!

SUMBER : http://www.mattjunior.com/2013/03/cara-daftar-google-maps-untuk-lokasi-bisnis-anda/

June 17, 2013

KBP chapter 10

Review questions 

1.What is the definition used in this chapter for “simple” subprograms?
-Subprograms cannot be nested and all local variables are static.

2. Which of the caller or callee saves execution status information?
-Either can sqve the execution status

3. What must be stored for the linkage to a subprogram?
- Execution status information

4. What is the task of a linker?
- find files that contain the translated subprograms referenced in that program and load them into memory, set target addresses of all calls to those subprograms in the main program to the entry addresses of those subprograms.

6. What is the difference between an activation record and an activation
record instance?
-The format, or layout, of the noncode part of a subprogram is called an
activation record.

-An activation record instance is a concrete example of an activation

8. What kind of machines often use registers to pass parameters?

11. What is an EP, and what is its purpose?
Enviroment Pointer.
The EP is used as the base of the offset addressing of the data contents of
the activation record instance—parameters and local variables.

Problem Set

6. Although local variables in Java methods are dynamically allocated at the beginning of each activation, under what circumstances could the value of a local variable in a particular activation retain the value of previous activation ?
-only if variable is declared as static. 
-Static modifier is a modifier that makes a variable history sensitive.

7. It is stated in this chapter that when nonlocal variables are accessed in a dynamic-scoped language using the dynamic chain, variable names must be stored in the activation records with the values. If this were actually done, every nonlocal access would require a sequence of costly string comparisons on names. Design an alternative to these string comparisons that would be faster.
-auxiliary data structure called a display. Or, to write variable names as integers. These integers act like an array. So when the activation happens, the comparisons will be faster.

9. The static-chain method could be expanded slightly by using two static links in each activation record instance where the second points to the static grandparent activation record instance. How would this approach affect the time required for subprogram linkage and nonlocal references ?
-Including two static links would reduce the access time to nonlocals that are defined in scopes two steps away to be equal to that for nonlocals that are one step away. Overall, because most nonlocal references are relatively close, this could significantly increase the execution efficiency of many programs.

11. If a compiler uses the static chain approach to implementing blocks, which of the entries in the activation records for the subprograms are needed in the activation records for blocks?
-the static chain connects all the static ancestors of an executing subprogram, in order of static parent first.

KBP chapter 9

Rickvian Aldi / 02PCT / 1601253441
Assignment By Mr. Tri Djoko Wahjono

Review Questions
1. What are three general characteristics of subprograms ?
- each subprograms has a single entry point
- the calling program unit is suspended during the execution of the called subprogram, which implies that there is only one subprogram in execution at any given time.
- Control always returns to the caller when the subprogram execution terminates.

2. What does it mean for a subprogram to be active ?
- if it has been called and started execution but the execution is not completed yet.

3. What is given in the header of a subprogram ?
- specifies that the following syntactic unit is a subprogram definition of some particular kind, provides name of the subprogram, optionally specifies a list of parameters
4. What characteristics of Python subprograms sets them apart from those of other languages ?
- function def statements are executable
5. What languages allow a variable number of parameters ?
- C,C++,Perl JavaScript, and Lua
6. What is a Ruby array formal parameter ?
- Substitute of keyword parameter which Ruby does not support
7. What is a parameter profile ? What is a subprogram protocol ?
- Parameter profile contains number, order and types of its formal parameter. Subprogram Protocol is the parameter profile and the return value if it is a function.
8. What are formal parameters ? What are actual parameters ?
- formal parameters are parameters in the subprogram header. Actual parameters are a list of parameters included in subprogram call statements
9. What are the advantages and disadvantages of keyword parameters ?
- The advantage is they can appear in any order in the actual parameter list. The disadvantage is the user must know the names of formal parameters.
10 . What are the differences between a function and a procedure ?
- Functions return values while procedure does not .
- Procedure defines new statements, while function define new user-defined operators.

Problem Set

1 .What are arguments for and against a user program building additional definitions for existing operators, as can be done in Python and C++? Do you think such user-defined operator overloading is good or bad ? Support your answer.
Answer :
-Operator overloading is created to make coding easier by able to add a non number object. This will act like an function overloading, which is represent by a operator symbol. but behind that, operator overloading is user defined, so the use of it can be known by only the programmer who coded the overloading. too much overloading will make ambiguity of the program increasing.

3. Argue in support of the templated functions of C++. How is it different from the templated functions of other languages ?
Answer : 
-Templated function will allow function to recieve many diffrent datatyle, for sake of readibility, templated functions is preferable than creating function overloading.

7. Consider the following program written in C syntax :

void fun(int first, int second){
first =+ first;
second += second;}

void main(){
int list[2] = {3,5};
fun (list[0], list[1]);
For each of the following parameter-passing methods, what are the values of the list array after execution ?
answer :
a. )Passed by value
 list[2] = {3,5}
b. )Passed by reference
 list[2] = {6,10}
c. )Passed by value-result
 list[2] = {6,10}

8.Argue against the Java design of not providing operator overloading.
Answer :
Once again, operator overloading is user defined. This will decrease readibility significantly which is make sense if operator overloading is not provided.