top of page

Data Structure Homework Help | Sample Practice Set

Problem 1

Sensor Database

Physical Environment Sensor Network: A sensor network consists of spatially dispersed and dedicated sensors for monitoring and recording physical conditions of environment like temperature, sound, humidity, wind, and so on for multiple stations (you can consider different areas in city). The data from all sensors is collected at central location. Each sensor records the corresponding data at continuous time interval daily. Each sensor is represented by sensor ID (integer), sensor type, data it senses, time interval during which it senses the conditions continuously. Two sensors are said to be neighbours and can communicate if they are located at distance of 1000m apart. Solve the following question.


1. Write a function create_data_structure () which will formulate the above mentioned sensor network in software. Data fields in the structure should include-

  • sensor_ID (integer)

  • sensor_type (char)

  • sensor_location(charater)(or sensor station)

  • duration(time interval ex. 5 min- it means that a sensor senses the temperature, humidity etc. after every 5 min.)

  • nearby_sensors (mostly array containing sensor_ID and distance in meters)

Central repository is the location where data from all sensors is collected and it should include following things-

  • sensor_ID

  • Date

  • Time

  • data(integer or float)


2. Retrieve_info() functions retrieves the data for sensors specified by following conditions

A. Depending on sensor type (retrieves till date data)

B. Depending on specified date for specific sensor type

C. Depending on specific time interval for specific sensor type

- for specified date (single day)

- for specified date range (multiple dates)


Implement above functions for particular station as well as for all stations.


3. Write a function find_communicating_neighbours () which should find all the neighbours of specified sensor. This function should check neighbourhood conditions mention above and should create the chain of neighbours. Ex. If node B and E is neighbour of A. C and D are neighbours of B. Then output should be like


A B->C

-> D

E


4. Adapt the data structure created by create_data_structure () for sensor type which records multiple quantities. Ex. Air quality index (AQI) sensor which records entities like PM10, PM 2.5, nitrogen dioxide, sulphur dioxide, carbon monoxide, ground level ozone etc. and tries to find out Air quality level and pollution level. AQI is measures based on the average quantity of a particular entity measured over a standard time interval. Standard time interval for measuring averages is different for different entities (24 hours for most of the entities, 8 hrs. For PM 2.5). There should be provision for storing standard time interval for each independent entity in existing data structure. Final AQI is the highest of the AQI values calculated separately for each entity. AQI value for finding health status is as follows














  • Write a function to report or display the month during which maximum AQI is reported for all years for all stations.

  • Write a function to find out the date on which particular health status is recorded (input health status and station from user i.e. for which health status user wants to go)

  • Write a function to display the dates on which hazardous health status is recorded for all stations.


Problem 2

Flight Management System:

A Flight Records Management System can be implemented as an array of structures, where each element of the array represents a flight record and each record has fields like flight name, flight id, flight capacity, flight arrival time, flight departure time, flight class (VIP, VVIP, public), and any other field you may want.


The combined pair of flight id and arrival time of the flight can be thought of as a key in the list and represents a unique record in a single list. The list of records should always be kept sorted (after any operation) on the basis of key. Also kept are 3 sorted lists, one each for every class of the flight.


Write following functions and a program that lets user to use any of these operations.


-insert

  • Inserts (if the entry is not present in the list) or updates an element (if the entry is present in the list)

  • I/p parameters: flight name, flight id, flight capacity, flight arrival time, flight departure time, flight class (VIP, VVIP, public).

  • O/p – Entry should be added/updated appropriately. The return parameter can specify if the insert operation is successful or not.

-delete

  • Deletes an elements

  • i/p parameters: o list (array of records from which the entry needs to be deleted) o flight id of the flight whose records need to be deleted.

  • o/p parameters: To know the operation is successful or not you have to print the appropriate message.

-getNumFlights

  • i/p parameters: list (array of records)

  • o/p: number of flights in the list. -isEmpty

  • i/p parameters: list (array of records)

  • o/p: To know if the list is empty or not

-isFull

  • i/p parameters: list (original array of records)

  • o/p: To know if the list is fully occupied or not

- geFlightWithtLongeststay

  • i/p parameters: list (original array of records)

  • o/p : flight(s) with max stay time (departure time – arrival time)

- getSortedOnArrivalTime

  • i/p parameters: list (original array of records)

  • o/p parameters : list sorted based on arrival time

- getSortedOnDepartureTime

  • i/p parameters: list (original array of records)

  • o/p parameters : list sorted based on departure time

- getSortedOnStayTime

  • i/p parameters: list (original array of records)

  • o/p parameters : list sorted based on stay time (departure time – arrival time)

