Skip to main content

Posts

Relevant Course / Subjects to Artificial Intelligence

Philosophy :  Logic, methods of reasoning, mind as physical system, foundations of learning, language, rationality. Mathematics:  Formal representation and proof, algorithms, computation, (un)decidability, (in)tractability Probability/Statistics:  Modeling uncertainty, learning from data Economics:  Utility, decision theory, rational economic agents Neuroscience:   Neurons as information processing units. Psychology/  Cognitive Science:   How do people behave, perceive, process cognitive information,  represent knowledge.               Computer engineering:  Building fast computers  Control theory:  Design systems that maximize an objective function over time Linguistics:  Knowledge representation, grammars. 

Intelligence and Artificial Intelligence, what is it?

What is artificial intelligence? Artificial intelligence is the intelligence of machines and robots and the branch of computer science that aims to create it. -  Wikipedia . It is the science and engineering of making intelligent machines, especially intelligent computer programs. It is related to the similar task of using computers to understand human intelligence, but AI does not have to confine itself to methods that are biologically observable. What is intelligence?  “the capacity to learn and solve problems” (Websters dictionary) In particular,  the ability to solve novel problems  the ability to act rationally  the ability to act like humans refere to AI.   Intelligence is the computational part of the ability to achieve goals in the world. Varying kinds and degrees of intelligence occur in people, many animals and some machines.

Knapsack Algorithm Shortcut Method

The knapsack problem or rucksack problem is a problem in combinatorial optimization: Given a set of items, each with a weight and a value, determine the number of each item to include in a collection so that the total weight is less than or equal to a given limit and the total value is as large as possible. It derives its name from the problem faced by someone who is constrained by a fixed-size knapsack and must fill it with the most valuable items. The main goal of Knapsack  is: You have a knapsack that has capacity (weight) W. You have several items I1,…,In. Each item Ij has a weight wj and a benefit bj.You want to place a certain number of copies of each item Ij in the knapsack so that: The knapsack weight capacity is not exceeded and The total benefit is maximal. There is a Shortcut Method  for Knapsack Algorithm , see the video:  

Java Program for finding Palindrome

Just follow the program to find Palindrome  in java: import java.io.BufferedReader; import java.io.InputStreamReader; public class Palindrome {     public static void main(String[] args) throws Exception {    BufferedReader br = new BufferedReader(new InputStreamReader(System.in));      String s1 = new String();          s1 =br.readLine();          s1 = s1.toLowerCase();     String s2 = new StringBuffer(s1).reverse().toString();          if(s1.equals(s2)){         System.out.println("Palindrome");     }else          System.out.println("Not Palindrome");      } }

Read or input form user in Java using BufferedReader

 BufferedReader use to read text from a character-input stream, buffering characters so as to provide for the efficient reading of characters, arrays, and lines.The buffer size may be specified, or the default size may be used. The default is large enough for most purposes. In Java  BufferedReader is a efficient method to read an input. Here given a short example to read a string from user and print it: package palindrome; import java.io.BufferedReader; import java.io.InputStreamReader; public class  inputExample   {     public static void main(String[] args) throws Exception {    BufferedReader br = new BufferedReader(new InputStreamReader(System.in));     String s = new String();       s =br.readLine();     System.out.println(s);     } }

Difference between Scanner vs. BufferedReader

BufferedReader Read text from a character-input stream, buffering characters so as to provide for the efficient reading of characters, arrays, and lines. The buffer size may be specified, or the default size may be used. The default is large enough for most purposes. Where Scanner is a simple text scanner which can parse primitive types and strings using regular expressions. A Scanner breaks its input into tokens using a delimiter pattern, which by default matches whitespace. The resulting tokens may then be converted into values of different types using the various next methods. Scanner is used for parsing tokens from the contents of the stream while BufferedReader just reads the stream and does not do any special parsing. In currently latest JDK6 release/build, the Scanner has a littler buffer (1KB char buffer) as opposed to the BufferedReader (8KB byte buffer), but it's more than enough.As to the choice, use the Scanner if you want to parse the file, use th...

Difference Between Function and Method

Each language has its own lexicon of terms with special meaning. In C Programming Language, the word Function means a program routine. In Java, the term Function does not have any special meaning. Whereas Method means one of the routines that forms the implementation of a class. First let we know what is Function? A function is a piece of reuseable code that is called by name. In C or C++ we used to say function to a reusable code. It can be passed data to operate on (arguments / parameters) and can optionally return a result. Function is a portion of code within a larger program, which performs a specific task and is relatively independent of the remaining code. So What is Method?? A method  is a piece of code that is called by name that is associated with an object. A method is almost identical to a function but it's purpose is generally to operate on the data contained within the component (class). Method is a function that is a member of a class. ...

