*p++ vs. (*p)++ *p++ means *(p++) ++ binds to p , not to *p ++ will increment "p," not "*p," which is the thing that "p" points to The value of the expression *p++ is the value that p pointed to before being incremented ( *p ) Two useful charts Pointer arithmetic notes (~pointer~) += (~number~); means (~pointer~) += ~number~) * sizeof((~type~)); Pointer arithmetic addition adds multiples of the type size to the memory address Ex. If p is a pointer to an integer, then p += 1 means p += 1 * sizeof(int) (~pointer name~) + 1 points to the next object in memory (returns a pointer to the next element) (~pointer name~) + i points to the i -th object beyond (~pointer name~) in memory (~pointer name~) += i increments (~pointer name~) to point to i elements beyond itself Types of valid pointer arithmetic Adding an integer to a pointer Subtracting 2 pointers (in the same array) Comparing...
Standard search problems Solution to a standard search problem: a plan Use a search algorithm to find the plan and solve the search problem Search algorithms are performed on the search tree (of the problem) to find the solution to the search problem All search algorithms follow the same algorithm, but just use a different data structures for the fringe Types of standard searches ➤ UNINFORMED SEARCH uninformed search - a search that does not know information about the goal's location Types of uninformed searches Depth first search (DFS) - a search strategy that expands the deepest node first Implementation : uses a last-in-first-out (LIFO) stack as the fringe Time complexity : $O(b^m)$, for a finite tree where $m$ is the maximum depth and $b$ is the branching factor Space complexity : $O(bm)$ DFS expands only the nodes on a single path from the deepest level to the root Breadth first search (BFS) - a search strategy in ...
adversarial search problems - games In adversarial search, the agent maximizes utility rather than minimizing cost (which is done for standard search problems) Solution to adversarial search problem: strategy strategy - the recommended best possible move given some configuration of the agent(s) and their opponent(s) game tree - a tree where the nodes are game states and edges are moves Types of adversarial search problems zero-sum games - deterministic, turn-taking, two-player games (pure competition between the two players) In zero-sum games, the sum of the utilities of the game agents is zero (i.e. equal and opposite utilities) stochastic games - games with probabilistic outcomes cooperative games - games in which players have common interests and utility function general games - games in which agents have independent utilities (cooperation, indifference, competition, etc. are all possible) Components of an adversarial sear...