Question 1 (a) Student FoldingComputedActual Number AddressAddress 9800344618777 9801824128555 9801960230555->6 9813794259222 9815889179666->7->8.

Slides:



Advertisements
Similar presentations
Hash Tables CS 310 – Professor Roch Weiss Chapter 20 All figures marked with a chapter and section number are copyrighted © 2006 by Pearson Addison-Wesley.
Advertisements

Dictionaries and Hash Tables
CSCE 3400 Data Structures & Algorithm Analysis
Hashing as a Dictionary Implementation
1 abstract containers hierarchical (1 to many) graph (many to many) first ith last sequence/linear (1 to 1) set.
Introduction to Trees. Tree example Consider this program structure diagram as itself a data structure. main readinprintprocess sortlookup.
Hashing Chapters What is Hashing? A technique that determines an index or location for storage of an item in a data structure The hash function.
Searching Kruse and Ryba Ch and 9.6. Problem: Search We are given a list of records. Each record has an associated key. Give efficient algorithm.
Binary Trees, Binary Search Trees COMP171 Fall 2006.
Hashing COMP171. Hashing 2 Hashing … * Again, a (dynamic) set of elements in which we do ‘search’, ‘insert’, and ‘delete’ n Linear ones: lists, stacks,
授課教授:李錫智 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.
Hashing CS 3358 Data Structures.
Department of Computer Science University of Maryland, College Park
1 Trees. 2 Outline –Tree Structures –Tree Node Level and Path Length –Binary Tree Definition –Binary Tree Nodes –Binary Search Trees.
Lec 15 April 9 Topics: l binary Trees l expression trees Binary Search Trees (Chapter 5 of text)
C++ Plus Data Structures
Binary Tree Properties & Representation. Minimum Number Of Nodes Minimum number of nodes in a binary tree whose height is h. At least one node at each.
1 abstract containers hierarchical (1 to many) graph (many to many) first ith last sequence/linear (1 to 1) set.
Hashing General idea: Get a large array
Introducing Hashing Chapter 21 Copyright ©2012 by Pearson Education, Inc. All rights reserved.
Hash Tables. Container of elements where each element has an associated key Each key is mapped to a value that determines the table cell where element.
Week 7 - Wednesday.  What did we talk about last time?  Recursive running time  Master Theorem  Introduction to trees.
§3 Separate Chaining ---- keep a list of all keys that hash to the same value struct ListNode; typedef struct ListNode *Position; struct HashTbl; typedef.
1 Chapter 5 Hashing General ideas Methods of implementing the hash table Comparison among these methods Applications of hashing Compare hash tables with.
Data Structures and Algorithm Analysis Hashing Lecturer: Jing Liu Homepage:
Data Structures Week 6 Further Data Structures The story so far  We understand the notion of an abstract data type.  Saw some fundamental operations.
DATA STRUCTURES AND ALGORITHMS Lecture Notes 7 Prepared by İnanç TAHRALI.
Trees EENG212 Algorithms and Data Structures. Trees Outline  Introduction to Trees  Binary Trees: Basic Definitions  Traversing Binary Trees  Node.
Searching: Binary Trees and Hash Tables CHAPTER 12 6/4/15 Nyhoff, ADTs, Data Structures and Problem Solving with C++, Second Edition, © 2005 Pearson Education,
Data Structures Using C++1 Search Algorithms Sequential Search (Linear Search) Binary Search.
Data Structures : Project 5 Data Structures Project 5 – Expression Trees and Code Generation.
Nyhoff, ADTs, Data Structures and Problem Solving with C++, Second Edition, © 2005 Pearson Education, Inc. All rights reserved Searching:
Hashing Table Professor Sin-Min Lee Department of Computer Science.
TECH Computer Science Dynamic Sets and Searching Analysis Technique  Amortized Analysis // average cost of each operation in the worst case Dynamic Sets.
Hashing COMP171. Hashing 2 Hashing … * Again, a (dynamic) set of elements in which we do ‘search’, ‘insert’, and ‘delete’ n Linear ones: lists, stacks,
1 CS 163 Data Structures Chapter 9 Building, Printing Binary Trees Herbert G. Mayer, PSU Status 5/21/2015.
Lecture1 introductions and Tree Data Structures 11/12/20151.
Hashing Hashing is another method for sorting and searching data.
Hashing as a Dictionary Implementation Chapter 19.
Hashing - 2 Designing Hash Tables Sections 5.3, 5.4, 5.4, 5.6.
CHAPTER 8 SEARCHING CSEB324 DATA STRUCTURES & ALGORITHM.
CE 221 Data Structures and Algorithms Chapter 4: Trees (Binary) Text: Read Weiss, §4.1 – 4.2 1Izmir University of Economics.
Hash Table March COP 3502, UCF 1. Outline Hash Table: – Motivation – Direct Access Table – Hash Table Solutions for Collision Problem: – Open.
CSE 373 Data Structures and Algorithms Lecture 17: Hashing II.
Hashtables. An Abstract data type that supports the following operations: –Insert –Find –Remove Search trees can be used for the same operations but require.
Rudiments of Trees a Joshua presentation DATA STRUCTURES.
Lecture - 10 on Data Structures. 6:05:57 PM Prepared by, Jesmin Akhter, Lecturer, IIT,JU.
Week 10 - Friday.  What did we talk about last time?  Graph representations  Adjacency matrix  Adjacency lists  Depth first search.
1 CSCD 326 Data Structures I Hashing. 2 Hashing Background Goal: provide a constant time complexity method of searching for stored data The best traditional.
1 Chapter 4 Trees Basic concept How tree are used to implement the file system How tree can be used to evaluate arithmetic expressions How to use trees.
Hashing COMP171. Hashing 2 Hashing … * Again, a (dynamic) set of elements in which we do ‘search’, ‘insert’, and ‘delete’ n Linear ones: lists, stacks,
Hashing. Hashing is the transformation of a string of characters into a usually shorter fixed-length value or key that represents the original string.
Week 15 – Wednesday.  What did we talk about last time?  Review up to Exam 1.
Week 7 - Wednesday.  What did we talk about last time?  Recursive running time  Master Theorem  Symbol tables.
Hashing Goal Perform inserts, deletes, and finds in constant average time Topics Hash table, hash function, collisions Collision handling Separate chaining.
Hashing. Search Given: Distinct keys k 1, k 2, …, k n and collection T of n records of the form (k 1, I 1 ), (k 2, I 2 ), …, (k n, I n ) where I j is.
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 Data Structures CSCI 132, Spring 2014 Lecture23 Analyzing Search Algorithms.
Chapter 11 (Lafore’s Book) Hash Tables Hwajung Lee.
Fundamental Structures of Computer Science II
Instructor: Lilian de Greef Quarter: Summer 2017
CS 201 Data Structures and Algorithms
Week 6 - Wednesday CS221.
Lecture 18. Basics and types of Trees
Hash Table.
Tree A tree is a data structure in which each node is comprised of some data as well as node pointers to child nodes
CE 221 Data Structures and Algorithms
CE 221 Data Structures and Algorithms
Tree traversal preorder, postorder: applies to any kind of tree
CSE 373: Data Structures and Algorithms
Presentation transcript:

Question 1 (a) Student FoldingComputedActual Number AddressAddress > >7->8

Question 1 (b) Average = ( ) / 5 = 1.6 (c)Since each cell in the table is eventually probed, if the table is not full, the collision can be resolved. (d) Similar to quadratic probing, all elements that hash to the same location will try the same collision resolution sequence. Thus secondary clustering problem cannot be resolved. But primary clustering problem similar to linear probing will not occur because there is no difference between records that hash to neighbouring and distant cells.

Question 2 Convert the infix expression, A^B*C-D+E/F/(G+H), into postfix expression Answer: AB^C*D-EF/GH+/+

Expression tree + - * D C ^ A B / / + HG F E

Question 3 A strictly binary tree is one that every non-leaf node has non-empty left and right subtrees. Write a recursive algorithm to determine if a binary tree is strictly binary or not. Assume the following data structure is given struct node {struct node *left; int info; struct node *right; };

Question 3 int binary (nodeptr root) {if (root!=NULL) if((root->left!= NULL && root-> right == NULL) || (root->left == NULL && root-> right !=NULL)) return (0); else return(binary(root->left) * binary(root->right)); else return (1); } Answer

Question 4 Sum=0; for (j=0;j<N;j++) for (k=0;k<N*N;k++) Sum++; Answer: NxN 2 = N 3

Question 4 Sum=0; for (j=0;j<N;j++) for (k=0;k<j;k++) Sum++; Answer: …. + (N-1) = N(N-1)/2

Question 5 Show and describe how to implement three stacks in one array Answer: - one from bottom up - one from top down - one from middle

Question 5 Show and describe how to implement three stacks in one array - if third stack collides with either one => needs to move - one reasonable strategy: move it so that its center is halfway between tops of two stacks