Implementation of Artificial Intelligent

Artificial Intelligent successfully been used and using in: Finance Robotics Games Medicines The Web and many more..

What exactly Artificial Intelligence or AI is?

Artificial intelligence or AI  is the intelligence of machines, any kind of machines that is programmable. And it is called AI program. Now another topics come here, that is "What is AI or Artificial Intelligence program is?" Yes, AI program is called Intelligent Agent.  Do you know what is Intelligent Agent? An intelligent agent is a system that perceives its environment and takes actions that maximize its chances of success. I will discuss more about intelligent agent in my next post. Stay with me. Thank You.

C++ Code of Bubble Sort

Bubble sort, often incorrectly referred to as sinking sort, is a simple sorting algorithm that works by repeatedly stepping through the list to be sorted, comparing each pair of adjacent items and swapping them if they are in the wrong order. Here is the C++ implantation of Bubble sort #include <iostream> using namespace std; int main() { int i,j, n; cout<< "How much number you will sort?" << endl; cin>>n; int a[n]; for(int x=1; x<=n;x++) { cout<< "Enter "<< " Number " << x <<": " << endl; cin>>a[x]; } for(int i=1; i<=n;i++) for(int j=i+1; j<=n;j++) { if (a[i]>a[j]){ int temp; temp = a[i]; a[i]=a[j]; a[j]=temp; } } cout<< "Sorted numbers are:" << endl; for(int x=1; x<=n;x++) { cout<< a[x] << ...

Integer Numbers in Programming Language

An integer variable may be defined to be of type short , int , or long . The only difference is that an int uses more or at least the same number of bytes as a short , and a long uses more or at least the same number of bytes as an int . For example, on the author’s PC, a short uses 2 bytes, an int also 2 bytes, and a long 4 bytes. short age = 20; int salary = 65000; long price = 4500000; By default, an integer variable is assumed to be signed (i.e., have a signed representation so that it can assume positive as well as negative values). However, an integer can be defined to be unsigned by using the keyword unsigned in its definition. The keyword signed is also allowed but is redundant. unsigned short age = 20; unsigned int salary = 65000; unsigned long price = 4500000; A literal integer (e.g., 1984 ) is always assumed to be of type int , unless it has an L or l suffix, in which case it is treated as a long . Also, a literal integer can be specified to be...

Memory, Memory Address in Programming Language

A computer provides a Random Access Memory (RAM) for storing executable program code as well as the data the program manipulates. This memory can be thought of as a contiguous sequence of bits , each of which is capable of storing a binary digit (0 or 1). Typically, the memory is also divided into groups of 8 consecutive bits (called bytes ). The bytes are sequentially addressed. Therefore each byte can be uniquely identified by its address. Figure: Bits and bytes in memory. The C++ compiler generates executable code which maps data entities to memory locations. For example, the variable definition int salary = 65000; causes the compiler to allocate a few bytes to represent salary . The exact number of bytes allocated and the method used for the binary representation of the integer depends on the specific C++ implementation, but let us say two bytes encoded as a 2’s complement integer. The compiler uses the address of the first byte at which salary is alloca...

Comments in Programming Language

A comment is a piece of descriptive text which explains some aspect of a program. Program comments are totally ignored by the compiler and are only intended for human readers. C++ provides two types of comment delimiters: · Anything after // (until the end of the line on which it appears) is considered a comment. · Anything enclosed by the pair /* and */ is considered a comment. Comments should be used to enhance (not to hinder) the readability of a program. The following two points, in particular, should be noted: · A comment should be easier to read and understand than the code which it tries to explain. A confusing or unnecessarily-complex comment is worse han no comment at all. · Over-use of comments can lead to even less readability. A program which contains so much comment that you can hardly see the code can by no means be considered readable. · Use of descriptive names for variables and other entities in a program, and proper indentation of ...

Variables In Programming Language

A variable is a symbolic name for a memory location in which data can be stored and subsequently recalled. Variables are used for holding data values so that they can be utilized in various computations in a program. All variables have two important attributes: · A type which is established when the variable is defined (e.g., integer, real, character). Once defined, the type of a C++ variable cannot be changed. · A value which can be changed by assigning a new value to the variable. The kind of values a variable can assume depends on its type. For example, an integer variable can only take integer values (e.g., 2, 100, -12).

