Expert Solution & Answer
Book Icon
Chapter 12, Problem 17SA

Explanation of Solution

The program has been explained in the in-lined comments:

#include <iostream> 

using namespace std; 

int main()  

{  

    //delcare a list and initialize it

    //with an array of 6 elements 

    int numList[6] = {25, 37, 62, 78, 92, 13};

    //create a pointer to the list -

    //the base address of the list is assigned

    //to the pointer

    int *listPtr = numList;

    //a new pointer is declared and is assigned

    //an address 2 int positions incremented i.e

    //it points to the 3rd position in the array

    //or numlist[2] which is the value 62

    int *temp = listPtr + 2;

    //declare an int variable

    int num;

    //assign value of the memory address pointed to

    //by listPtr with the arithmetic expression on the

    //RHS of the assignment operator

    //RHS = *(listPtr + 1) - *listPtr = 

    //numList[1] - numList[0] = 37-25 = 12

    //since listPtr is numList[0] so now the array elements

    //are {12, 37, 62, 78, 92, 13}

    *listPtr = *(listPtr + 1) - *listPtr;

    //listPtr is incremented and now points to numList[1]

    // i.e. 37

    listPtr++;

    //num is assigned the value pointed to by temp which is

    //numList[2] i.e. 62

    num = *temp;

    //temp is incrementedand now points to numList[3] 

    //i...

Blurred answer
Students have asked these similar questions
solve this questions for me .
a) first player is the minimizing player. What move should be chosen?b) What nodes would not need to be examined using the alpha-beta pruning procedure?
Consider the problem of finding a path in the grid shown below from the position S to theposition G. The agent can move on the grid horizontally and vertically, one square at atime (each step has a cost of one). No step may be made into a forbidden crossed area. Inthe case of ties, break it using up, left, right, and down.(a) Draw the search tree in a greedy search. Manhattan distance should be used as theheuristic function. That is, h(n) for any node n is the Manhattan distance from nto G. The Manhattan distance between two points is the distance in the x-directionplus the distance in the y-direction. It corresponds to the distance traveled along citystreets arranged in a grid. For example, the Manhattan distance between G and S is4. What is the path that is found by the greedy search?(b) Draw the search tree in an A∗search. Manhattan distance should be used as the
Knowledge Booster
Background pattern image
Similar questions
SEE MORE QUESTIONS
Recommended textbooks for you
Text book image
C++ for Engineers and Scientists
Computer Science
ISBN:9781133187844
Author:Bronson, Gary J.
Publisher:Course Technology Ptr
Text book image
Systems Architecture
Computer Science
ISBN:9781305080195
Author:Stephen D. Burd
Publisher:Cengage Learning
Text book image
New Perspectives on HTML5, CSS3, and JavaScript
Computer Science
ISBN:9781305503922
Author:Patrick M. Carey
Publisher:Cengage Learning
Text book image
EBK JAVA PROGRAMMING
Computer Science
ISBN:9781337671385
Author:FARRELL
Publisher:CENGAGE LEARNING - CONSIGNMENT
Text book image
C++ Programming: From Problem Analysis to Program...
Computer Science
ISBN:9781337102087
Author:D. S. Malik
Publisher:Cengage Learning
Text book image
Programming Logic & Design Comprehensive
Computer Science
ISBN:9781337669405
Author:FARRELL
Publisher:Cengage