0% found this document useful (0 votes)
349 views4 pages

ف1

This document contains sample questions and problems related to graphs, sorting algorithms, divide and conquer algorithms, and searching algorithms. It asks the reader to: 1) Construct a graph and apply depth-first search (DFS) and breadth-first search (BFS) to find costs. 2) Explain which traversal (DFS or BFS) would be better in a maze and why. 3) Provide pseudocode for a divide-and-conquer maximum-finding algorithm and analyze its runtime. 4) Determine the order of growth for a given divide-and-conquer recurrence relation. 5) Trace the recursive calls of quicksort on a sample array. 6) Analyze
Copyright
© Attribution Non-Commercial (BY-NC)
We take content rights seriously. If you suspect this is your content, claim it here.
Available Formats
Download as DOCX, PDF, TXT or read online on Scribd
0% found this document useful (0 votes)
349 views4 pages

ف1

This document contains sample questions and problems related to graphs, sorting algorithms, divide and conquer algorithms, and searching algorithms. It asks the reader to: 1) Construct a graph and apply depth-first search (DFS) and breadth-first search (BFS) to find costs. 2) Explain which traversal (DFS or BFS) would be better in a maze and why. 3) Provide pseudocode for a divide-and-conquer maximum-finding algorithm and analyze its runtime. 4) Determine the order of growth for a given divide-and-conquer recurrence relation. 5) Trace the recursive calls of quicksort on a sample array. 6) Analyze
Copyright
© Attribution Non-Commercial (BY-NC)
We take content rights seriously. If you suspect this is your content, claim it here.
Available Formats
Download as DOCX, PDF, TXT or read online on Scribd
You are on page 1/ 4

Q4)

One can model a maze by having a vertex for a starting point, a finishing point, dead ends, and all the points in the maze where more than one path can be taken, and then connecting the vertices according to the paths in the maze. a- Construct such a graph for the following maze.

b- Which traversalDFS or BFSwould you use if you found yourself in a Maze and why?

a. Write a pseudo code for a divide-and-conquer algorithm for finding The Position of the largest element in an array of n numbers. b. What will be your algorithms output for arrays with several elements of the largest value? c. Set up and solve a recurrence relation for the number of key comparisons made by your algorithm.

Q5)
Find the order of growth for solutions of the following recurrences. T (n) = 4T (n/2) + n, T (1) = 1

Q6)
Apply quick sort to sort the list E, X, A, M, P, L, E in alphabetical order. Trace of the recursive calls made. For the partitioning procedure. a. Prove that if the scanning indices stop while pointing to the same element, i.e., i = j, the value they are pointing to must be equal to p. b. Prove that when the scanning indices stop, j cannot point to an element more than one position to the left of the one pointed to by i. c. Why is it worth stopping the scans after encountering an element equal to the pivot? d. Is quick sort a stable sorting algorithm

Consider the following algorithm. Algorithm Secret (A [0..n 1]) //Input: An array A[0..n 1] of n real numbers minval A[0]; maxval A[0] for i 1 to n 1 do if A[i] < minval minval A[i] if A[i] > maxval maxval A[i] return maxval minval a. What does this algorithm compute? b. What is its basic operation? c. How many times is the basic operation executed? d. What is the efficiency class of this algorithm? e. Suggest an improvement or a better algorithm altogether and indicate Its efficiency class. If you cannot do it, try to prove that, in fact, it
Cant be done

Q1
18 Mark s

Form the below Graph(G) Answer the following Questions 11 12 18 11 6 34 67 78 58 2 1 78 3 8 5 14 67 23 22 4 56 7 15 80 9

o o o o

Draw DFS and compute Cost Draw BFS and compute Cost Find the Mini-Spanning Tree(MST) Using Kruskal Method(compute Cost)( Find mini-spanning Tree(MST) Using Prime Method start at(9)(compute Cost)

Q2
12 Marks

algorithm(A[0..n-1],K) l=0 int m r=n-1 while l<=r do m=(l+r)/2 if k=A[m] return m else if k<A[m] r=m-1 else l=m+1 return -1

a) b) c)

What is the largest number of key comparisons made by this algorithm? (5 marks) What is the input and output of this algorithm? (2 marks) Analyze the time efficiency of this Algorithm and find Recurrence?(5 marks)

You might also like

pFad - Phonifier reborn

Pfad - The Proxy pFad of © 2024 Garber Painting. All rights reserved.

Note: This service is not intended for secure transactions such as banking, social media, email, or purchasing. Use at your own risk. We assume no liability whatsoever for broken pages.


Alternative Proxies:

Alternative Proxy

pFad Proxy

pFad v3 Proxy

pFad v4 Proxy