Compilation Process of a C++ Program

Compiling a C++ program involves a number of steps (most of which are transparent to the user): · First, the C++ preprocessor goes over the program text and carries out theinstructions specified by the preprocessor directives (e.g., #include ). The result is a modified program text which no longer contains any directives. · Then, the C++ compiler translates the program code. The compiler may be a true C++ compiler which generates native (assembly or machine) code, or just a translator which translates the code into C. In the latter case, the resulting C code is then passed through a C compiler to produce native object code. In either case, the outcome may be incomplete due to the program referring to library routines which are not defined as a part of the program. For example, Listing 1.1 refers to the << operator which is actually defined in a separate IO library. · Finally, the linker completes the object code by linking it with the object code of any lib...

A simple C++ Program and Explanation of it

A simple C++ Program and Explanation of it: #include <iostream.h> int main (void) { cout << "Hello World\n"; }             #include <iostream.h> 1.       This line uses the preprocessor directive #include to include the contents of the header file iostream.h in the program. Iostream.h is a standard C++ header file and contains definitions for input and output. int main (void) 2.       This line defines a function called main . A function may have zero or more parameters ; these always appear after the function name, between a pair of brackets. The word void appearing between the brackets indicates that main has no parameters. A function may also have a return type ; this always appears before the function name. The return type for main is int (i.e., an integer number). All C++ programs must have exactly one main function. Program...

Polymorphism, Encapsulation, and Inheritance Work Together

Polymorphism, Encapsulation, and Inheritance Work Together: When properly applied, polymorphism, encapsulation, and inheritance combine to produce a programming environment that supports the development of far more robust and scaleable programs than does the process-oriented model. A well-designed hierarchy of classes is the basis for reusing the code in which you have invested time and effort developing and testing. Encapsulation allows you to migrate your implementations over time without breaking the code that depends on the public interface of your classes. Polymorphism allows you to create clean, sensible, readable, and resilient code. Of the two real-world examples, the automobile more completely illustrates the power of object-oriented design. Dogs are fun to think about from an inheritance standpoint, but cars are more like programs. All drivers rely on inheritance to drive different types (subclasses) of vehicles. Whether the vehicle is a school bus, a Mercedes sedan, a...

Polymorphism In JAV A Programming Languagea

Polymorphism In JAV A Programming Language: Polymorphism (from the Greek, meaning “many forms”) is a feature that allows one interface to be used for a general class of actions. The specific action is determined by the exact nature of the situation. Consider a stack (which is a last-in, first-out list). You might have a program that requires three types of stacks. One stack is used for integer values, one for floating-point values, and one for characters. The algorithm that implements each stack is the same, even though the data being stored differs. In a non– object-oriented language, you would be required to create three different sets of stack routines, with each set using different names. However, because of polymorphism, in Java you can specify a general set of stack routines that all share the same names. More generally, the concept of polymorphism is often expressed by the phrase “one interface, multiple methods.” This means that it is possible to design a generic inter...

Inheritance in JAVA Programming Language

Inheritance in JAVA Programming Language: Inheritance is the process by which one object acquires the properties of another object. This is important because it supports the concept of hierarchical classification. As mentioned earlier, most knowledge is made manageable by hierarchical (that is, top-down) classifications. For example, a Golden Retriever is part of the classification dog, which in turn is part of the mammal class, which is under the larger class animal. Without the use of hierarchies, each object would need to define all of its characteristics explicitly. However, by use of inheritance, an object need only define those qualities that make it unique within its class. It can inherit its general attributes from its parent. Thus, it is the inheritance mechanism that makes it possible for one object to be a specific instance of a more general case. Let’s take a closer look at this process. Most people naturally view the world as made up of objects that are re...

Encapsulation in JAVA Programming Language

Encapsulation: Encapsulation is the mechanism that binds together code and the data it manipulates, and keeps both safe from outside interference and misuse. One way to think about encapsulation is as a protective wrapper that prevents the code and data from being arbitrarily accessed by other code defined outside the wrapper. Access to the code and data inside the wrapper is tightly controlled through a well-defined interface. To relate this to the real world, consider the automatic transmission on an automobile. It encapsulates hundreds of bits of information about your engine, such as how much you are accelerating, the pitch of the surface you are on, and the position of the shift lever. You, as the user, have only one method of affecting this complex encapsulation: by moving the gear-shift lever. You can’t affect the transmission by using the turn signal or windshield wipers, for example. Thus, the gear-shift lever is a well-defined (indeed, unique) interface to the transm...