Answered step by step
Verified Expert Solution
Link Copied!

Question

1 Approved Answer

[2 pts] Figure 1 shows a search tree with 21 nodes. Please uses BFS, and DFS algorithms showing in Figures 2, 3, and 4 to

image text in transcribed[2 pts] Figure 1 shows a search tree with 21 nodes. Please uses BFS, and DFS algorithms showing in Figures 2, 3, and 4 to report the order of the nodes being visited, and the Fringe structure of each method (report fringe structure of each step as show in the table below) [1 pt]. Please compare the fringe structure and explain the memory consumption of each method, with respect to branching factor (b) and the search depth (d) [1 pt].

Fringe

Node visited

Fringe Size

Search depth

image text in transcribed

1 procedure DFS-iterative(G,v): 2 let S be a stack 3 S.push(v) 4 while S is not empty V : S.pop() if v is not labeled as discovered: label v as discovered for all edges from v to w in G.adjacentEdges(v) do S.push(w) Figure 2 Depth First Search DFS (Method 1) s stack s.push(initial node) add initial node to visited while s is not empty: Figure 1 Set all nodes to not visited" q new Queue(); q.enqueue (initial node); wile q empty do V s.peek() if for all E(v,u) there is one unvisited u: x q.dequeue(); mark u as visited if ( x has not been visited) s.push(u) visited[x] true; // Visit node x else for every edge (x, y) /* we are using all edges) if (y has not been visited) .pop q.enqueue(y) // Use the edge (x,y)!!! Figure 3 Depth First Search (Method 2) Figure 2: Breath First Search (BFS)

Step by Step Solution

There are 3 Steps involved in it

Step: 1

blur-text-image

Get Instant Access to Expert-Tailored Solutions

See step-by-step solutions with expert insights and AI powered tools for academic success

Step: 2

blur-text-image

Step: 3

blur-text-image

Ace Your Homework with AI

Get the answers you need in no time with our AI-driven, step-by-step assistance

Get Started

Recommended Textbook for

Students also viewed these Databases questions

Question

Find the inverse of cos -sin sire cos

Answered: 1 week ago