Topmost 18 Prolog Interview Questions

5
http://career.guru99.com/ Top 18 Prolog Interview Questions 1) Explain what is prolog programming language? What is it based on? Prolog is designed for Artificial Intelligence, and it deals with the declarative and logical aspects. Prolog is a logic programming and is based on three attributes- Facts, Rules of Inference and Questions. Facts are the known truths, rules determine how new information can be inferred from these facts, and questions search for answers according to the facts and rules. 2) Name the sector where prolog programming language is used? Prolog programming language is used in sectors like Automated reasoning Machine learning Robot planning Problem solving Natural language understanding Intelligent data base retrieval Expert systesm 3) Explain why PROLOG language is stated as a procedural language? In Prolog, procedures are referred as predicate. It is also known as a procedural language due to the two unusual aspects of prolog like prolog is non deterministic and has assign- once variables. 4) Explain what is List structures in Prolog? A Prolog list is referred as an ordered sequence of elements of arbitrary length. Here the elements are variables, constant, structures, including other lists. 5) Why in prolog it is said that Program and Data are the same thing? In Prolog, data and program both are implemented as the bunch of trees. There is no difference between a rule that causes operations to happen and a rule that just gives back a data value. 1 / 5

description

Topmost 18 Prolog Interview Questions

Transcript of Topmost 18 Prolog Interview Questions

  • http://career.guru99.com/

    Top 18 Prolog Interview Questions1) Explain what is prolog programming language? What is it based on?

    Prolog is designed for Artificial Intelligence, and it deals with the declarative and logical aspects.Prolog is a logic programming and is based on three attributes- Facts, Rules of Inference andQuestions. Facts are the known truths, rules determine how new information can be inferredfrom these facts, and questions search for answers according to the facts and rules.

    2) Name the sector where prolog programming language is used?

    Prolog programming language is used in sectors like

    Automated reasoningMachine learningRobot planningProblem solvingNatural language understandingIntelligent data base retrievalExpert systesm

    3) Explain why PROLOG language is stated as a procedural language?

    In Prolog, procedures are referred as predicate. It is also known as a procedural language dueto the two unusual aspects of prolog like prolog is non deterministic and has assign- oncevariables.

    4) Explain what is List structures in Prolog?

    A Prolog list is referred as an ordered sequence of elements of arbitrary length. Here theelements are variables, constant, structures, including other lists.

    5) Why in prolog it is said that Program and Data are the same thing?

    In Prolog, data and program both are implemented as the bunch of trees. There is no differencebetween a rule that causes operations to happen and a rule that just gives back a data value.

    1 / 5

  • http://career.guru99.com/

    6) Mention who is referred as a Member in Prolog?

    Member is a Prolog tool that is used for configuring lists and to introduce the idea of recursingdown lists.

    7) Mention what is the difference between = and = = in Prolog?

    The = operator in Prolog is actually a predicate that stands for unification. This operator = =means the two terms are not identical. Unification does not take place even if this succeeds.

    8) Explain why matching variable is important in Prolog? What is the method to matchvariables?

    In Prolog, in order to process the elements of a list, we have to match them to variables. Themethod for doing is

    We get the head by matching it to a variableBy calling a predicate with the variable, it processes the headUntil you get an empty list repeat the above steps

    9) Explain what is recursion in Prolog?

    In any language, a function that can call itself until the goal has been succeed is referred asrecursion. In Prolog, recursion happens when a predicate contains a goal that refers to itself.

    10) Explain what is SWI-Prolog?

    SWI-Prolog is a free prolog compiler licensed under GPL, targeting primarily the research andeducation.

    11) Explain what is backtracking in Prolog?

    In Prolog, backtracking is a process adopted by Prolog. When a sub-goal fails in Prolog, theProlog system moves its steps backwards to the previous goal and tries to re-satisfy it.Backtracking enables Prolog to find all alternative solutions to a given query.

    12) Mention what is the difference between Prolog and normal programming language?

    Prolog: It is a declarative programming language which means that you have to

    2 / 5

  • http://career.guru99.com/

    specify the goals, but not the strategy to reach the goal. It figures it out on its own.Normal Programming language: Languages like C/C++/Java/Python are imperative(IP) languages that does specify instructions of how to reach some goal, but leaving thereal goal implicit

    13) Mention what is Cut (!) in Prolog and what is the advantage of Cut and Negation?

    Cut function is used in Prolog when you want to restrict Prolog from backtracking into certainchoicepoints or subgoals, either because the alternatives would give wrong solutions or forefficiency reasons.

    Advantage of using cut in Prolog is

    Through cut, we can often improve the efficiency of the programWe can specify exclusive rules using cut

    14) Mention why you have to use is instead of = in Prolog when it comes to applyingcalculation logic?

    = triggers unification in Prologis triggers arithmetic evaluation in Prolog

    So, in Prolog you cannot use = when you want to calculate something like 2+4=6, but insteadyou have to use 2+4 is 6.

    15) Explain where you use \+ operator in Prolog?

    Operator \+ can be used to negate goals; these are either sub-goals in the body of a rule or sub-goals of a query. We cannot negate facts or the heads of rules.

    16) In cuts what is the Parent goal in Prolog?

    When running the subgoals in a rules body, the parent goal is referred to the goal that causedthe matching of the head of the current rule.

    17) Explain with an example what is Setof predicate in Prolog?

    In Prolog, Setof predicate can be used to find out all the solutions of a predicate. Forexample, you have this database:

    Guru99 (SAP, Testing Tools)

    Guru99 (PHP, Perl)

    And if you want to find the solutions of Guru99 (X, Y). We can enter

    3 / 5

  • http://career.guru99.com/

    Setof ([ X,Y] , Guru99 (X,Y), Z).

    Z = [[ SAP , Testing Tools], [ PHP, Perl] ]

    18) Explain what is the difference between bagof/3 and setof/3 predicate in Prolog?

    Setof/3 is similar to bagof/3 and the difference between is that bagof/3 leaves all repeatedsolutions while setof/3 removes them.

    -------------------------------------------------------------------------------------------------------------------------------

    Guru99 provides FREE ONLINE TUTORIAL on Various courses like

    PHP Java Linux Apache

    Perl SQL VB Script JavaScript

    Accounting Ethical Hacking Cloud Computing Jmeter

    Manual Testing QTP Selenium Test Management

    Load Runner Quality Center Mobile Testing Live SeleniumProject

    Enterprise Testing Live Testing Project Sap & All Modules

    -------------------------------------------------------------------------------------------------------------------------------

    4 / 5

  • http://career.guru99.com/

    Copyrighted Material

    Powered by TCPDF (www.tcpdf.org)

    5 / 5