授課教授:李錫智 Data Structures -3 rd exam-. 1.[5] Refer to the two trees in Fig. 1. Let’s define the balance factor BF of a node to be the absolute value of.

Slides:



Advertisements
Similar presentations
The Dictionary ADT Definition A dictionary is an ordered or unordered list of key-element pairs, where keys are used to locate elements in the list. Example:
Advertisements

An Introduction to Hashing. By: Sara Kennedy Presented: November 1, 2002.
Transform and Conquer Chapter 6. Transform and Conquer Solve problem by transforming into: a more convenient instance of the same problem (instance simplification)
Data Abstraction and Problem Solving with JAVA Walls and Mirrors Frank M. Carrano and Janet J. Prichard © 2001 Addison Wesley Data Abstraction and Problem.
授課教授:李錫智 Data Structures -1 st exam-. 1.[10] We define f(n) = O(g(n)) if and only if there is a real constant c>0 and an integer constant n 0 >0, such.
Data Structures (3rd Exam). 1. [5] Determine whether or not the arrays A = [62, 40, 58, 26, 30, 57, 50, 16, 15], B = [56, 38, 55, 46, 16, 53, 48, 39,
CSC401 – Analysis of Algorithms Lecture Notes 5 Heaps and Hash Tables Objectives: Introduce Heaps, Heap-sorting, and Heap- construction Analyze the performance.
Tirgul 10 Rehearsal about Universal Hashing Solving two problems from theoretical exercises: –T2 q. 1 –T3 q. 2.
C++ Programming:. Program Design Including
© 2006 Pearson Addison-Wesley. All rights reserved13 A-1 Chapter 13 Hash Tables.
Course Review COMP171 Spring Hashing / Slide 2 Elementary Data Structures * Linked lists n Types: singular, doubly, circular n Operations: insert,
Hash Tables1 Part E Hash Tables  
Hash Tables1 Part E Hash Tables  
Data Structure Activities Richard Anderson University of Washington July 2, 20081IUCEE: Data Structures Activities.
COMP 171 Data Structures and Algorithms Tutorial 10 Hash Tables.
CSE 326 Hashing Richard Anderson (instead of Martin Tompa)
AVL trees. AVL Trees We have seen that all operations depend on the depth of the tree. We don’t want trees with nodes which have large height This can.
© 2006 Pearson Addison-Wesley. All rights reserved13 B-1 Chapter 13 (continued) Advanced Implementation of Tables.
Question 1 (a) Student FoldingComputedActual Number AddressAddress > >7->8.
Introducing Hashing Chapter 21 Copyright ©2012 by Pearson Education, Inc. All rights reserved.
© 2006 Pearson Addison-Wesley. All rights reserved13 B-1 Chapter 13 (excerpts) Advanced Implementation of Tables CS102 Sections 51 and 52 Marc Smith and.
1 Hash Tables  a hash table is an array of size Tsize  has index positions 0.. Tsize-1  two types of hash tables  open hash table  array element type.
Final Review Dr. Bernard Chen Ph.D. University of Central Arkansas Spring 2010.
Final Review Dr. Yingwu Zhu. Goals Use appropriate data structures to solve real- world problems –E.g., use stack to implement non-recursive BST traversal,
IT 60101: Lecture #151 Foundation of Computing Systems Lecture 15 Searching Algorithms.
7-1 Chapter 7 Searching. 7-2 nameno.age record 1BB616 record 2CC916 record 3AA818 record 4DD217 table(file) key internal key, embedded key 和整個 record.
Hashing Dr. Yingwu Zhu.
© 2006 Pearson Addison-Wesley. All rights reserved13 B-1 Chapter 13 (continued) Advanced Implementation of Tables.
TECH Computer Science Dynamic Sets and Searching Analysis Technique  Amortized Analysis // average cost of each operation in the worst case Dynamic Sets.
Hash Tables1   © 2010 Goodrich, Tamassia.
Hashing Suppose we want to search for a data item in a huge data record tables How long will it take? – It depends on the data structure – (unsorted) linked.
Review for Final Exam – cs411/511 Definitions (5 questions, 2 points each) Algorithm Analysis (3 questions, 3 points each) General Questions (3 questions,
Data Structure II So Pak Yeung Outline Review  Array  Sorted Array  Linked List Binary Search Tree Heap Hash Table.
Hashtables. An Abstract data type that supports the following operations: –Insert –Find –Remove Search trees can be used for the same operations but require.
Data Structure II. Outline Heap Binary Search Tree Hash Table Binary Indexed Tree Segment Tree.
Data Structures -Final exam- 2015/6/22 授課教授:李錫智. Question 1. Let a hash table have 13 entries. Suppose we have 10 integer keys: 68, 100, 58, 80, 72, 101,
Data Structures -3 st exam- 授課教師 : 李錫智 教授. 1. [5] Assume we have a binary tree which is implemented in a pointer-based scheme. Describe how to know the.
Chapter 13 C Advanced Implementations of Tables – Hash Tables.
Chapter 9 Hashing Dr. Youssef Harrath
Instructor Neelima Gupta Expected Running Times and Randomized Algorithms Instructor Neelima Gupta
1 Chapter 9 Searching And Table. 2 OBJECTIVE Introduces: Basic searching concept Type of searching Hash function Collision problems.
Data Structures -2 nd exam- 授課教師 : 李錫智 教授 1. 1.[10] Please answer the following questions about stack: What is the response of the statement “(new stack()).isEmpty()”?
Hash Tables ADT Data Dictionary, with two operations – Insert an item, – Search for (and retrieve) an item How should we implement a data dictionary? –
CSE 3358 NOTE SET 13 Data Structures and Algorithms.
Data Structures -3 rd exam- 授課教授:李錫智. 1.[10] Suppose we want to implement a queue by using the following List operations: getLength(); remove(position);
1 the BSTree class  BSTreeNode has same structure as binary tree nodes  elements stored in a BSTree are a key- value pair  must be a class (or a struct)
1.[10] Suppose we have 14 integers: 10, 100, 30, 130, 80, 50, 140, 20, 60, 70, 120, 40, 90, 110. Please create a 2-3 tree by inserting one integer at a.
Data Structures -3 rd exam- 授課教師 : 李錫智 教授. 1.[10] Please answer the following questions about queue: [ 2] What is the response of the statement: “(new.
Chapter 11 (Lafore’s Book) Hash Tables Hwajung Lee.
Prof. Amr Goneid, AUC1 CSCI 210 Data Structures and Algorithms Prof. Amr Goneid AUC Part 5. Dictionaries(2): Hash Tables.
Algorithms Design Fall 2016 Week 6 Hash Collusion Algorithms and Binary Search Trees.
CSCI 210 Data Structures and Algorithms
Binary search tree. Removing a node
Hashing CSE 2011 Winter July 2018.
Introduction Applications Balance Factor Rotations Deletion Example
Dictionaries Dictionaries 07/27/16 16:46 07/27/16 16:46 Hash Tables 
Dictionaries 9/14/ :35 AM Hash Tables   4
The Dictionary ADT Definition A dictionary is an ordered or unordered list of key-element pairs, where keys are used to locate elements in the list. Example:
Advanced Associative Structures
Hash In-Class Quiz.
CS223 Advanced Data Structures and Algorithms
AVL Search Tree put(9)
Hash Tables Computer Science and Engineering
A Hash Table with Chaining
Advanced Implementation of Tables
Advanced Implementation of Tables
CS223 Advanced Data Structures and Algorithms
AVL Tree By Rajanikanth B.
Final Review Dr. Yingwu Zhu.
Ch Hash Tables Array or linked list Binary search trees
Presentation transcript:

授課教授:李錫智 Data Structures -3 rd exam-

1.[5] Refer to the two trees in Fig. 1. Let’s define the balance factor BF of a node to be the absolute value of the difference between the heights of the children of the node. Please show the BF of each node in both trees. Are they AVL trees? Why or why not? Ans: AVL Tree  BF ≦ 1 (a) 符合條件,所以 (a) 是 AVL Tree (b)62 的 BF=2 ,所以不是 AVL Tree (a)(b)

2.[10] Consider ten integers 42, 22, 32, 74, 47, 52, 94, 29, 40, 58 in order. Using the hash function h(k) = k%11, construct an 11- element hash table with chaining for collision resolution. Draw the final hash table. Note that singly linked lists are used. An integer is inserted as the first node of a list. Ans:

3.[10] Consider ten integers 42, 22, 32, 74, 47, 52, 94, 29, 40, 58 in order. Using the hash function h(k) = k%11, construct an 11-element hash table with linear probing for collision resolution. Draw the final hash table. Ans:

4.[10] Consider the integers 42, 3, 17, 22, 32, 7, 12, 74, 47, 8, 5, 52, 94, 29, 15, 6, 40, 58 in order. Create a binary search tree for them and draw the final tree. Ans:

5.[5] Please delete 17 from the binary search tree of Problem 4 and show the resulting binary search tree. Note that the right subtree is considered if necessary. Ans:

6.[10] Consider the integers 42, 22, 32, 74, 47, 52, 94, 29, 40, 58 in order. Using the first hash function h(k) = k%11 and the secondary hash function d(k) = 5 – k%5, construct an 11- element hash table with double hashing for collision resolution. Draw the final hash table. Ans: ( i + jd(k)) mod N for j = 0, 1, …, N - 1 h(42)=9 h(22)=0 h(32)=10 h(74)=8 h(47)=3 h(52)=8, d(52)=3 (8+1*3) mod 11=0 (8+2*3) mod 11=3 (8+3*3) mod 11=6 ……

7.[10] Consider the integers 42, 3, 17, 22, 32, 7, 12, 74, 47, 8, 5, 52 in order. Create an AVL tree for them and draw the final tree. Also, draw the intermediate tree after each violation is resolved. Ans

7.[10] 42, 3, 17, 22, 32, 7, 12, 74, 47, 8, 5, 52 Ans:

7.[10] 42, 3, 17, 22, 32, 7, 12, 74, 47, 8, 5, 52 Ans:

8.[5] Please delete 74 first and then delete 52 from the AVL tree of Problem 7 and show the resulting AVL tree. Note that the right subtree is considered if necessary. Ans:

9.[10] Consider the integers 42, 3, 17, 22, 32, 7, 12, 74, 47, 8, 5 in order. Create a (2,4) tree for them and draw the final tree. Also, draw the intermediate tree after each violation is resolved. When an overflow occurs, please navigate the third number. Ans:

9.[10] 42, 3, 17, 22, 32, 7, 12, 74, 47, 8, 5 Ans:

10.[5] Please delete 47 from the (2,4) tree of Problem 9 and show the resulting (2,4) tree. Note that the right subtree is considered if necessary. Ans:

11.[10] Consider an array A containing the integers 42, 3, 17, 22, 32, 7, 12, 74, 47, 8. Please sort the integers in ascending order using in-place quick-sort. Note that the first element of the underlying sequence is used as the pivot. Draw the array after the execution of each partition. Ans:

11.[10] Consider an array A containing the integers 42, 3, 17, 22, 32, 7, 12, 74, 47, 8. Please sort the integers in ascending order using in-place quick-sort. Note that the first element of the underlying sequence is used as the pivot. Draw the array after the execution of each partition. Ans:

12.[10( 送分 )] You are given a set S of n real numbers and another real number x. Describe a O(nlogn)-time algorithm that determines whether or not there exist two elements in S whose sum is exactly x. Ans: A set S of n real numbers Real number x Algorithm judge (S, x) QuickSort(S); for i  0 to n-1 do temp=x-S[i]; if (BinarySearch(temp)) return TRUE; return FALSE;