CS112A1 Spring 2008 Practice Final. ASYMPTOTIC NOTATION: a)Show that log(n) and ln(n) are the same in terms of Big-Theta notation b)Show that log(n+1)

Slides:



Advertisements
Similar presentations
Theory of Computing Lecture 6 MAS 714 Hartmut Klauck.
Advertisements

Graph Traversals Visit vertices of a graph G to determine some property: Is G connected? Is there a path from vertex a to vertex b? Does G have a cycle?
Graphs Chapter 12. Chapter Objectives  To become familiar with graph terminology and the different types of graphs  To study a Graph ADT and different.
Graphs Chapter 20 Data Structures and Problem Solving with C++: Walls and Mirrors, Carrano and Henry, © 2013.
Graph Searching (Graph Traversal) Algorithm Design and Analysis Week 8 Bibliography: [CLRS] – chap 22.2 –
Graph II MST, Shortest Path. Graph Terminology Node (vertex) Edge (arc) Directed graph, undirected graph Degree, in-degree, out-degree Subgraph Simple.
1 Greedy 2 Jose Rolim University of Geneva. Algorithmique Greedy 2Jose Rolim2 Examples Greedy  Minimum Spanning Trees  Shortest Paths Dijkstra.
ITEC200 – Week 12 Graphs. 2 Chapter Objectives To become familiar with graph terminology and the different types of graphs To study.
Prelim 2 Review CS 2110 Fall 2009.
CS 311 Graph Algorithms. Definitions A Graph G = (V, E) where V is a set of vertices and E is a set of edges, An edge is a pair (u,v) where u,v  V. If.
UMass Lowell Computer Science Analysis of Algorithms Prof. Karen Daniels Fall, 2001 Lectures 3 Tuesday, 9/25/01 Graph Algorithms: Part 1 Shortest.
Greedy Algorithms Reading Material: Chapter 8 (Except Section 8.5)
Graphs Chapter 12. Chapter 12: Graphs2 Chapter Objectives To become familiar with graph terminology and the different types of graphs To study a Graph.
Spring 2010CS 2251 Graphs Chapter 10. Spring 2010CS 2252 Chapter Objectives To become familiar with graph terminology and the different types of graphs.
Course Review COMP171 Spring Hashing / Slide 2 Elementary Data Structures * Linked lists n Types: singular, doubly, circular n Operations: insert,
Dynamic Sets and Data Structures Over the course of an algorithm’s execution, an algorithm may maintain a dynamic set of objects The algorithm will perform.
Shortest Paths Definitions Single Source Algorithms
Fall 2007CS 2251 Graphs Chapter 12. Fall 2007CS 2252 Chapter Objectives To become familiar with graph terminology and the different types of graphs To.
Greedy Algorithms Like dynamic programming algorithms, greedy algorithms are usually designed to solve optimization problems Unlike dynamic programming.
Data Structures, Spring 2004 © L. Joskowicz 1 DAST – Final Lecture Summary and overview What we have learned. Why it is important. What next.
Graphs Chapter 20 Data Structures and Problem Solving with C++: Walls and Mirrors, Frank Carrano, © 2012.
Prim’s Algorithm and an MST Speed-Up
Review of Graphs A graph is composed of edges E and vertices V that link the nodes together. A graph G is often denoted G=(V,E) where V is the set of vertices.
C o n f i d e n t i a l HOME NEXT Subject Name: Data Structure Using C Unit Title: Graphs.
Data Structures Using C++ 2E
Graphs CS 400/600 – Data Structures. Graphs2 Graphs  Used to represent all kinds of problems Networks and routing State diagrams Flow and capacity.
Course notes CS2606: Data Structures and Object-Oriented Development Graphs Department of Computer Science Virginia Tech Spring 2008 (The following notes.
1 Shortest Path Algorithms Andreas Klappenecker [based on slides by Prof. Welch]
COSC 3101NJ. Elder Assignment 2 Remarking Assignment 2 Marks y = 0.995x R 2 = Old Mark New Mark.
Week -7-8 Topic - Graph Algorithms CSE – 5311 Prepared by:- Sushruth Puttaswamy Lekhendro Lisham.
Chapter 9 – Graphs A graph G=(V,E) – vertices and edges
Dijkstras Algorithm Named after its discoverer, Dutch computer scientist Edsger Dijkstra, is an algorithm that solves the single-source shortest path problem.
Charles Lin. Graph Representation Graph Representation DFS DFS BFS BFS Dijkstra Dijkstra A* Search A* Search Bellman-Ford Bellman-Ford Floyd-Warshall.
Spring 2015 Lecture 10: Elementary Graph Algorithms
0 Course Outline n Introduction and Algorithm Analysis (Ch. 2) n Hash Tables: dictionary data structure (Ch. 5) n Heaps: priority queue data structures.
COSC 3101A - Design and Analysis of Algorithms 14 Review.
L Please get a complete set (brown, green, red and yellow) of colored paper from the front.
December 4, Algorithms and Data Structures Lecture XV Simonas Šaltenis Aalborg University
CS Data Structures II Review & Final Exam. 2 Topics Review Final Exam.
Lecture 11 Algorithm Analysis Arne Kutzner Hanyang University / Seoul Korea.
CS223 Advanced Data Structures and Algorithms 1 Review for Final Neil Tang 04/27/2010.
Jan Topological Order and SCC Edge classification Topological order Recognition of strongly connected components.
1 Chapter 22 Elementary Graph Algorithms. 2 Introduction G=(V, E) –V = vertex set –E = edge set Graph representation –Adjacency list –Adjacency matrix.
Runtime O(VE), for +/- edges, Detects existence of neg. loops
1 Prim’s algorithm. 2 Minimum Spanning Tree Given a weighted undirected graph G, find a tree T that spans all the vertices of G and minimizes the sum.
Chapter 22: Elementary Graph Algorithms
Graphs. Graphs Similar to the graphs you’ve known since the 5 th grade: line graphs, bar graphs, etc., but more general. Those mathematical graphs are.
Copyright © 2007 Pearson Education, Inc. Publishing as Pearson Addison-Wesley. Ver Chapter 13: Graphs Data Abstraction & Problem Solving with C++
Graphs Chapter 12. Chapter 12: Graphs2 Chapter Objectives To become familiar with graph terminology and the different types of graphs To study a Graph.
© 2006 Pearson Addison-Wesley. All rights reserved 14 A-1 Chapter 14 Graphs.
Graphs Upon completion you will be able to:
Graphs & Paths Presentation : Part II. Graph representation Given graph G = (V, E). May be either directed or undirected. Two common ways to represent.
Chapter 20: Graphs. Objectives In this chapter, you will: – Learn about graphs – Become familiar with the basic terminology of graph theory – Discover.
CSCE 411 Design and Analysis of Algorithms Set 9: More Graph Algorithms Prof. Jennifer Welch Spring 2012 CSCE 411, Spring 2012: Set 9 1.
Graph Searching CSIT 402 Data Structures II. 2 Graph Searching Methodology Depth-First Search (DFS) Depth-First Search (DFS) ›Searches down one path as.
Main Index Contents 11 Main Index Contents Graph Categories Graph Categories Example of Digraph Example of Digraph Connectedness of Digraph Connectedness.
CSC317 1 At the same time: Breadth-first search tree: If node v is discovered after u then edge uv is added to the tree. We say that u is a predecessor.
Chapter 22: Elementary Graph Algorithms Overview: Definition of a graph Representation of graphs adjacency list matrix Elementary search algorithms breadth-first.
Minimum Spanning Tree Graph Theory Basics - Anil Kishore.
Minimum Spanning Trees
Lecture 11 Graph Algorithms
Common final examinations
CS120 Graphs.
Minimum Spanning Trees
CSE373: Data Structures & Algorithms Lecture 12: Minimum Spanning Trees Catie Baker Spring 2015.
CSE373: Data Structures & Algorithms Lecture 20: Minimum Spanning Trees Linda Shapiro Spring 2016.
Graph Representation (23.1/22.1)
Shortest Path Algorithms
Chapter 14 Graphs © 2011 Pearson Addison-Wesley. All rights reserved.
Lecture 10 Graph Algorithms
Presentation transcript:

CS112A1 Spring 2008 Practice Final

ASYMPTOTIC NOTATION: a)Show that log(n) and ln(n) are the same in terms of Big-Theta notation b)Show that log(n+1) = O(log(n))

