National University Of Computer And Emerging Sciences: Cs201: Data Structures (fall 2017)

  • Uploaded by: Faiq Iftikhar
  • 0
  • 0
  • January 2021
  • PDF

This document was uploaded by user and they confirmed that they have the permission to share it. If you are author or own the copyright of this book, please report to us by using this DMCA report form. Report DMCA


Overview

Download & View National University Of Computer And Emerging Sciences: Cs201: Data Structures (fall 2017) as PDF for free.

More details

  • Words: 1,469
  • Pages: 4
Loading documents preview...
National University of Computer and Emerging Sciences School of Computing

Fall 2017

Islamabad Campus

CS201: Data Structures (Fall 2017) Assignment 2 (Deadline: 09th October, 2017 01:00 AM)

Submission: You are required to use Visual Studio for the assignment. Combine all your work (solution folder) in one .zip file after performing “Clean Solution”. Name the .zip file as ROLL_NUM_A_02.zip (e.g. 16i-0001_A_02.zip). Submit zip file on slate within given deadline. Failure to submit according to above format would result in deduction of 10% marks. Comments: Comment your code properly. Marks (minimum 10%) will be deducted for the undocumented code. Deadline: Deadline to submit assignment is 09th October, 2017 01:00 AM. Late submission without any deduction will be accepted till 09th October, 2017 10:00 AM. No submission will be considered for grading outside slate or after 09th October, 2017 10:00 AM. Correct and timely submission of assignment is responsibility of every student; hence no relaxation will be given to anyone. Plagiarism: -50% marks in the assignment if any significant part of assignment is found plagiarized. A code is considered plagiarized if more than 20% code is not your own work.

Photo Organizer You love to keep a collection of memories in form of photographs. You have decided to take advantage of your programming skills in order to keep your memories organized. You want to develop a Visual C++ console application to keep track of your photos. You have decided to assign categories to photos as i) friends, ii) family and iii) trips. You also don’t want these categories to be fixed; you want to start gym soon and you will be adding some more categories like sports and fitness etc. Some of your photos can belong to more than one category like a trip with friends will go to both Friends and Trips.

Page 1 of 4

National University of Computer and Emerging Sciences School of Computing

Fall 2017

Islamabad Campus

Programming Details You have decided to use singly linked list for each category in order to keep track of your photos. Each photo in your software should have only one node. A photo node should be accessible (i.e., pointed) by the linked lists of all categories assigned to that photo (cf. above picture). Moreover, each photo has a default category named as “uncategorized” (not shown in the above picture). A photo node is a data structure containing at least the following data members: 1. Title of the photo 2. Filename along with the path information, i.e., name and absolute or relative path of the folder on the hard disk where the photo is located. 3. Date of the creation of the photo 4. Categories assigned to the photo 5. List of next pointers to enable inclusion of the photo node in the linked lists of multiple categories. For example, a photo belonging to two categories will have two next pointers one for the linked list of each category. The next pointers should be managed in a dynamic manner.

Operations 1) Add/delete category: If a category is removed then the corresponding linked list is also destroyed. Remember each photo has only one node so the nodes belonging to multiple categories must not be deleted. Moreover, the default category of the photos cannot be removed. 2) Add/delete photo: If a photo is deleted then the linked list of all categories (associated with the deleted photo) must be updated. In contrast, if a photo is added, then it must be added to the linked lists of all categories it belongs. On deletion the photo is removed from the default category as well. 1) Add/Remove categories of a photo: You have to update the linked lists of categories appropriately. For example, if a photo is assigned a category “friend” then you have to add the node of that photo to the linked list of category friend by establishing the pointers appropriately. Remember, every photo has only one node and therefore assigning a new category only requires adjusting next pointers. The default category cannot be remove. 4) Display photos in one or more categories: Use the display code (i.e., display_code.cpp) uploaded along with the assignment to display the photos using web browser. The following display options must be supported: 1. Union of photos in the specified categories, e.g., display photos belonging to categories A or B. 2. Intersection of photos in the specified categories, e.g., display photos that belong to both the categories i.e., A and B. 3. XOR of photos in the specified categories, e.g., display photos belonging to one category but not the other. 4. Photo with a specific title. 5. Photos taken on a specific date: MM/DD/YYYY

Page 2 of 4

National University of Computer and Emerging Sciences School of Computing Fall 2017 Islamabad Campus 6. Photos taken in between a date range, e.g., display photos taken from MM/DD/YYYY to MM/DD/YYYY 5) Undo operations: Your program should be able to undo the operations of delete photo and delete category. You have to use dynamic stacks for handing undo operations. Each entry on the stack should save the operation name and all the parameters required to perform the reverse operation. For example for delete photo operation the undo stack should store the operation “delete_photo” and parameters that can be used later for recreating the photo node. In particular, to undo the “delete_photo” operation you will have to i) recreate the photo node containing the information about the title, filename, date etc., and ii) reinsert it into the linked lists of relevant categories.

Additional details and advice Your program should be menu driven and enable users to perform different operations mentioned above. The menu gets input from the users and pass it (as arguments) to the ADT insert, remove, search (i.e., retrieve and return), and display operations. Moreover, memory allocation should be dynamic. Make sure to define a constructor and destructor for all classes. Your destructors must deallocate all dynamically allocated memory.

Code for displaying Images As you cannot display the photos directly on the console without the use of sophisticated libraries, the easy way is to generate HTML files to display photos in browser when necessary. This can be done using the Shell API. C++ provides the library to call the default browser to open up a specified HTML (Assuming that we know the base path of our code). The following code is also uploaded as a .cpp file along with the assignment. #include <windows.h> #include <Shellapi.h> #include<string> #include // Written for the course Data structures in FAST-NU-ISB /* * This code is for creating HTML file at run time and then calling the using shell * API * HTML have a lot of TAGs which we will not be covering all * The code use the ones we need for displaying and formatting the images * Then the ShellExecute will be used to call the created output */ using namespace std; int main() { string html="Your Page Title here

YOUR TITLE OF CATEGORY HERE

"; /* * is a parent tag to be placed in the start of every html page * head tag has a child tag in which we can specify the title of the page "category name in your case" * Body tag actually have all the child tags you can say i will have all the remaining content

Page 3 of 4

National University of Computer and Emerging Sciences School of Computing

Fall 2017

Islamabad Campus

*

tag is a heading of level 1 tag */ string files[3]={"1.jpg", "2.jpg", "3.jpg"}; // links of images (supposed to be taken from linkedlist) string base_link="file:///C:/Users/admin/Documents/"; // of the same folder of images and the one HTML is going to be for(int i=0; i<3; i++) { html+="

"; // constructing images tags with 400x400 dimensions } html+=""; // closing previously opened tags fstream fout; // creating file stream fout.open("file.html", ios::out); // assigning file with create replace mode fout<< html; // writing the html tags to the text file fout.close(); // closing the stream string temp_link=base_link+"file.html"; // creating a full URL to be understood by the browsers if(ShellExecute(NULL, "open", temp_link.c_str(), NULL, NULL, SW_SHOWMAXIMIZED)) // calling default browser with our constructed HTML file { /* COUT NO ERROR */ } else{ // ERROR } }

What to submit Submit your code for this assignment, programmed in C++ using Visual Studio 2017. A document containing the snapshots of your code of main functionalities along with some algorithmic details must be submitted. The document in particular highlight: how the data structures you used helps you in improving run time. The code needs to be well documented so that grader can get a good idea of what each of your procedures do. Program modularity, clarity, documentation etc., along with correct implementation will be considered for grading.

Good Luck!

Page 4 of 4


Related Documents


More Documents from "Moazam Ali"