UpdateFlightStatus

  • Parameters: list (original array of records), list2 (each record containing flight id, flight name, status (DELAY, ON_TIME, CANCELLED, PROMOTED), delay time. If status is DELAY, then delay_time gives us the time by which the flight is delayed for arrival. The stay time (difference between arrival and departure times) for the flight remains the same. If status is PROMOTED, it promotes the flight class, so the original flight class and promoted flight class to be provided.

  • i/p paraments:

  • o/p: Updates the original list according to status. The Output must be sorted on key. Also updates the 3 sorted lists maintained for each flight class.

-list Unique

  • i/p parameters – A list of record which contains duplicate entries (with same flight name and flight id )

  • Output – Remove duplicate entries if present. Retain the occurrence with minimum delay, in case of duplicates.


Problem 3

Library System

In an institute library, the following information are stored corresponding to each book:

  1. Name of the book

  2. Subject

  3. Authors (surname first) of the book

  4. Accsession number (an accession number is a sequential number assigned to each record or item as it is added to a library collection or database and which indicates the chronological order of its acquisition)

  5. New print or reprint with year of publish

  6. Issued/available

All books are stored in the database in sorted order of subject. All books of the same subject, are sorted according to title. All books of same title are sorted according to names of authors (if at all exists). All copies of the same book are sorted according to year of print.


One member database is maintained with the following information:

  1. Member name

  2. Department

  3. Status/designation (student/faculty)

  4. Member ID

  5. Number of books issued

When a new member is formed, his/her name is appended to the end of the array of members.


To search the availability of a book in the library, the title of the book should be used as the search key (if the entire title is not known then at least two keywords of the title can be used as the search key (e.g., for “Design and Analysis of Algorithm”, the search key may be “Design Algorithm”). If the title is not known properly then the name of the author can be used for searching a book. For the first case, if the book is enlisted in the library then all the corresponding information (author’s name, year of print, number of copies present in the library with their availability status [issued (0), non-issued (1)]) is shown. For the second case, all books of the author will be displayed.


To issue a book the location of the book is to be known. The location of the book is identified with following information:


6. Hall number

7. Rack number

8. Row number


The issue operation also displays the date of return/renew (for faculty, duration is one month and for student it is 2 weeks). A member can also check the return or renew date of all the books he/she has issued. A renewed permission can be extended upto 3 times. The maximum number of issues (i.e, number of books) for a faculty is restricted to 4 and that for students is restricted to 2 books.


A fine against late return is computed as 50 paise/day unanimously.


The insertion of a book in the library, should consider two different cases. A new print of an available book or a new book which was not available earlier in the library.


(i) Design such a library database by defining required number of data structures using “array of structures”. Separate array should be created for faculty and student member.


(ii) Define functions for insertion of a book by considering various conditions mentioned above.

(iii) Define functions to create new faculty or student member.


(iv) Find and display the names of the faculty and the student who currently issued maximum number of books.


(v) Write a function to calculate fine against a member and display the names of the borrower having maximum fine till date.


(vi) Sort and display the names of the borrowers in descending order of number of borrows currently in their possession. If more than one person have same number of books borrowed then faculty name comes first. If the borrowers having same number of borrows are in the same category (both are faculties or students) then display their name in alphabetical (dictionary) order.



Problem 4

Resident Record System

The following structure defines the accommodation records maintained for all residents of VNIT campus.


struct accommodation

{

char firstname[50];

char lastname[50];

char accommodation_type [20];

int idtype;

struct idnum

{

char aadhaar[15];

char passport[15];

char empcode [15]; };

char address[100];

}


The field idtype takes a value 0, 1, or 2, indicating whether the ID is Aadhaar Card number, Passport number, or Employee code.


(a) Write a function, InsertRecord(), which reads a record from user into an array B of structures.Example records: Suman Dey Type-II 2 2022513 Formal methods lab, VNIT, Nagpur. PramodGupta Type-I 1 ZF351076 Dept. of CSE, VNIT, Nagpur. After reading idnum you must treat the rest of the line as the address. The other fields ofidnum should be null.

(b) Write a function removeDuplicates() to remove the duplicate entries from the records.


(c) Write a function, printRecords(), which prints the records in B so that all those who have provided passport numbers are listed first, all those who have provided Aadhaar card numbers are listed next, and all those who have provided Employee code are listed at the end.


(d) We wish to print the records in B in alphabetic order of names (sorted by firstname and ties resolved by lastname). Instead of sorting the records in B, we will create a thing called index. For this purpose, create an array, index, of N integers, and then for each k, 0 ≤ k < N, populate index[k] with the index of the record containing the kth name in alphabetic order. For example, the index for the records of part (a) will be as follows: index [0] = 1 index [1] = 0. Write a function printSortedRecords() that uses the arrayindex[], to print the records in alphabetic order of names.


(e) Write a search() function that prints the whole information for a given Employee name. If there are multiple records with same name then print them in alphabetic order.


(f) Write a function deleteRecord() to delete the record of a given employee, the input to this function should be idtype and idnum. Make sure to change the index array after deletion.


(g) Write the updateRecord() function to update the record of an employee. The field to update should be the user input. Make sure to change the index array after updating firstname or lastname.


(h) Create an additional structure having 10 blocks of each type of accommodation. The types of accommodation are type-I, type-II, type-III, and type-IV. Mark the blocks as accommodated/not accommodated. Write a function specialRequestAllocation() to change a type of block requested by an employee depending on the availability of that type of block




Contact Us at:

Realcode4you@gmail.com to get instant help or If you have any data structure related problems or need any support then our expert ready to help you.

bottom of page