SORTING: Show how quicksort works on the following array, by showing its contents after each recursive call, and marking the pivot element’s final location. Assume the pivot is always chosen to be the last element in the array Now show how mergesort would work on the same array, by showing the two sub-arrays merged at each iteration and the resulting merged array.

SIMPLE ABSTRACT DATA TYPES (ADTs): a)True/False: Stack, Queue, and List can be implemented using an array, or a linked list. b)True/False: Stack is a FIFO (first in, first out) data structure, while Queue is a LIFO (last in, first out data structure). c) True/False: Stack and Queue can be implemented using a LIST. HEAPS: a)True/False: A Binary Heap is one way to implement a priority queue. b)True/False: Like with Binary Search Trees, we can produce the elements in a Heap in sorted order in O(n). c)In a Min-Heap, where can the largest element be found? How long would it take to find it? AVL TREES: Show the result of inserting the following keys into an empty AVL tree: KONSTANTIN (assume that duplicate keys are not inserted)

LEFTIST HEAPS: Show the result of merging the two leftist heaps below: Evo Morales, president of Bolivia, is known for his colorful native sweaters (which he wears to formal occasions). Give an argument why the merge operation preserves the leftist and the heap order property of the resulting heap.

HASHING: Illustrate the insertion of the keys below into a hash table with the hash function h(k) = (2k + 5) mod 11, using an array of size 11, collisions are handled with a second hash function h'(k) = 7 - k mod

