Upcoming SlideShare
×

# Data Structures 2007

778 views

Published on

Lecture Notes on Data Structures by Sanjay Goel, JIIT, July-Dec, 2007

Published in: Education, Technology
0 Likes
Statistics
Notes
• Full Name
Comment goes here.

Are you sure you want to Yes No
• Be the first to comment

• Be the first to like this

Views
Total views
778
On SlideShare
0
From Embeds
0
Number of Embeds
3
Actions
Shares
0
16
0
Likes
0
Embeds 0
No embeds

No notes for slide

### Data Structures 2007

1. 1. Sanjay Goel, JIIT, DS, 2007 Data Structures Lecture and lab AssignmentsPractice assignments will not be evaluated in lab. However, every fortnight there will bea lab test which will be based on practice assignments. The 4 hrs of lab for all batchesare divided as follows:Lab A: first 2 lab hrs of the weekLab B: next 2 lab hrs of the weekThe test will be conducted in Lab A and Lab B on rotational basis. 1. Assignment #1 : (Practice) • Create and traverse linked list (of structure of anything) and write the records content onto a file. Let them then read the file and recreate linked list in same/reverse order. • Practice simple Graphics 2. Assignment #2 : (Lab A: 10 Marks, last date of evaluation 11.08.07) • create a linked list of at least 20 user inputted point (x,y), store it in file, and save it. • Open the file. draw a polyline using these points. • Ask the user to choose any two points for deletion from the point sequence through keyboard based interface • (No mouse programming). update the file. • clear screen and draw a new polyline using these points. • Ask the user to insert four new points between any two chosen points in the sequence through keyboard based interface (No mouse programming). Update the file. • Clear screen and draw a polyline using these points. • Enthusiastic students are encouraged to do mouse programming and delete and insert points through mouse operations. 3. Assignment #3 : (Practice) • WAP a polynomial calculator with keyboard based UI for following functionality for up to 3 variable polynomials: - Add, subtract, multiply, differential, and integrate polynomials. 4. Assignment #4 : (Practice) • WAP a software to automatically test your polynomial calculator using user specified database of test cases. 5. Assignment #5 : (Lab B: 20 Marks last date of evaluation 11.08.07) • WAP to test if a given chemical equation is balanced. Design a clear UI, data structure and testing algorithm. The equation may have up to 5 terms on each side and up to four elements in each molecule. (10 marks) • Also write a program to test it using user specified set of test-cases. (10 marks) 6. Assignment #6 : (Practice) • Propose a keyboard based UI of a possibly new simple application (new = not used by you) in any application domain of your familiarity. 7. Assignment #7 : (Practice) • Propose the functionality design of a new software.
2. 2. Sanjay Goel, JIIT, DS, 2007 8. Assignment #8 : (Practice) • WAP to perform basic set operations and also optionally draw colored Venn diagram. • In a group of three, critically examine the user interface of some popular software systems and write an essay highlighting the problems related to UI in these software systems. 9. Assignment #9: (Lab A: 10 Marks last date of evaluation 25.08.07) • WAP to input (non-graphically), store, edit, and output (graphically) ER diagrams. Neatly design the UI, DS, Logic and Control. 10. Assignment #10 : (Practice) • Identify the Logic and control part of five programs already written by you. See how can you change the algorithm of these programs without changing the logic. Enthusiastic students are encouraged to refer Robert Kowalski’s paper, Algorithm = Logic + Control, Communication of ACM, July 1979. • Practice Recursion 11. Assignment #11 : (Practice) • Understand the history of evolution of product design by doing a self study of any specific technology other than IT and electronic. Identify what factors led to major changes. How much of this was dependent on change of demand? • Design UI, DS, Logic and control for following problems. Assess your design analytically, experimentally as well as through code review. Also see how different data structure and control designs affect the algorithm’s performance without changing the logic. Draw graphs showing the performance of different algorithm wrt increasing data size. • Store polynomial functions and series of numbers. Test if the given series is a Taylor series approximation (at x) for a given polynomial function and x0. Taylor series approx. of a given function is as : While equating real numbers do not use ==, instead, check if abs (n1-n2) is <= e1, where e1 is very small real number and its value depends on application. See how different data structure and control designs effect the algorithm’s performance without changing the logic. • Design a dynamic data structure for storing a randomly ordered collection of single variable polynomial functions and another static data structure
3. 3. Sanjay Goel, JIIT, DS, 2007 for storing randomly-ordered collection of real number-sequences. The records in both the collections also should have additional provision for storing indices of all the matching entries (if any) in another collection. One entry in any collection may match with none, one or many entries in another. A number-sequence is declared as matching with a polynomial, if all the numbers in the sequence match with corresponding terms of the Taylor series expansion of a function for given x and x0 within the limits of a user-defined ‘permitted-mismatch’. Design an algorithm for updating matching indices in both the collections for a given user-defined input of ‘permitted-mismatch’, x and x0. 12. Assignment #12 : (Practice) • Refer Sander’s paper “Using Jackson diagrams to classify and define data structures” (ACM SIGCSE Bulletin Feb 1983) for diagrammatic representation of DS. Represent the data structures of all the assignments of this course using this method. • Using this method draw a DS diagram for storing Book. • Understand and analyze the relation of UI, Algorithm and DS in the context of popular Software. 13. Assignment #13 : (Practice) • Learn about ASCII codes. 14. Assignment #14 : (Lab B: 10 Marks last date of evaluation 28.08.07) • Write a program to create a linked list of 10000 nodes of even numbers in increasing order starting from zero. (0 mark) • Write four versions of programs for printing this linked list in backward order by varying data structure in your program. Understand the relationship of DS with algorithm. Empirically compare the memory requirement and run time efficiency of these programs. (2+2+2+2+2) 15. Assignment #15: (Practice) • Refer: G. M. Galler Algorithms: evaluation of the Legendre polynomial Pn(X) by recursion June 1960 Communications of the ACM, Volume 3 Issue 6 • Practice recursion: o Binomial coefficient o Chebyshev Polynomial o Laguerre Polynomial o Hermite Polynomial o Legendra Polynomial o Bessel Function • Practice multi-way recursion. Fibonacci, Ackerman, and so on. • Create multi-way linked data structure, and populate it with some data to create varied configurations of data. Use various forms of multi-way
4. 4. Sanjay Goel, JIIT, DS, 2007 recursion to display the subset of stored data in this data structure in many different ways on varied configurations of data. Compare the hand simulated results with computer outputs. Practice at least 20-30 cases. • Store 5 variable multi-function truth table using at least four different data structures. Write program to create and use this data. 16. Assignment #16: (Practice) • Refer: • Ivan B. Liss, Thomas C. McMillan, Fractals with turtle graphics: a CS2 programming exercise for introducing recursion, ACM SIGCSE Bulletin , Proceedings of the eighteenth SIGCSE technical symposium on Computer science education SIGCSE 87, Volume 19 Issue 1 , February 1987 • Peter E. Oppenheimer, Real time design and animation of fractal plants and trees, ACM SIGGRAPH Computer Graphics , Proceedings of the 13th annual conference on Computer graphics and interactive techniques SIGGRAPH 86, Volume 20 Issue 4, August 1986 • Aaron Gordon, Teaching recursion using recursively-generated geometric designs, Journal of Computing Sciences in Colleges, Volume 22 Issue 1, October 2006, ACM Digital Library • Practice recursive programs for simple geometric fractals like Koch curve, Sierpinski Triangle, Cantor set and so on. Try different configurations of multi-way recursion call for each of these fractals. Analytically estimate and experimentally verify the effect of changing the order of recursive calls on the order of growth of the graphic pattern. 17. Assignment #17: (Lab A: 10 Marks last date of evaluation 4.09.07) • Write a non recursive program for drawing fractal such as Koch Curve / Sierpienski Triangle/ Cantor Set/ Sierpienski Carpet /Box Fractal/Cantor Square/ Haferman Carpet/Tree or some other fractal that basically uses the logic of multi-way recursion. 18. Assignment #18: (Practice) • WAP for doing Binary search using recursive as well as non recursive techniques. • Write non-recursive programs for drawing more fractals. Generate varied growth patterns using varied control strategies on the same logic. Understand the DS requirements for each case. 19. Assignment#19: (Practice) • The shape of the initial polygon (Level (L) =1) is repeatedly transformed till the perimeter of the resultant polygon becomes more than 1000 times the initial perimeter using 5-segment Koch curve process for each polygon- segment. Design an algorithm to carry out this transformation on the initial polygon and store the vertices of each stage of new polygon in an appropriate Data structure. Propose an algorithm for drawing the polygon for user
5. 5. Sanjay Goel, JIIT, DS, 2007 specified ‘stage/level’ (L= 1, 2, 3…) using this stored data without regenerating the points. 20. Assignment#20: (Lab B: 10 Marks last date of evaluation 20.09.07) • Write a recursive program for checking the feasibility of a Knight to traverse a chessboard to a given destination pt. from a given starting pt. Use of Graphics is welcome but not compulsory. [This is based on rat in the maze] (Check with your lab faculty for the batch specific variation of this problem) 21. Assignment#21: (Practice) • Write a recursive program for solving tower of Hanoi for variable number of discs and poles. • Write recursive programs for array and list processing (print elements, add elements, multiply elements, count the number of elements etc.). 22. Assignment#22: (Practice) • Write a recursive program for searching kth smallest and jth largest element in an unsorted array (Median search). 23. Assignment#23: (Practice) • Write recursive program for multiplying two numbers by addition. • Write a recursive program to count the occurrences of a string in a linked list of strings. • Write a recursive program to take n words and print them in reverse order. • Write a recursive program for drawing line, circle, and spiral. • Review iterative versions of selection, insertion, and bubble sort algorithms and propose recursive logic for these. 24. Assignment#24: (Practice) • Write a recursive program for floodfill (x,y,boundary colour, new colour) • Group of three: Write a recursive program for patternfill (x,y, boundary colour, pattern), where pattern is matrix of colours. [These are based on rat in the maze, divide and conquer]. • Group of three: Write non recursive versions of above mentioned Knight Problem, floodfill, and patternfill problems. 25. Assignment#25: (Practice) • Write a recursive program for interpolation search. • Group of three: Write a program to simulate 2d multi limb virtual toy assemblies. Define your own assemblies. [A case of kinematics - 2d graphic transformations (translation and rotation), recursion and data structures]. • Group of three: Write a program to store sphere/ellipse/ paraboloid /hyperbolid / any other kind of 3d object as a polyhedron.
6. 6. Sanjay Goel, JIIT, DS, 2007 26. Assignment#26: (Practice) • Write recursive programs for descending sorting using the sort strategy of selection, insertion, and bubble sort algorithms. Generate and analyze different implementation approaches at least, two, for each. 27. Assignment#27: (Practice) • Write recursive s for implementing 2-way merge sort, 3-way merge sort, and quick sort algorithms. • Implement Merge sort and Quick sort without recursion. • Evaluate the performance of all your sorting programs with varied configurations of input data. • Update your sorting programs to graphically demonstrate the dynamics of sorting algorithms. (Reference: Algorithms by Robert Sedgewick). • Refer: A system for algorithm animation, Marc H. Brown, Robert Sedgewick, ACM SIGGRAPH Computer Graphics , Proceedings of the 11th annual conference on Computer graphics and interactive techniques SIGGRAPH 84, Vol. 18 Issue 3 • Refer: Implementing Quicksort programs, Robert Sedgewick , Communications of the ACM, Volume 21 Issue 10, October 1978. • Sorting on Electronic Computer Systems, Edward H. Friend, Journal of the ACM (JACM), Volume 3 Issue 3, July 1956 • Refer Brian project gallery for beautiful simulation of many algorithms. http://www.brian-borowski.com 28. Assignment#28: (Lab B: 10 Marks last date of evaluation 13.10.07 ) • One unsorted list of integers having 50,000 elements is given. WAP for displaying the elements ranging between 10,000th smallest element to 11,000th smallest element in ascending order. Estimate the number of comparisons required for performing this task using your approach. 29. Assignment#29: (Lab A: 20 Marks last date of evaluation 17.10.07 ) • A large rectangular floor’s area is tiled with thick triangular tiles with grooves between adjacent tiles as shown in figure below. These grooves are to be used for laying several types of cables and pipes. Maximum of three cables/pipes may pass through any groove. However, more are allowed to pass through groove intersections. (a) Propose a machine readable format for specifying the cabling/piping requirements in terms of end points. (b) Propose an output format for a computer generated textual cabling/piping specifications in terms of the complete paths for each cabling/piping requirement. (c) WAP to process the data as in (a) and generate the output as in (b).
7. 7. Sanjay Goel, JIIT, DS, 2007 30. Assignment#30: (Practice) • Develop formula based logic for accessing elements of compactly stored k dimensional triangular matrices with different storage sequences. Using this compact storage, write programs for matrix multiplication and matrix inversion. 31. Assignment#31: (Practice) • WAP for creating and updating a database about inter-webpage links. The program should answer the frequent query - if webpage x is connected with webpage y without accessing the webpage at query time. Your program should also update the database on every insertion/deletion of webpage and/or hyperlinks. Design different types of DS, and corresponding algorithms. Evaluate the performance difference in terms of memory and processing complexity in different mechanisms. (Based on the concepts of sparse matrix and/or graph). • To access some of original and classical papers on sorting, study various papers presented at ACM sort symposium in 1962. Refer the May, 1963 issue of Communications of ACM. • Refer: Review of Storage Techniques for Sparse Matrices, Shahnaz, Rukhsana Usman, Anila Chughtai, Imran R., 9th International Multitopic Conference, IEEE INMIC 2005 • N. Goharian, A. Jain, Q. Sun, "Comparative Analysis of Sparse Matrix Algorithms for Information Retrieval", Journal of Systemics, Cybernetics and Informatics, 2003. 32. Assignment#32:(Bonus marks for theory = 20, Last date: 10 Nov) • This assignment is only open to those whose assignments are up-to-date and regular. Others should first complete at least 80% assignments (Including practice assignments) and show the same to their concerned faculty. Take the prior approval of your lab faculty to undertake this assignment. All students with odd enroll numbers will consult and will be evaluated by faculty in LAB A. All students with even enroll numbers will consult and will be evaluated faculty in LAB B. • Study at least two of the papers recommended so far or otherwise. Take your lab faculty’s prior approval for confirming the choice of the paper. Prepare small report; summarize the paper, analytically and experimentally validate some of the algorithms presented in these papers. The bonus marks will depend upon the quality of the paper chosen by you and your work. 33. Assignment#33:(Practice) • Understand the relationship and interchangeability between Table, Matrix, and Graph representations of databases. Evaluate the pros and cons of these logical representations. Reflect on the implementation options of underlying