MIDTERM Preparation. CSS 343: Data Structures Algorithms, and Discrete Math II
|
|
- Ernest Austin
- 5 years ago
- Views:
Transcription
1 MIDTERM Preparation CSS 343: Data Structures Algorithms, and Discrete Math II The midterm is closed-book, closed-notes exam, except for a single sheet of letter-sized, double-sided hand-written or typed notes AND a basic calculator. If you are using typed notes, your font size has to be at least 10. You will submit your notes along with your midterm. You are responsible for creating your own set of notes. Total of 100 points, 120 minutes allowed time. Material covered : Chapter 15-17, 19, 20 in Carrano + lectures + assignments + other readings The actual midterm will have 5-10 questions similar to the questions below. You must attempt these questions yourself in preparing for the exam. Looking at the solutions will give you a false sense of security and will not help you in preparing for the exam. Trees T1. What is the minimum height of a binary tree with 0, 1, 2, 3, 5, 7, 10, 20, 100 nodes? Which of the trees above could be a perfect or full tree? Which of the trees above could be a complete tree? How many nodes does a full binary tree with height 8 have? The total number of nodes in a binary tree is 2 h - 1 Nodes Height (max nodes 1) 2 2 (max nodes 3) (max nodes 7) 7 3 1
2 10 4 (max nodes 15) 20 5 (max nodes 31) (max nodes 127) How about 10,000 nodes? 2 h - 1 >= h >= 9999 h >= log(9999) h >= 13.xx (2 13 is 8192) Minimum height is 14 Prefect or full tree has the maximum nodes possible, so trees with 1, 3 and 7 nodes is full. All of them could be complete, as long as we arrange the leaves properly. When height is 8, gives 255 T2. For the given binary tree below, print the order of nodes that will be visited for preorder, inorder and postorder traversal. Preorder (root, left subtree, right subtree): K, F, C, J, N, L, M, O Inorder (left subtree, root, right subtree): C, F, J, K, L, M, N, O Postorder (left subtree, right subtree, root): C, J, F, M, L, O, N, K T3. Explain the process for removing the node F for the tree above? Find inorder successor, which is J, and swap the node data with J. Since inorder successor was a leaf, we are done. T4. Starting from the initial tree, explain the process for removing K? 2
3 Find inorder successor, which is L, and swap the node data with K. Since the inorder successor has a right child, promote the right child to be the left child of N. T5. Explain tree sort algorithm. What are the different parts, what is its complexity for best-case and worst case. Put all elements from an array into a tree - best case O(n log n), worst case array already sorted O(n 2 ) Inorder traversal to get all items in order - O(n) Total complexity best case O(n log n + n) which is O(n log n), worst case O(n 2 + n) which is O(n 2 ) T6. Create a complete binary search tree with the following elements T7. Given an array representation of a tree with 100 elements, indexes 0 to 99 no free locations. For the item at index 25, what is the array index of its left child, right child and parent? Assuming that the tree has been constructed with only additions where each height was completely filled from left to right before constructing next level. If not, then the nodes can be anywhere and we have to look it up in the table. left = 2 * parentindex + 1 right = 2 * parentindex + 2 parent = (left - 1) / 2 For index 25, parent at 12, left child at 51 and right child at 52 Huffman 3
4 H1. Given the following distribution of letters, create the Huffman tree. l: 0.03, i: 0.09, e: 0.17, f: 0.14, s: 0.17, b: 0.12, u: 0.13, t: 0.15 What is the average number of bits used to encode a symbol using this encoding? What is the bit representation for the letters: l, i, f, e What is the total number of bits needed to represent the word life? Sort smallest to largest and combine the two smallest in a tree. You should redraw the tree at each step which is not done below. [ The below solution put the heavier nodes on the right, which is not the convention we followed in class. If you were putting the heavier nodes on the left, you'd end up with the mirror image of the below tree. The visualization on puts heavier nodes on the right. I will make sure the question states whether heavier nodes should go on the left or right on the exam. If the question does not state a preference, you can do it either way ] l: 0.03, i: 0.09, b: 0.12, u: 0.13, f: 0.14, t: 0.15, e: 0.17, s: 0.17 Combine l(0.03) i(0.09) to get weight 0.12 b: 0.12, li: 0.12, u: 0.13, f: 0.14, t: 0.15, e: 0.17, s: 0.17 Combine b(0.12) li(0.12) to get weight 0.24 u: 0.13, f: 0.14, t: 0.15, e: 0.17, s: 0.17, bli: 0.24 Combine u(0.13) f(0.14) to get weight 0.27 t: 0.15, e: 0.17, s: 0.17, bli: 0.24, uf:
5 Combine t(0.15) e(0.17) to get weight 0.32 s: 0.17, bli: 0.24, uf: 0.27, te: 0.32 Combine s(0.17) bli(0.24) to get weight 0.41 uf: 0.27, te: 0.32, sbli: 0.41 Combine uf(0.27) te(0.32) to get weight 0.59 sbli: 0.41, ufte: 0.59 Combine sbli(0.41) ufte(0.59) to get weight 1 5
6 Label the edges with 0s and 1s to get all the encodings s: 00 b 010 l: 0110 i: 0111 u: 100 f: 101 t: 110 e: 111 What is the bit representation for the letters: l, i, f, e Spaces added for readability Total: 14 What is the average number of bits used to encode a symbol using this encoding? The average number of bits used to encode a symbol using this encoding is 6
7 l: 0.03, i: 0.09, b: 0.12, u: 0.13, f: 0.14, t: 0.15, e: 0.17, s: 0.17 s: 00 2 * b * l: * i: * u: * f: * t: * e: * 0.17 = = 2.95 Arithmetic Expressions AE1. Draw the corresponding trees representing prefix expressions and evaluate the result 1. + * * / * evaluate right to left when operator found, apply it to the operands and substitute result + * * *
8 * / * * / * * / * / * AE2. Convert the following infix expression to an algebraic expression tree: (a + b) * (c - d) / (e * f) * g / h Write the preordertraversal corresponding to Polish prefix notation 8
9 / * / * + a b - c d * e f g h Operator Overloading OO1. Assume that imaginary numbers are implemented via the class IN. Write the function signatures for the copy constructor, operator+, operator+= and operator= member functions. IN operator+(const IN &in) const; IN& operator+=(const IN &in); IN& operator=(const IN &in); Priority Queue PQ1. The STL implements priority queue. Given the below definition for a priority queue, write the code to insert 3 objects into the queue, and then remove each item and print it. using IntStr = pair < int, string >; priority_queue<intstr, vector<intstr>, greater<intstr>> pq; pq.push( make_pair(10, "a") ); pq.push( make_pair(30, "b") ); pq.push( make_pair(50, "c") ); while (!pq.empty()) { IntStr pair = pq.top(); pq.pop(); cout << pair.first << " " << pair.second << ", "; } // should print from smallest to largest because of greater // 10 a, 30 b, 50 c, Heap H1. For a maxheap, what is the complexity of the following operations? The heap property must be maintained. 1. Find smallest item 2. Find largest item 9
10 3. Remove smallest item 4. Remove largest item 5. Inserting an item that is smaller than all items in the tree 6. Inserting an item that is larger than all items in the tree Assuming the heap is implemented as an array 1. Find smallest item - last element O(n) - finding a small item is easy but smallest requires visiting all leaves which is about n/2 2. Find largest item - first element O(1) 3. Remove smallest item - finding smallest is O(n), removing it is O(1), but then we need to make the heap structure again by swapping it with the last item in the heap and calling heapify which is O(log n). Total O(n) 4. Remove largest item - swap largest with smallest and trickle down, O(log n) 5. Inserting an item that is smaller than all items in the tree - insert at last free spot, no bubble up required, O(1) 6. Inserting an item that is larger than all items in the tree - insert at last free spot, bubble up all the way to the root, O(log n) H2. Draw the maxheap tree structure and the array representation that results from the following order of insertions: 9, 15, 6, 1, 5, 7, 3, 50 (fixed: removed 2, 2019/02/06) 9 Insert 15 and bubble up
11 Insert 7 and bubble up
12 Insert 50 and bubble up H3: Remove 50 and then 15 from the heap created above. Draw the tree structure and the corresponding array representation Cannot remove 15, must remove 50 first and then 15 12
13 Swap 1 and 50, delete the node that now has 50 Trickle down 1: Swap with 15, Swap with Swap 15 with 3, delete the node that now has 15 Trickle down 3: Swap with 9, Swap with H4: Given the array below, show the steps to convert the array into a maxheap. Redraw the array every time a number changes or two number are swapped. Write out what is happening in each step
14 size is 9 Call heaprebuild starting from (size - 2) / 2 to 0, that is from 3 to 0. Index 0 is the first node that has a child Calling heaprebuild on index 3, corresponding to 40 Bigger child, 200, bis promoted replacing Calling heaprebuild on index 2, corresponding to 5 Bigger child, 100, is promoted replacing
15 Calling heaprebuild on index 1, corresponding to 20 Bigger child, 200, is promoted replacing 20 heaprebuild calls itself recursively since 20 now has a child of 40 which is bigger Bigger child, 40, is promoted replacing Calling heaprebuild on index 0, corresponding to 10 Bigger child, 200, is promoted replacing 10 heaprebuild calls itself recursively since 10 now has a child of 40 and 50 which are bigger Bigger child, 50, is promoted replacing
16 The array now represents heap. H5: Using the heap array above, show the steps to sort the array using heap sort. Redraw the array every time a number changes or two number are swapped. Write out what is happening in each step. The sorted section of the array is currently empty Swap index-0 with index-8 Trickle 20 down, swap with 100 Sorted section is just index Swap index-0 with index-7 Trickle 3 down, swap with 50, swap with 40 Sorted section is [7-8] Swap index-0 with index-6 16
17 Trickle 5 down, swap with 40, swap with 10 Sorted section is [6-8] Swap index-0 with index-5 Trickle 6 down, swap with 20 Sorted section is [5-8] Swap index-0 with index-4 Trickle 5 down, swap with 10 Sorted section is [4-8] Swap index-0 with index-3 Trickle 3 down, swap with 6 Sorted section is [3-8]
18 Swap index-0 with index-2 Trickle 3 down, swap with 5 Sorted section is [2-8] Swap index-0 with index-1 Sorted section is [1-8] Swap index-0 with index-0 Sorted section is [0-8] Graphs G1. For the graph below, list the order of nodes that will be visited by depth-first and breadth-first search algorithms, starting from 7. If there are any ties on what edge to process, break the ties using alphabetical/numerical order. 18
19 DFS: 7, 3, 1, 2, 5, 10, 6, 4, 8, 9, 13, 14, 11, 12 BFS: 7, 3, 4, 9, 11, 12, 1, 6, 8, 13, 2, 10, 14, 5 // Sanity check for BFS // Distance 0 edge: 7 // Distance 1 edge: 3, 4, 9, 11, 12 // Distance 2 edges: 1, 6, 8, 13 // Distance 3 edges: 2, 8, 10, 14 // Distance 4 edges: 5 G2. For the graph given below, write out the topological order of the vertices and describe the algorithm used. Remove vertex without any successors, add that to the topological list and then repeat. Not a unique solution K A O C N D L B (fixed 2019/02/06) G3. For the graph given below, use Prim's algorithm to create the minimum spanning tree and indicate the total length. Use 3 as your starting vertex. 19
20 The edge between 4-8 is not labelled, assuming 0 weight for that edge (fixed 2019/02/06) Edge Weight Total Weight: 21 20
21 G4. For the graph given below, find the shortest path from S to all the vertices using Dijkstra's algorithm. At each step, you must show what vertices are in the vertex set and what the current weight to each vertex is. Assume the graph below: vertex vertexse t A B C D E F G H S S INF INF INF INF INF A S,A 7 B S,A,B C E F S,A,B,C S,A,B,C, E S,A,B,C,E,F 7 9 G SABCEFG 8 H SABCEFGH Final Distances
22 G5. Given the graph below, assume the Dobreta-Craiova road has been removed. List the order of cities that will be visited by greedy search algorithm when starting from Timisiora and going to Bucharest. Dobreta-Craiova road has been removed. Greedy search will choose the city that has the shortest straight-line distance. Using Best-first search algorithm with f(u) set to straight line distance Add initial vertex to PQ OPEN while PQ is not empty w = top of queue if w is targetvertex, return add w to CLOSED list for each vertex u adjacent to w if u is not in CLOSED calculate f(u), push u to PQ OPEN with cost f(u) SORTED OPEN LIST : Timisoara(329) Next city: Timisoara Closed: Timisoara 22
23 Add to OPEN: Arad(366), Lugoj(244) SORTED OPEN LIST : Lugoj(244), Arad(366) Next city: Lugoj Closed: Lugoj Add to OPEN: Mehadia(241) -- Timisoara is closed, so not added SORTED OPEN LIST : Mehadia(241), Arad(366) Next city: Mehadia Closed: Mehadia Add to OPEN: Dobreta(242) -- Lugoj is closed, so not added SORTED OPEN LIST : Dobreta(242), Arad(366) Next city: Dobreta Closed: Dobreta Add to OPEN: none - road to Craiova removed, Mehadia closed SORTED OPEN LIST : Arad(366) Next city: Arad Closed: Arad Add to OPEN: Zerind(374), Sibiu(253) -- Timisoara is closed, so not added SORTED OPEN LIST : Sibiu(253), Zerind(374) Next city: Sibiu Closed: Sibiu Add to OPEN: Rimnicu Vilcea(193), Fagaras(178), Oradea(380) SORTED OPEN LIST : Fagaras(178), Rimnicu Vilcea(193), Zerind(374), Oradea(380) Next city: Fagaras Close: Fagaras Add to OPEN: Bucharest(0) SORTED OPEN LIST : Bucharest(0), Rimnicu Vilcea(193), Zerind(374), Oradea(380) Next city: Bucharest Found destination - not the shortest path, but good enough The path found was Timisoara-Arad-Sibiu-Fagaras-Bucharest. The shorter path is Timisoara-Arad-Sibiu-Rimnicu-Pitesti-Bucharest G6. Given the graph above, make the following changes 23
24 1. Pitesti-Bucharest road is now 200 instead of The straight line distance from Pitesti to Bucharest is 198 instead of 98 Starting from Arad, list the order of the that will be explored by the A* search algorithm A* search will choose the city based on priority. Using Best-first search algorithm with f(u) set to distance to get to the city PLUS estimated distance from that city to destination Add initial vertex to PQ OPEN while PQ is not empty w = top of queue if w is targetvertex, return add w to CLOSED list for each vertex u adjacent to w if u is not in CLOSED calculate f(u), push u to PQ OPEN with cost f(u) SORTED OPEN LIST : Arad(329=0+329) Next city: Arad, distance traveled 0 Closed: Arad Add to OPEN: Zerind(449= ), Sibiu(393= ), Timisoara(447= ) SORTED OPEN LIST : Sibiu(393), Timisoara(447), Zerind(449) Next city: Sibiu,, distance traveled 140 Closed: Sibiu Add to OPEN: Oradea(671= ), Fagaras(417= ), Rimnicu(413= ) SORTED OPEN LIST : Rimnicu(413), Fagaras(417), Timisoara(447), Zerind(449), Oradea(671) Next city: Rimnicu, distance traveled 220 Closed: Rimnicu Add to OPEN: Craiova(526= ), Pitesti(515= ) Pitesti road estime 198 instead of 98, so Pitesti has lower priority SORTED OPEN LIST : Fagaras(417), Timisoara(447), Zerind(449), Bucharest(450), Pitesti(515), Craiova(526), Oradea(671) Next city: Fagaras, distance traveled 239 Closed: Fagaras 24
25 Add to OPEN: Bucharest(450= ) SORTED OPEN LIST : Timisoara(447), Zerind(449), Bucharest(450), Pitesti(515), Craiova(526), Oradea(671) Next city: Timisoara... Next city: Zerind... Next city: Bucharest Target city found, distance traveled 450 A* does find the shortest path Arad-Sibiu-Fagaras-Bucharest, but explores far away options like Zerind because the estimate is always underestimating the required distance. Balanced Trees B1. For the 2-3 given below, insert the following elements one by one and draw the tree after each insertion:
26 B2. For the tree given below, insert the following elements one by one and draw the tree after each insertion. Use preemptive split if needed:
27 B3. For the AVL tree given below, insert the following elements one by one and draw the tree after each insertion
28 General S1. Who is Mr Landau? How many hands did he shake? What was served at the dinner party? 28
29 29
Introduction to Artificial Intelligence. Informed Search
Introduction to Artificial Intelligence Informed Search Bernhard Beckert UNIVERSITÄT KOBLENZ-LANDAU Winter Term 2004/2005 B. Beckert: KI für IM p.1 Outline Best-first search A search Heuristics B. Beckert:
More informationInformed Search and Exploration
Ch. 03 p.1/47 Informed Search and Exploration Sections 3.5 and 3.6 Ch. 03 p.2/47 Outline Best-first search A search Heuristics, pattern databases IDA search (Recursive Best-First Search (RBFS), MA and
More informationCSS 343 Data Structures, Algorithms, and Discrete Math II. Graphs II. Yusuf Pisan
CSS 343 Data Structures, Algorithms, and Discrete Math II Graphs II Yusuf Pisan 2 3 Shortest Path: Dijkstra's Algorithm Shortest path from given vertex to all other vertices Initial weight is first row
More informationInformed search algorithms
Informed search algorithms Chapter 4, Sections 1 2 Chapter 4, Sections 1 2 1 Outline Best-first search A search Heuristics Chapter 4, Sections 1 2 2 Review: Tree search function Tree-Search( problem, fringe)
More informationInformed Search and Exploration
Ch. 03b p.1/51 Informed Search and Exploration Sections 3.5 and 3.6 Nilufer Onder Department of Computer Science Michigan Technological University Ch. 03b p.2/51 Outline Best-first search A search Heuristics,
More informationCS486/686 Lecture Slides (c) 2015 P.Poupart
1 2 Solving Problems by Searching [RN2] Sec 3.1-3.5 [RN3] Sec 3.1-3.4 CS486/686 University of Waterloo Lecture 2: May 7, 2015 3 Outline Problem solving agents and search Examples Properties of search algorithms
More informationCS486/686 Lecture Slides (c) 2014 P.Poupart
1 2 1 Solving Problems by Searching [RN2] Sec 3.1-3.5 [RN3] Sec 3.1-3.4 CS486/686 University of Waterloo Lecture 2: January 9, 2014 3 Outline Problem solving agents and search Examples Properties of search
More informationSolving Problems by Searching
Solving Problems by Searching CS486/686 University of Waterloo Sept 11, 2008 1 Outline Problem solving agents and search Examples Properties of search algorithms Uninformed search Breadth first Depth first
More informationInformed search algorithms. Chapter 4, Sections 1 2 1
Informed search algorithms Chapter 4, Sections 1 2 Chapter 4, Sections 1 2 1 Outline Best-first search A search Heuristics Chapter 4, Sections 1 2 2 Review: Tree search function Tree-Search( problem, fringe)
More informationCOMP219: Artificial Intelligence. Lecture 7: Search Strategies
COMP219: Artificial Intelligence Lecture 7: Search Strategies 1 Overview Last time basic ideas about problem solving; state space; solutions as paths; the notion of solution cost; the importance of using
More informationCOMP9414/ 9814/ 3411: Artificial Intelligence. 5. Informed Search. Russell & Norvig, Chapter 3. UNSW c Alan Blair,
COMP9414/ 9814/ 3411: Artificial Intelligence 5. Informed Search Russell & Norvig, Chapter 3. COMP9414/9814/3411 15s1 Informed Search 1 Search Strategies General Search algorithm: add initial state to
More informationOverview. Path Cost Function. Real Life Problems. COMP219: Artificial Intelligence. Lecture 10: Heuristic Search
COMP219: Artificial Intelligence Lecture 10: Heuristic Search Overview Last time Depth-limited, iterative deepening and bi-directional search Avoiding repeated states Today Show how applying knowledge
More informationArtificial Intelligence, CS, Nanjing University Spring, 2018, Yang Yu. Lecture 3: Search 2.
Artificial Intelligence, CS, Nanjing University Spring, 2018, Yang Yu Lecture 3: Search 2 http://cs.nju.edu.cn/yuy/course_ai18.ashx Previously... function Tree-Search( problem, fringe) returns a solution,
More informationCOMP219: Artificial Intelligence. Lecture 10: Heuristic Search
COMP219: Artificial Intelligence Lecture 10: Heuristic Search 1 Class Tests Class Test 1 (Prolog): Tuesday 8 th November (Week 7) 13:00-14:00 LIFS-LT2 and LIFS-LT3 Class Test 2 (Everything but Prolog)
More informationSearching and NetLogo
Searching and NetLogo Artificial Intelligence @ Allegheny College Janyl Jumadinova September 6, 2018 Janyl Jumadinova Searching and NetLogo September 6, 2018 1 / 21 NetLogo NetLogo the Agent Based Modeling
More informationCOMP219: Artificial Intelligence. Lecture 10: Heuristic Search
COMP219: Artificial Intelligence Lecture 10: Heuristic Search 1 Class Tests Class Test 1 (Prolog): Friday 17th November (Week 8), 15:00-17:00. Class Test 2 (Everything but Prolog) Friday 15th December
More informationInformed search methods
CS 2710 Foundations of AI Lecture 5 Informed search methods Milos Hauskrecht milos@pitt.edu 5329 Sennott Square Announcements Homework assignment 2 is out Due on Tuesday, September 19, 2017 before the
More informationArtificial Intelligence. Informed search methods
Artificial Intelligence Informed search methods In which we see how information about the state space can prevent algorithms from blundering about in the dark. 2 Uninformed vs. Informed Search Uninformed
More informationThe ADT priority queue Orders its items by a priority value The first item removed is the one having the highest priority value
The ADT priority queue Orders its items by a priority value The first item removed is the one having the highest priority value 1 Possible implementations Sorted linear implementations o Appropriate if
More informationPROBLEM SOLVING AND SEARCH IN ARTIFICIAL INTELLIGENCE
Artificial Intelligence, Computational Logic PROBLEM SOLVING AND SEARCH IN ARTIFICIAL INTELLIGENCE Lecture 3 Informed Search Sarah Gaggl Dresden, 22th April 2014 Agenda 1 Introduction 2 Uninformed Search
More informationArtificial Intelligence: Search Part 2: Heuristic search
Artificial Intelligence: Search Part 2: Heuristic search Thomas Trappenberg January 16, 2009 Based on the slides provided by Russell and Norvig, Chapter 4, Section 1 2,(4) Outline Best-first search A search
More informationInformed Search and Exploration
Ch. 04 p.1/39 Informed Search and Exploration Chapter 4 Ch. 04 p.2/39 Outline Best-first search A search Heuristics IDA search Hill-climbing Simulated annealing Ch. 04 p.3/39 Review: Tree search function
More informationProblem solving and search
Problem solving and search Chapter 3 Chapter 3 1 Outline Problem-solving agents Problem types Problem formulation Example problems Uninformed search algorithms Informed search algorithms Chapter 3 2 Restricted
More informationCS:4420 Artificial Intelligence
CS:4420 Artificial Intelligence Spring 2018 Informed Search Cesare Tinelli The University of Iowa Copyright 2004 18, Cesare Tinelli and Stuart Russell a a These notes were originally developed by Stuart
More informationAlgorithm. December 7, Shortest path using A Algorithm. Phaneendhar Reddy Vanam. Introduction. History. Components of A.
December 7, 2011 1 2 3 4 5 6 7 The A is a best-first search algorithm that finds the least cost path from an initial configuration to a final configuration. The most essential part of the A is a good heuristic
More informationUpcoming ACM Events Linux Crash Course Date: Time: Location: Weekly Crack the Coding Interview Date:
Upcoming ACM Events Linux Crash Course Date: Oct. 2nd and 3rd Time: 1:15 pm - 3:15 pm Location: UW1-210 (10/02) and UW1-221 (10/03) Weekly Crack the Coding Interview Date: Weekly Fridays from Oct. 5th
More informationCOSC 2007 Data Structures II Final Exam. Part 1: multiple choice (1 mark each, total 30 marks, circle the correct answer)
COSC 2007 Data Structures II Final Exam Thursday, April 13 th, 2006 This is a closed book and closed notes exam. There are total 3 parts. Please answer the questions in the provided space and use back
More informationComputer Science E-22 Practice Final Exam
name Computer Science E-22 This exam consists of three parts. Part I has 10 multiple-choice questions that you must complete. Part II consists of 4 multi-part problems, of which you must complete 3, and
More informationCOSC343: Artificial Intelligence
COSC343: Artificial Intelligence Lecture 18: Informed search algorithms Alistair Knott Dept. of Computer Science, University of Otago Alistair Knott (Otago) COSC343 Lecture 18 1 / 1 In today s lecture
More informationRoute planning / Search Movement Group behavior Decision making
Game AI Where is the AI Route planning / Search Movement Group behavior Decision making General Search Algorithm Design Keep a pair of set of states: One, the set of states to explore, called the open
More informationTREES. Trees - Introduction
TREES Chapter 6 Trees - Introduction All previous data organizations we've studied are linear each element can have only one predecessor and successor Accessing all elements in a linear sequence is O(n)
More informationCSE100 Practice Final Exam Section C Fall 2015: Dec 10 th, Problem Topic Points Possible Points Earned Grader
CSE100 Practice Final Exam Section C Fall 2015: Dec 10 th, 2015 Problem Topic Points Possible Points Earned Grader 1 The Basics 40 2 Application and Comparison 20 3 Run Time Analysis 20 4 C++ and Programming
More informationCS414-Artificial Intelligence
CS414-Artificial Intelligence Lecture 6: Informed Search Algorithms Waheed Noor Computer Science and Information Technology, University of Balochistan, Quetta, Pakistan Waheed Noor (CS&IT, UoB, Quetta)
More information7.1 Introduction. A (free) tree T is A simple graph such that for every pair of vertices v and w there is a unique path from v to w
Chapter 7 Trees 7.1 Introduction A (free) tree T is A simple graph such that for every pair of vertices v and w there is a unique path from v to w Tree Terminology Parent Ancestor Child Descendant Siblings
More informationOptimal Control and Dynamic Programming
Optimal Control and Dynamic Programming SC Q 7- Duarte Antunes Outline Shortest paths in graphs Dynamic programming Dijkstra s and A* algorithms Certainty equivalent control Graph Weighted Graph Nodes
More informationInformed Search Algorithms. Chapter 4
Informed Search Algorithms Chapter 4 Outline Informed Search and Heuristic Functions For informed search, we use problem-specific knowledge to guide the search. Topics: Best-first search A search Heuristics
More informationInformed (heuristic) search (cont). Constraint-satisfaction search.
CS 1571 Introduction to AI Lecture 5 Informed (heuristic) search (cont). Constraint-satisfaction search. Milos Hauskrecht milos@cs.pitt.edu 539 Sennott Square Administration PS 1 due today Report before
More informationProblem solving and search
Problem solving and search Chapter 3 Chapter 3 1 How to Solve a (Simple) Problem 7 2 4 1 2 5 6 3 4 5 8 3 1 6 7 8 Start State Goal State Chapter 3 2 Introduction Simple goal-based agents can solve problems
More informationInformed Search. Topics. Review: Tree Search. What is Informed Search? Best-First Search
Topics Informed Search Best-First Search Greedy Search A* Search Sattiraju Prabhakar CS771: Classes,, Wichita State University 3/6/2005 AI_InformedSearch 2 Review: Tree Search What is Informed Search?
More informationPEAS: Medical diagnosis system
PEAS: Medical diagnosis system Performance measure Patient health, cost, reputation Environment Patients, medical staff, insurers, courts Actuators Screen display, email Sensors Keyboard/mouse Environment
More informationPlanning, Execution & Learning 1. Heuristic Search Planning
Planning, Execution & Learning 1. Heuristic Search Planning Reid Simmons Planning, Execution & Learning: Heuristic 1 Simmons, Veloso : Fall 2001 Basic Idea Heuristic Search Planning Automatically Analyze
More informationBinary Trees, Binary Search Trees
Binary Trees, Binary Search Trees Trees Linear access time of linked lists is prohibitive Does there exist any simple data structure for which the running time of most operations (search, insert, delete)
More informationSolving Problems using Search
Solving Problems using Search Artificial Intelligence @ Allegheny College Janyl Jumadinova September 11, 2018 Janyl Jumadinova Solving Problems using Search September 11, 2018 1 / 35 Example: Romania On
More informationAGENTS AND ENVIRONMENTS. What is AI in reality?
AGENTS AND ENVIRONMENTS What is AI in reality? AI is our attempt to create a machine that thinks (or acts) humanly (or rationally) Think like a human Cognitive Modeling Think rationally Logic-based Systems
More informationInformed Search (Ch )
Informed Search (Ch. 3.5-3.6) Informed search In uninformed search, we only had the node information (parent, children, cost of actions) Now we will assume there is some additional information, we will
More informationComplete the quizzes in the "Problem Set 1" unit in the Introduction to Artificial Intelligence course from Udacity:
Name: Course: CAP 4601 Semester: Summer 2013 Assignment: Assignment 05 Date: 26 JUN 2013 Complete the following written problems: 1. Problem Set 1 (100 Points). Complete the quizzes in the "Problem Set
More informationSection 5.5. Left subtree The left subtree of a vertex V on a binary tree is the graph formed by the left child L of V, the descendents
Section 5.5 Binary Tree A binary tree is a rooted tree in which each vertex has at most two children and each child is designated as being a left child or a right child. Thus, in a binary tree, each vertex
More informationInformed search algorithms
Artificial Intelligence Topic 4 Informed search algorithms Best-first search Greedy search A search Admissible heuristics Memory-bounded search IDA SMA Reading: Russell and Norvig, Chapter 4, Sections
More informationData Structure and Algorithm, Spring 2013 Midterm Examination 120 points Time: 2:20pm-5:20pm (180 minutes), Tuesday, April 16, 2013
Data Structure and Algorithm, Spring 2013 Midterm Examination 120 points Time: 2:20pm-5:20pm (180 minutes), Tuesday, April 16, 2013 Problem 1. In each of the following question, please specify if the statement
More informationAGENTS AND ENVIRONMENTS. What is AI in reality?
AGENTS AND ENVIRONMENTS What is AI in reality? AI is our attempt to create a machine that thinks (or acts) humanly (or rationally) Think like a human Cognitive Modeling Think rationally Logic-based Systems
More informationInformed search algorithms
CS 580 1 Informed search algorithms Chapter 4, Sections 1 2, 4 CS 580 2 Outline Best-first search A search Heuristics Hill-climbing Simulated annealing CS 580 3 Review: General search function General-Search(
More informationTrees. (Trees) Data Structures and Programming Spring / 28
Trees (Trees) Data Structures and Programming Spring 2018 1 / 28 Trees A tree is a collection of nodes, which can be empty (recursive definition) If not empty, a tree consists of a distinguished node r
More informationCSE 373 APRIL 17 TH TREE BALANCE AND AVL
CSE 373 APRIL 17 TH TREE BALANCE AND AVL ASSORTED MINUTIAE HW3 due Wednesday Double check submissions Use binary search for SADict Midterm text Friday Review in Class on Wednesday Testing Advice Empty
More informationR13. II B. Tech I Semester Supplementary Examinations, May/June DATA STRUCTURES (Com. to ECE, CSE, EIE, IT, ECC)
SET - 1 II B. Tech I Semester Supplementary Examinations, May/June - 2016 PART A 1. a) Write a procedure for the Tower of Hanoi problem? b) What you mean by enqueue and dequeue operations in a queue? c)
More informationR10 SET - 1. Code No: R II B. Tech I Semester, Supplementary Examinations, May
www.jwjobs.net R10 SET - 1 II B. Tech I Semester, Supplementary Examinations, May - 2012 (Com. to CSE, IT, ECC ) Time: 3 hours Max Marks: 75 *******-****** 1. a) Which of the given options provides the
More informationA6-R3: DATA STRUCTURE THROUGH C LANGUAGE
A6-R3: DATA STRUCTURE THROUGH C LANGUAGE NOTE: 1. There are TWO PARTS in this Module/Paper. PART ONE contains FOUR questions and PART TWO contains FIVE questions. 2. PART ONE is to be answered in the TEAR-OFF
More informationIntroduction to Artificial Intelligence (G51IAI)
Introduction to Artificial Intelligence (G51IAI) Dr Rong Qu Heuristic Searches Blind Search vs. Heuristic Searches Blind search Randomly choose where to search in the search tree When problems get large,
More informationDYNAMIC MEMORY ALLOCATION AND DEALLOCATION
COURSE TITLE DATA STRUCTURE DETAILED SYLLABUS SR.NO NAME OF CHAPTERS & DETAILS HOURS ALLOTTED 1 USER DEFINED DATATYPE /STRUCTURE About structure Defining structure Accessing structure element Array of
More informationData Structures Brett Bernstein
Data Structures Brett Bernstein Final Review 1. Consider a binary tree of height k. (a) What is the maximum number of nodes? (b) What is the maximum number of leaves? (c) What is the minimum number of
More informationA6-R3: DATA STRUCTURE THROUGH C LANGUAGE
A6-R3: DATA STRUCTURE THROUGH C LANGUAGE NOTE: 1. There are TWO PARTS in this Module/Paper. PART ONE contains FOUR questions and PART TWO contains FIVE questions. 2. PART ONE is to be answered in the TEAR-OFF
More informationTDT4136 Logic and Reasoning Systems
TDT4136 Logic and Reasoning Systems Chapter 3 & 4.1 - Informed Search and Exploration Lester Solbakken solbakke@idi.ntnu.no Norwegian University of Science and Technology 18.10.2011 1 Lester Solbakken
More informationArtificial Intelligence
Artificial Intelligence hapter 1 hapter 1 1 Iterative deepening search function Iterative-Deepening-Search( problem) returns a solution inputs: problem, a problem for depth 0 to do result Depth-Limited-Search(
More informationCS301 - Data Structures Glossary By
CS301 - Data Structures Glossary By Abstract Data Type : A set of data values and associated operations that are precisely specified independent of any particular implementation. Also known as ADT Algorithm
More informationEnd-Term Examination Second Semester [MCA] MAY-JUNE 2006
(Please write your Roll No. immediately) Roll No. Paper Code: MCA-102 End-Term Examination Second Semester [MCA] MAY-JUNE 2006 Subject: Data Structure Time: 3 Hours Maximum Marks: 60 Note: Question 1.
More informationSolving Problems by Searching
Solving Problems by Searching Agents, Goal-Based Agents, Problem-Solving Agents Search Problems Blind Search Strategies Agents sensors environment percepts actions? agent effectors Definition. An agent
More informationSolving Problems by Searching
Solving Problems by Searching Agents, Goal-Based Agents, Problem-Solving Agents Search Problems Blind Search Strategies Agents sensors environment percepts actions? agent effectors Definition. An agent
More informationRobot Programming with Lisp
6. Search Algorithms Gayane Kazhoyan (Stuart Russell, Peter Norvig) Institute for University of Bremen Contents Problem Definition Uninformed search strategies BFS Uniform-Cost DFS Depth-Limited Iterative
More informationTrees! Ellen Walker! CPSC 201 Data Structures! Hiram College!
Trees! Ellen Walker! CPSC 201 Data Structures! Hiram College! ADTʼs Weʼve Studied! Position-oriented ADT! List! Stack! Queue! Value-oriented ADT! Sorted list! All of these are linear! One previous item;
More information& ( D. " mnp ' ( ) n 3. n 2. ( ) C. " n
CSE Name Test Summer Last Digits of Mav ID # Multiple Choice. Write your answer to the LEFT of each problem. points each. The time to multiply two n " n matrices is: A. " n C. "% n B. " max( m,n, p). The
More informationProblem solving and search
Problem solving and search Chapter 3 TB Artificial Intelligence Slides from AIMA http://aima.cs.berkeley.edu 1 /1 Outline Problem-solving agents Problem types Problem formulation Example problems Basic
More informationE.G.S. PILLAY ENGINEERING COLLEGE (An Autonomous Institution, Affiliated to Anna University, Chennai) Nagore Post, Nagapattinam , Tamilnadu.
17CA 104DATA STRUCTURES Academic Year : 018-019 Programme : MCA Year / Semester : I / I Question Bank Course Coordinator: Mrs. C.Mallika Course Objectives The student should be able to 1. To understand
More informationCourse Review for Finals. Cpt S 223 Fall 2008
Course Review for Finals Cpt S 223 Fall 2008 1 Course Overview Introduction to advanced data structures Algorithmic asymptotic analysis Programming data structures Program design based on performance i.e.,
More informationLecture Plan. Best-first search Greedy search A* search Designing heuristics. Hill-climbing. 1 Informed search strategies. Informed strategies
Lecture Plan 1 Informed search strategies (KA AGH) 1 czerwca 2010 1 / 28 Blind vs. informed search strategies Blind search methods You already know them: BFS, DFS, UCS et al. They don t analyse the nodes
More informationPrincess Nora University Faculty of Computer & Information Systems ARTIFICIAL INTELLIGENCE (CS 370D) Computer Science Department
Princess Nora University Faculty of Computer & Information Systems ARTIFICIAL INTELLIGENCE (CS 370D) Computer Science Department (CHAPTER-3-PART3) PROBLEM SOLVING AND SEARCH Searching algorithm Uninformed
More informationFINALTERM EXAMINATION Fall 2009 CS301- Data Structures Question No: 1 ( Marks: 1 ) - Please choose one The data of the problem is of 2GB and the hard
FINALTERM EXAMINATION Fall 2009 CS301- Data Structures Question No: 1 The data of the problem is of 2GB and the hard disk is of 1GB capacity, to solve this problem we should Use better data structures
More informationCS210 (161) with Dr. Basit Qureshi Final Exam Weight 40%
CS210 (161) with Dr. Basit Qureshi Final Exam Weight 40% Name ID Directions: There are 9 questions in this exam. To earn a possible full score, you must solve all questions. Time allowed: 180 minutes Closed
More informationlogn D. Θ C. Θ n 2 ( ) ( ) f n B. nlogn Ο n2 n 2 D. Ο & % ( C. Θ # ( D. Θ n ( ) Ω f ( n)
CSE 0 Test Your name as it appears on your UTA ID Card Fall 0 Multiple Choice:. Write the letter of your answer on the line ) to the LEFT of each problem.. CIRCLED ANSWERS DO NOT COUNT.. points each. The
More informationGraphs vs trees up front; use grid too; discuss for BFS, DFS, IDS, UCS Cut back on A* optimality detail; a bit more on importance of heuristics,
Graphs vs trees up front; use grid too; discuss for BFS, DFS, IDS, UCS Cut back on A* optimality detail; a bit more on importance of heuristics, performance data Pattern DBs? General Tree Search function
More information9. The expected time for insertion sort for n keys is in which set? (All n! input permutations are equally likely.)
CSE 0 Name Test Spring 006 Last 4 Digits of Student ID # Multiple Choice. Write your answer to the LEFT of each problem. points each. Suppose f ( x) is a monotonically increasing function. Which of the
More informationCSE 373 OCTOBER 11 TH TRAVERSALS AND AVL
CSE 373 OCTOBER 11 TH TRAVERSALS AND AVL MINUTIAE Feedback for P1p1 should have gone out before class Grades on canvas tonight Emails went to the student who submitted the assignment If you did not receive
More informationData Structures Question Bank Multiple Choice
Section 1. Fundamentals: Complexity, Algorthm Analysis 1. An algorithm solves A single problem or function Multiple problems or functions Has a single programming language implementation 2. A solution
More informationChapter 4 Trees. Theorem A graph G has a spanning tree if and only if G is connected.
Chapter 4 Trees 4-1 Trees and Spanning Trees Trees, T: A simple, cycle-free, loop-free graph satisfies: If v and w are vertices in T, there is a unique simple path from v to w. Eg. Trees. Spanning trees:
More information( ) D. Θ ( ) ( ) Ο f ( n) ( ) Ω. C. T n C. Θ. B. n logn Ο
CSE 0 Name Test Fall 0 Multiple Choice. Write your answer to the LEFT of each problem. points each. The expected time for insertion sort for n keys is in which set? (All n! input permutations are equally
More informationArtificial Intelligence
Artificial Intelligence CSC348 Unit 3: Problem Solving and Search Syedur Rahman Lecturer, CSE Department North South University syedur.rahman@wolfson.oxon.org Artificial Intelligence: Lecture Notes The
More information8. Write an example for expression tree. [A/M 10] (A+B)*((C-D)/(E^F))
DHANALAKSHMI COLLEGE OF ENGINEERING DEPARTMENT OF COMPUTER SCIENCE AND ENGINEERING EC6301 OBJECT ORIENTED PROGRAMMING AND DATA STRUCTURES UNIT IV NONLINEAR DATA STRUCTURES Part A 1. Define Tree [N/D 08]
More informationOutline for today s lecture. Informed Search I. One issue: How to search backwards? Very briefly: Bidirectional search. Outline for today s lecture
Outline for today s lecture Informed Search I Uninformed Search Briefly: Bidirectional Search (AIMA 3.4.6) Uniform Cost Search (UCS) Informed Search Introduction to Informed search Heuristics 1 st attempt:
More informationCourse Review for. Cpt S 223 Fall Cpt S 223. School of EECS, WSU
Course Review for Midterm Exam 1 Cpt S 223 Fall 2011 1 Midterm Exam 1 When: Friday (10/14) 1:10-2pm Where: in class Closed book, closed notes Comprehensive Material for preparation: Lecture slides & in-class
More informationWeek 3: Path Search. COMP9414/ 9814/ 3411: Artificial Intelligence. Motivation. Example: Romania. Romania Street Map. Russell & Norvig, Chapter 3.
COMP9414/9814/3411 17s1 Search 1 COMP9414/ 9814/ 3411: Artificial Intelligence Week 3: Path Search Russell & Norvig, Chapter 3. Motivation Reactive and Model-Based Agents choose their actions based only
More informationData Structures. Trees. By Dr. Mohammad Ali H. Eljinini. M.A. Eljinini, PhD
Data Structures Trees By Dr. Mohammad Ali H. Eljinini Trees Are collections of items arranged in a tree like data structure (none linear). Items are stored inside units called nodes. However: We can use
More information( ) ( ) C. " 1 n. ( ) $ f n. ( ) B. " log( n! ) ( ) and that you already know ( ) ( ) " % g( n) ( ) " #&
CSE 0 Name Test Summer 008 Last 4 Digits of Mav ID # Multiple Choice. Write your answer to the LEFT of each problem. points each. The time for the following code is in which set? for (i=0; i
More information12 Abstract Data Types
12 Abstract Data Types 12.1 Foundations of Computer Science Cengage Learning Objectives After studying this chapter, the student should be able to: Define the concept of an abstract data type (ADT). Define
More informationDATA STRUCTURE : A MCQ QUESTION SET Code : RBMCQ0305
Q.1 If h is any hashing function and is used to hash n keys in to a table of size m, where n
More informationCS:4420 Artificial Intelligence
S:4420 rtificial Intelligence Spring 2018 Uninformed Search esare Tinelli The University of Iowa opyright 2004 18, esare Tinelli and Stuart Russell a a These notes were originally developed by Stuart Russell
More informationSolving Problems by Searching. Artificial Intelligence Santa Clara University 2016
Solving Problems by Searching Artificial Intelligence Santa Clara University 2016 Problem Solving Agents Problem Solving Agents Use atomic representation of states Planning agents Use factored or structured
More informationINSTITUTE OF AERONAUTICAL ENGINEERING
INSTITUTE OF AERONAUTICAL ENGINEERING (Autonomous) Dundigal, Hyderabad - 500 043 COMPUTER SCIENCE AND ENGINEERING TUTORIAL QUESTION BANK Course Name Course Code Class Branch DATA STRUCTURES ACS002 B. Tech
More informationInformed Search and Exploration
Informed Search and Exploration Chapter 4 (4.1-4.3) CS 2710 1 Introduction Ch.3 searches good building blocks for learning about search But vastly inefficient eg: Can we do better? Breadth Depth Uniform
More information) $ f ( n) " %( g( n)
CSE 0 Name Test Spring 008 Last Digits of Mav ID # Multiple Choice. Write your answer to the LEFT of each problem. points each. The time to compute the sum of the n elements of an integer array is: # A.
More informationCSCI-401 Examlet #5. Name: Class: Date: True/False Indicate whether the sentence or statement is true or false.
Name: Class: Date: CSCI-401 Examlet #5 True/False Indicate whether the sentence or statement is true or false. 1. The root node of the standard binary tree can be drawn anywhere in the tree diagram. 2.
More informationInformed search algorithms
Informed search algorithms This lecture topic Chapter 3.5-3.7 Next lecture topic Chapter 4.1-4.2 (Please read lecture topic material before and after each lecture on that topic) Outline Review limitations
More informationChapter 20: Binary Trees
Chapter 20: Binary Trees 20.1 Definition and Application of Binary Trees Definition and Application of Binary Trees Binary tree: a nonlinear linked list in which each node may point to 0, 1, or two other
More information