ab d e GRAPH REPRESENTATION: Show an adjacency matrix and an adjacency list representation of the graph below: c Which representation will use less memory for this graph?

BREADTH FIRST SEARCH: while BFS is still running, what is the smallest and largest possible size of the queue? DEPTH FIRST SEARCH: Show how DFS is run on the graph below. For each vertex, mark its discovery and finishing time. Draw the resulting depth first spanning tree forest. Assume that vertices are processed in alphabetical order. a bc d e f g h i TOPOLOGICAL SORT: Use the output of your DFS to give a topological ordering of the vertices (if one is possible).

DEPTH FIRST SEARCH: a)True/False: If v is discovered from u, then f(u) > f(v), where f(u) and f(v) denote the finishing times of u and v in a DFS. b)True/False: If v is a descendant of u in a depth first spanning tree, then there is a path from u to v. c)True/False: If d(u) < d(v) < f(v) < f(u), then v is a descendant of u in a depth first spanning tree, where d and f denote discovery/finishing times in a DFS. d) Argue that if there is a path from u to v and f(v) > f(u), there must be a path from v to u. Why does correctness of dfs-based topological sort follow?

STRONGLY CONNECTED COMPONENTS (SCC): Show how the DFS-based SCC algorithm works on the following graph: a b c d e

MINIMUM SPANNING TREE (MST): Show the MST returned by Prim’s and Kruskal’s algorithm for the following graph: a b c def g Do they find the same MST? Will this always be the case?

SHORTEST PATHS: What algorithm will you use to find shortest paths in the graph in each situation: a)Graph is undirected, unweighted b)Graph is directed, unweighted c)Graph is weighted, no negative weight edges d)Graph is weighted, with negative weight edges Why are shortest paths not defined for networks with negative weight cycles? We have seen that the RELAX subroutine is part (of an efficient implementation) of Prim, Dijkstra, and Bellman-Ford algorithms. If we relax edge (u,v) of weight 3, and v has a distance of 6, and u has a distance of 2, will the parent of v be set to u?

SHORTEST PATHS: For the graph below, find shortest paths from a to all other vertices using Dijkstra’s algorithm. List the order in which shortest paths of the vertices will be discovered, and the shortest path distances. ab cd e fg