Upcoming SlideShare
×

Data Structures 2004

1,246 views
1,166 views

Published on

Lecture notes of Data Structures by Sanjay Goel, July-Dec, 2004, JIIT Noida

Published in: Technology, Education
1 Like
Statistics
Notes
• Full Name
Comment goes here.

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

Views
Total views
1,246
On SlideShare
0
From Embeds
0
Number of Embeds
3
Actions
Shares
0
8
0
Likes
1
Embeds 0
No embeds

No notes for slide

Data Structures 2004

3. 3. Lecture Notes, Data Structures Sanjay Goel, JIIT, 2004 4. Compare the run time costs of element deletion from an array with element deletion from a linked list. 5. You can use an additional variable i.e. counter of elements to keep the count of elements in the array and linked list. You can also consider initialising array with values out of the permitted range e.g. if the values are expected to be within –20 to 20, you can use –100 or 100 to indicate empty elements. Zero in this case is a legal value within the range and does not indicate emptiness. 6. Design a data storage scheme for storing polynomial functions and series of numbers. Design an algorithm to 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 : 7. 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. 8. Design a dynamic data structure for storing a randomly ordered collection of single variable polynomial functions and another static data structure 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. Lecture 7 (2 hr.) (12.08.04) (Class strength : Approx. 200 students) Post class Assignment: 1. Modify the last assignment of previous lecture to take input from text file and also output the result into a file. 2. WAP to shift up the elements of an array stored in a file after deleting one element from in between. 3. WAP to circularly shift up the elements of an array stored in a file after deleting one element from in between. Lecture 8 (1 hr.) (17.08.04) (Class strength : Approx. 230 students) 1. Write an algorithm for reversing the order of elements in an array. 2. What does the following algorithm do? Illustrate your answer with example. void WhatdoIdo (NodePtr p) { if (p) { WhatdoIdo (p -> next); cout << p -> data; }; } 2.1 What if the order of statements in the inner block is exchanged? 2.2 Transform this algorithm into an equivalent non-recursive algorithm. What are your options ? Evaluate the options. 3. Option 1: Do not use any extra memory for doing the task Option 2: Use an Array to copy the elements and then print the elements of array in reverse order as array elements can be easily printed in any order.
4. 4. Lecture Notes, Data Structures Sanjay Goel, JIIT, 2004 Option 3: Use a linked list to copy the elements in reverse order , insert the new node in front of the existing list (rather than at the back). 4. WAP based on each option. 5. As software designers, we use additional memory for designing more efficient algorithms. This additional memory can be used in various forms. Each form has some merits and demerits. 6. Unless specifically permitted or required, changing the input (form or the content) is not acceptable in most cases. Lecture 9 (2 hr.) (19.08.04) (Class strength : Approx. 180 students) 1. Pick one of the following or any other similar popular family game and propose a design for a software version Snakes and Ladders Ludo Chess Any Cards based Game Make-a-word Rubic Cube You can design you software either on the model of ‘play with computer’ or ‘play through computer’ 2. A design team has conceived the following initial specifications of a search engine for a large company’s internal Digital Library Only specially authorised users can upload new documents or new versions of old document. All employees can look at the documents. Information systems department will create, update and maintain a list of keywords for faster search facility. The search engine users can also search by entering any word through the keyword. Searched documents are to be listed as follows: Case A, Faster search on a listed keyword : As per the frequency of occurrence of the word i.e. the documents having higher “density” of the chosen keyword will be listed before the documents having lower density, where, density[k, d] =(Occurrence count of the word k in d)/(word count in d) Case B, Search by entering a word though the keyboard : As per the frequency of usage of a document, where usage is defined as number of times a document is opened by users through the search engine. Draw a design diagram (Concept map) for this problem. Refer to ADS (DSII 2002-03) lecture #6 slide 6 to 27 and Lecture #9 slide no 12-13. 2. Progressive development of software. Programming is only a small part of the process. All Engineering design require and create drawings. It is possible to create software through its architectural drawings. It becomes much simpler a process that is easy to follow and monitor. Stage 1. Write a design story. Stage 2. Prepare a checklist of nouns and verbs in the design story. Stage 3. Draw 1st level Concept map of software. Draw a graph of Nouns and verbs. Stage 4. Draw 2nd level Concept map of software. Put verbs inside oval shape and nouns in rectangular shaped boxes. Stage 5. Draw 3rd level Concept map of software. Put examples of data in the noun boxes. Stage 6. Draw 4th level Concept map of software. Identify data tanks (rectangular boxes with multiple record in the same format but with different values) and put them inside double lined rectangular boxes. Suitably label data tanks. Iterate through above cycle and critique in a group. Check for inconsistencies and incompleteness at each iterative stage and update your concept map. Coding will follow in later stages. 4. While flowchart gives a process centric view of the software, Concept map gives a data centric view.