Advanced Data Structures 2006

676 views

Published on

Advanced Data Structures, lecture notes by Sanjay Goel, JIIT, 2006

Published in: Education, Technology
0 Comments
0 Likes
Statistics
Notes
  • Be the first to comment

  • Be the first to like this

No Downloads
Views
Total views
676
On SlideShare
0
From Embeds
0
Number of Embeds
4
Actions
Shares
0
Downloads
10
Comments
0
Likes
0
Embeds 0
No embeds

No notes for slide

Advanced Data Structures 2006

  1. 1. Advanced Data Structures, JIIT Sanjay Goel, 2006 ADS: Lecture Notes Even Sem: 2005-06 1. 10.01.06 1. Learning Outcomes, relationship with DS, DBMS, and OOPS. 2. Concept map (DS) Concept map (DBMS) ER Diagram Class Diagram 3. Assignment: Suggest a solution of converting file format in any domain. Identify the problems and issues. 2. 17.01.06 1. Review of Key issues: - Computational problem solving process. - Design as story telling. 2. Some options for identifying your first paper for your literature survey: i. Select paper(s) that use one or more of the of the Data Structure already studied by you (e.g. Table, Stack, Binary Tree, BST, Queue, Dequeue and so on) in the first course. ii. Select paper(s) on ADT specification and design. iii. Select paper(s) that describe the ADTs or classes used for designing a complete software system of your choice. iv. Select paper(s) that discuss recursive solution for some algorithmic problem. v. Select paper(s) that recursion removal techniques. vi. Select Paper(s) that discuss simulation models using queues. vii. Select papers that analyze the performance of some DS. viii. Select papers that discuss some file format. 3. 18.01.06 1. Review and Enhancement Concept mapping Notation - Identify data tanks as i. IN Data Tanks ii. OUT Data Tanks iii. IN & OUT Data Tanks iv. Buffer Data Tanks - All IN and IN & OUT data Tanks are part of INITIAL STATE (IS) - All OUT and IN & OUT data Tanks are part of FINAL STATE (FS) - Develop Initial State Diagram (ISD) as a collection of IN and IN & OUT Data tanks. - Develop Final State Diagram (FSD) as a collection of OUT and IN & OUT Data tanks. - Develop Concept map (CM) as a network of all Data tanks and Processing Units.
  2. 2. Advanced Data Structures, JIIT Sanjay Goel, 2006 - Put the following symbols on the center of the top line of the Rectangular box of Tank. i. IN Data Tanks : ii. OUT data tanks : iii. IN & OUT Data tanks: iv. Temporary buffer type data tanks: No symbol. 2. Storing a Graph as a Table. 3. Storing a Binary Tree in a Table. 4. Traversing (pre-order) of Binary tree stored as a table. 5. Assignment: When you have learnt SQL in DBMS, use it to do traversal over binary tree stores as a table. 6. Assignment (Group of 2) (3 marks each): Export the Table(s) created by you or by your group partner as your DBMS assignment to a text file. Write any three query functions (already executed by you using ACCESS) to process this text file using C language. 4. 24.01.06 1. Big O, small o, Big Omega, small omega, Big Theta notations. 2. Worst case, Best case, Average Case complexity analysis. 3. Assignment: Perform the average case complexity analysis for following algorithms: - Linear Search in unordered array, Linear search in Ordered array, Binary search. - Insertion sort, Bubble sort, Selection sort. 5. 25.01.06 1. Average Case Complexity analysis: Linear search, Binary search, Insertion sort. 2. Impact of hardware speedup on the data size that can be processed by an algorithm of known complexity f (n). 3. Assignment: In the three research papers that have to be studied by you, at least one should be on complexity analysis. Write program to experimentally validate the theoretical/experimental results on complexity analysis reported in the paper studied by you. Include your results in the literature survey report and presentation. Keep reporting your Lab instructors about the progress on literature survey. 6. 31.01.06 1. Insertion sort Selection sort. Comparison of algorithmic process. 2. Merge sort Transform the process Quick Sort.
  3. 3. Advanced Data Structures, JIIT Sanjay Goel, 2006 3. Comparison less sorting Radix sort 4. Assignment: Analyze the Best case, Worst case, and average case complexity for sorting a linked list using selection sort and insertion sort, Your algorithm should have a space complexity of O(1). 5. Assignment (5 marks): WAP for Radix sort, non-recursive Merge sort, and Quick sort algorithms. Experimentally test the performance for varying data size and distribution. Design the test cases for this experiment. Graphically plot the results of your experiment. 7. 01.02.06 1. Best case and Worst case analysis of Merge Sort. 2. Algorithmic performance improvement by mixing different algorithms Binary insertion sort. 3. Algorithmic performance improvement by identifying the weakness and removing them for large n Shell sort. 4. Assignment (Group of two, 3 marks each): In the three research papers that have to be studied by you, one can be on sorting techniques. Write program to experimentally find out the best initial step size for shell sort for sorting an array of 10,000 integers. 8. 07.02.06 1. Best case and Worst case Complexity Analysis of Quick sort. 2. Algorithmic visualization techniques. 3. Assignment (bonus: only for those who have submitted earlier assignments on sorting program before 10.02.04: 3 marks): Write a function for array visualization to graphically display its sorted-ness. Insert this function in sorting programs to demonstrate algorithms’ progress. 9. 08.02.06 1. Tree Sort algorithm: Using BST. 2. Top down Vs Bottom up growth of tree. 3. Construction of expression tree. 4. Huffman encoding algorithm. 5. Assignment (2 marks): Using your existing functions, WAP and experimentally evaluate the performance of Tree sort algorithm. 10. 14.02.06 1. Review of key ideas. 2. Dynamic programming: e.g. Merge sort. 3. Greedy Algorithms: Huffman encoding. 4. Heap: Priority Queue: insertion and deletion operations. Number of comparison during insertion and deletion. 11. 15.02.06 1. Heap: element insertion, deletion. 2. Heapsort.
  4. 4. Advanced Data Structures, JIIT Sanjay Goel, 2006 12. 02.03.06 1. Review of Algorithmic Design techniques: a. Brute Force Method: Instead of creative logic, computational speed is used for solving the problem e.g. Linear Search, Selection sort, Bubble sort. b. Decrease and Conquer: Instead of solving the problem with n elements, the problem is solved for n-k elements and then n-2k and so on. The solution for n elements is derived from the solution of smaller size data set e.g. Insertion sort. c. Divide and conquer: The problem size is decreased by a ratio rather than a constant e.g. Binary search, Quick sort, Hanoi, Maze, recursive Merge, and so on. d. Greedy: Rather than trying to take best alternative a locally best solution is picked us and short sighted decisions are taken to solve problems e.g. Huffman encoding, Traveling salesman, Activity scheduling, Map coloring, and so on. 2. Assignment (4 marks): All should allow a user inputted data for processing. B1, B2: Huffman encoding (variable number of n symbols) B2, B3: Activity scheduling, (variable number of n activities and variable number of m venues). B4, B5: Traveling Salesman (variable number of n cities) Others: Map coloring (variable number of n regions) 13. 03.03.06 1. Greedy Algorithms: - Coin exchange - Graph: Dominant set of graph - Graph: MST: Kruskal, Prim 2 Assignment (4 marks): All should allow a user inputted data for processing. B1 : Dominant set (variable number of n nodes and m links using Adjacency matrix based storage of Graph) B2: Dominant set (variable number of n nodes and m links using Adjacency list based storage of Graph) B3: Dominant set (variable number of n nodes and m links using linked storage of Graph) B4: Kruskal’s Algorithm, (variable number of n nodes and m links using Adjacency matrix based storage of Graph). B5: Kruskal’s Algorithm, (variable number of n nodes and m links using Adjacency list based storage of Graph). B6: Kruskal’s Algorithm, (variable number of n nodes and m links using linked storage of Graph). B7: Prim’s Algorithm, (variable number of n nodes and m links using Adjacency matrix based storage of Graph). B8: Prim’s Algorithm, (variable number of n nodes and m links using Adjacency list based storage of Graph).
  5. 5. Advanced Data Structures, JIIT Sanjay Goel, 2006 B9: Prim’s Algorithm, (variable number of n nodes and m links using linked storage of Graph). 13-14. 7.3.06 and 8.3.06 More on Greedy AlgorithmsCases of Greedy Algorithms: MST AlgorithmsKruskal’s Algo Examine arcs one-by-one in the sorted order and add them to OUTPUT if their addition does not create a cycle. 10 2 4 35 25 1 20 30 40 3 5 15 Minimum cost, No cycle, select 10 2 4 35 25 1 20 30 40 3 5 15 Selected Link count < 4 so continue Next Minimum cost, No cycle, select
  6. 6. Advanced Data Structures, JIIT Sanjay Goel, 2006 10 2 4 35 25 1 20 30 40 3 5 15 Selected Link count < 4 so continue Next Minimum cost, No cycle, select 10 2 4 35 25 1 20 30 40 3 5 15 Selected Link count < 4 so continue Next Minimum cost, will create a cycle so reject 10 2 4 35 25 1 20 30 40 3 5 15 Selected Link count < 4 so continue Next Minimum cost, will create a cycle so reject
  7. 7. Advanced Data Structures, JIIT Sanjay Goel, 2006 10 2 4 35 25 1 20 30 40 3 5 15 Selected Link count < 4 so continue Next Minimum cost, No cycle, so select 10 2 4 35 25 1 20 30 40 3 5 15 Selected Link count = 4, so stop.Prim’s AlgoStart with a vertex and grow the tree by gradually adding the cheapest unselected edgeconnected to any node in the selected subset. 10 2 4 35 25 1 20 30 40 3 5 15 Start with any node say 1.
  8. 8. Advanced Data Structures, JIIT Sanjay Goel, 2006 10 2 4 35 25 1 20 30 40 3 5 15 Selected links <4 so continueCheck the minimum cost link (amongst the dotted blue), Does not create a cycle so select 10 2 4 35 25 1 20 30 40 3 5 15 Selected links <4 so continue Check the minimum cost link from the already selected nodes, Does not create a cycle so select 10 2 4 35 25 1 20 30 40 3 5 15 Selected links <4 so continue Check the minimum cost link from the already selected nodes, Does not create a cycle so select
  9. 9. Advanced Data Structures, JIIT Sanjay Goel, 2006 10 2 4 35 25 1 20 30 40 3 5 15 Selected links <4 so continue Check the minimum cost link from the already selected nodes, Does not create a cycle so select 10 2 4 35 25 1 20 30 40 3 5 15 Selected links =4 so stopSollin’s Algorithm 1. Proceeds by adding the least cost arc emanating from each tree. 2. Each iteration reduces the number of components by a factor of at least 2. 10 2 4 35 25 1 20 30 40 3 5 15 Selected link count <4 so continue Choose a node, check its cheapest link, No cycle so select
  10. 10. Advanced Data Structures, JIIT Sanjay Goel, 2006 10 2 4 35 25 1 20 30 40 3 5 15 Selected link count <4 so continue Choose next node, check its cheapest link, No cycle or duplication, so select 10 2 4 35 25 1 20 30 40 3 5 15 Selected link count <4 so continue Choose next node, check its cheapest link, No cycle or duplication, so select 10 2 4 35 25 1 20 30 40 3 5 15 Selected link count <4 so continueChoose next node, check its cheapest link, No cycle but duplication, so no new selectionNo New adge is added for node 4 as the cheapest edge from node 4 is alreadyselected.
  11. 11. Advanced Data Structures, JIIT Sanjay Goel, 2006 10 2 4 35 25 1 20 30 40 3 5 15Selected link count <4 so continueChoose next node, check its cheapest link, No cycle but duplication, so no new selectionNo New adge is added for node 5 as the cheapest edge from node 5 is alreadyselected. 10 10 2 4 2 4 35 35 25 1 20 30 1 40 3 5 3 5 15 15Ist iteration over we get some connected components(2nd Iteration starts to link these connected components) 10 2 4 35 25 1 20 30 40 3 5 15Selected link count <4 so continueChoose a tree (connected component) , check its cheapest link, No cycle no duplication,so select.
  12. 12. Advanced Data Structures, JIIT Sanjay Goel, 2006 10 2 4 35 25 1 20 30 40 3 5 15 Selected link count = 4 so stop 15. 21.3.06 1. Dijkastra’s shortest path Algorithm for un-weighted graph and weighted graph. 2. Programming Assignments: (5 marks) B1: Dijkastra’s Algorithm for weighted graph using Adj matrix for Graph and linked structure for priority queue. B2: Dijkastra’s Algorithm for weighted graph using Adj matrix for graph and array based structure for priority queue. B3: Dijkastra’s Algorithm for weighted graph using Adj List for graph and array based structure for priority queue. B4: Dijkastra’s Algorithm for weighted graph using Adj List and linked structure for priority queue. B5: Dijkastra’s Algorithm for weighted graph using Linked Structure for graph and array based structure for priority queue B6: Dijkastra’s Algorithm for weighted graph using Linked Structure for graph and linked structure for priority queue. B7: Dijkastra’s Algorithm for weighted graph using Simulated pointer based Structure for graph and array based structure for priority queue B8: Dijkastra’s Algorithm for weighted graph using Simulated pointer based Structure for graph and linked structure for priority queue. B9: Sollin’s Algorithm using Adj Matrix for Graph. 16. 22.3.06 1. Map Colouring. 2. Limitations of Greedy Algorithm: Optimality is an issue. 3. Dynamic Programming: overlapping sub-problems, recursion removal: Fibonacci, Binomial Coefficients, Coin. 4. Assignment: If your choice of three research papers is not over, include one paper or Dynamic Programming. 17-18. 4.4.06 and 5.4.06 1. Decision Tree for classification 2. Puzzle solving: i. Problem space States: goal, initial, others, states are defined by problem
  13. 13. Advanced Data Structures, JIIT Sanjay Goel, 2006 ii. Operators for state transition depend upon the problem. iii. Goal test. iv. Data Structure for State representation (generally using flags). 1. 8-puzzle 2. River Problem 3. 8-Queen possible 3d extension 4. Robot path finding 5. Robot block world 6. Water jug problem 7. Rat in the maze 8. Tower of Hanoi 9. Rubic Cube v. Generating choice depending upon the available operators: generating decision tree. vi. Searching the goal state and path to reach goal state in decision tree: Depth first Vs Breadth First Search. vii. Search strategy properties: completeness (yes/no), optimality (yes/no), and Time and Space complexity of algorithm. 3. Assignment: (group of 2 students, 5 marks each) B1: WAP for placing maximum number of queen on chess like board of 5x5 cells following the rules of chess. Analyze the complexities of your algorithm. B2: WAP for placing maximum number of Knights on chess like board of 5x5 cells following the rules of chess. Analyze the complexities of your algorithm. B3: WAP for placing maximum number of rooks (n1) and bishops (n2) on a chess like board of 5x5 cells following the rules of chess such that ABS (n1- n2) <=1. Analyze the complexities of your algorithm. B4: WAP for solving 4x4 puzzle (one hole) (re-arrange any user inputted initial pattern of letters into a desired user inputted given pattern). Analyze the complexities of your algorithm. B5: WAP for solving Water jug problem for any user inputted amount with 4 jugs of capacity of 10, 9, 5, and 2. Analyze the complexities of your algorithm. B6: WAP for solving Water jug problem for any user inputted amount with 3 jugs of capacity of 7, 4, and 3. Analyze the complexities of your algorithm. B7: WAP for solving Water jug problem for any user inputted amount with 2 jugs of capacity of 7 and 6. Analyze the complexities of your algorithm. B8: WAP for solving 4x4 puzzle (two holes) (re-arrange any user inputted initial pattern of letters into a desired user inputted given pattern). Analyze the complexities of your algorithm. B9: WAP for solving 4x4 puzzle (three holes) (re-arrange any user inputted initial pattern of letters into a desired user inputted given pattern). Analyze the complexities of your algorithm.
  14. 14. Advanced Data Structures, JIIT Sanjay Goel, 2006 19. 11.04.06 1. Threaded BST Assignment (Group of 2, 7.5 marks each): B1: Create a graph of student records with following attributes: i. Name ii. Roll Number iii. Department The inter-node links represent close friendship between students. One student can have at most 5 close friends. A BST tree is used to index this database on student’s Name. WAP to store this database and answer following queries and perform following operations: i. List the Roll numbers of friends of a given name. ii. List the Names of the friends of given roll number. iii. insertion of new record. iv. deletion of a record v. insertion of a link vi. deletion of a link Use pointer based storage for graph and pointer-less storage for BST. B2: Create a graph of student records with following attributes: • Name • Roll Number • Department The inter-node links represent close friendship between students. One student can have at most 5 close friends. A BST tree is used to index this database on student’s Name. WAP to store this database and answer following queries and perform following operations: List the Roll numbers of friends of a given name. List the Names of the friends of given roll number. insertion of new record. deletion of a record insertion of a link deletion of a link Use pointer based storage for graph and pointer based storage for BST. B3: Create a graph of student records with following attributes: • Name • Roll Number • Department The inter-node links represent close friendship between students. One student can have at most 5 close friends. A BST tree is used to index this database on student’s Name. WAP to store this database and answer following queries and perform following operations: List the Roll numbers of friends of a given name.
  15. 15. Advanced Data Structures, JIIT Sanjay Goel, 2006 List the Names of the friends of given roll number. insertion of new record. deletion of a record insertion of a link deletion of a link Use pointer-less storage for graph and pointer based storage for BST. B4: Create a graph of student records with following attributes: • Name • Roll Number • Department The inter-node links represent close friendship between students. One student can have at most 5 close friends. A BST tree is used to index this database on student’s Name. WAP to store this database and answer following queries and perform following operations: List the Roll numbers of friends of a given name. List the Names of the friends of given roll number. insertion of new record. deletion of a record insertion of a link deletion of a link Use pointer-less storage for graph and pointer-less storage for BST. B5: Create a graph of employee records with following attributes: • Name • Employee Number • Department The inter-node links represent shared postings between employees. One employee can have at most 4 shared postings with other employees. A BST tree is used to index this database on employee number. WAP to store this database and answer following queries and operations: List the department of co-posted employees of a given name. List the Names of the co-posted employees of given employee number. insertion of new record. deletion of a record insertion of a link deletion of a link Use pointer-less storage for graph and pointer-less storage for BST. B6: Create a graph of employee records with following attributes: • Name • Employee Number • Department The inter-node links represent shared postings between employees. One employee can have at most 4 shared postings with other employees.
  16. 16. Advanced Data Structures, JIIT Sanjay Goel, 2006 A BST tree is used to index this database on employee number. WAP to store this database and answer following queries and operations: List the department of co-posted employees of a given name. List the Names of the co-posted employees of given employee number. insertion of new record. deletion of a record insertion of a link deletion of a link Use pointer-less storage for graph and pointer based storage for BST. B7: Create a graph of employee records with following attributes: • Name • Employee Number • Department The inter-node links represent shared postings between employees. One employee can have at most 4 shared postings with other employees. A BST tree is used to index this database on employee number. WAP to store this database and answer following queries and operations: List the department of co-posted employees of a given name. List the Names of the co-posted employees of given employee number. insertion of new record. deletion of a record insertion of a link deletion of a link Use pointer based storage for graph and pointer-less storage for BST. B8: Create a graph of employee records with following attributes: • Name • Employee Number • Department The inter-node links represent shared postings between employees. One employee can have at most 4 shared postings with other employees. A BST tree is used to index this database on employee number. WAP to store this database and answer following queries and operations: List the department of co-posted employees of a given name. List the Names of the co-posted employees of given employee number. insertion of new record. deletion of a record insertion of a link deletion of a link Use pointer based storage for graph and pointer based storage for BST.
  17. 17. Advanced Data Structures, JIIT Sanjay Goel, 2006 B9: Create a graph of Book records with following attributes: • Title • Author name • ISBN Number • Library Acquisition Number • Publisher The inter-node links represent cross referencing between books. One book can refer to at most 5 other employees. A BST tree is used to index this database on ISBN number. WAP to store this database and answer following queries and operations: List the publishers of books referred by of a given book given its ISBN number. List the publishers of books referring to of a given book given its Title Insertion of new record. deletion of a record insertion of a link deletion of a link Use pointer-less storage for graph and pointer-less storage for BST. 20. 18.04.06 1. Comparison of Linear Index and BST based Index. 2. Indexed BST. 3. ASSIGNMENT (Group of two or alone, 9 marks each) : Modify your last assignment given on 11.04.05 as follows: i. Replace ordinary BST with Threaded Indexed BST. ii. Save and upload your database (graph as well as index) on (and from) file(s). 21. 19.04.06 1. AVL Tree. 2. Bonus Assignment (single student, 5 marks, only for those who scored a total of minimum 20 marks out of 60 in two minor tests and all five lab tests, three tests conducted by seniors in the evenings as well as two tests by faculty during lab time): Modify your last assignment by replacing Threaded Indexed BST with Threaded Indexed AVL search Tree. 22-23. 25-26.04.06 1. AVL Tree: Balancing after Insertion and Deletion. LL, RR, LR, RL, R0, R1, R-1, L0, L1, L-1. 2. TRIE, Compact TRIE.
  18. 18. Advanced Data Structures, JIIT Sanjay Goel, 2006 24-25. 02.5.06 1. Multi-way Search Trees for creating Index structure for large database: B Tree, B+ Tree, B* Tree: Data structure, Search, Insertion, Deletion. 25. 03.05.06 1. Hashing: Hash function, Synonym, Collision, Collision resolution, Open hashing, Bucket hashing, Closed hashing. **************************************************************** Some relevant quotes: 1. I cannot teach anybody anything; I can only make them think. – Socrates 2. You cannot teach people anything. You can only help them discover it within themselves. - Galileo 3. I do not teach anything. I create conditions for learning. 4. The only source of knowledge is experience. - Einstein

×