0% found this document useful (0 votes)
9 views

DataStructures FALL 2024 Assignment01

Uploaded by

i232082
Copyright
© © All Rights Reserved
We take content rights seriously. If you suspect this is your content, claim it here.
Available Formats
Download as PDF, TXT or read online on Scribd
0% found this document useful (0 votes)
9 views

DataStructures FALL 2024 Assignment01

Uploaded by

i232082
Copyright
© © All Rights Reserved
We take content rights seriously. If you suspect this is your content, claim it here.
Available Formats
Download as PDF, TXT or read online on Scribd
You are on page 1/ 6

NATIONAL UNIVERSITY OF COMPUTER & EMERGING

SCIENCES ISLAMABAD CAMPUS

Data Structures FALL - 2024

ASSIGNMENT - 1

LET’S HAVE SOME FUN

Due Date: 18th September, 2024


Time: 11:59 PM

Please follow the following submission instructions. Failure to submit according to the format
would result in a deduction of marks. Submissions other than Google classroom (e.g., email etc.)
will not be accepted. No late submission will be accepted. Correct and timely submission of the
assignment is the responsibility of every student; hence no relaxation will be given to anyone.

Instructions: Total Marks: 160

1. Make sure that you read and understand each and every instruction. If you have any
questions or comments, you are encouraged to discuss your problems with your
colleagues (and instructors) on google classroom.

2. The student is solely responsible for checking the final .cpp files for issues like
corrupt files, viruses in the file, or mistakenly exe sent. If we cannot download the
file from Google Classroom, it will lead to zero marks in the assignment.

3. If there is a syntax error or usage of global/static variables in the code, zero marks
will be awarded in that part of the assignment.

4. Displayed output should be well mannered and well presented. Use appropriate
comments and indentation in your source code.
Honor Policy

Plagiarism is a grave academic offense that can severely undermine your academic integrity and
reputation. Any instance of a student found to have plagiarized their assignment, whether from a
peer or external source, will be subject to strict consequences. This may result in a zero score for
the current or all assignments, or in severe cases, even a failure in the course. Furthermore, all
instances of plagiarism will be promptly reported to the Disciplinary Committee for further
action.

Submission Guidelines

1. For each question in your assignment, make a separate .cpp file e.g., for question 1,
make q1.cpp and so on. Each file that you submit must contain your name,
student-id, and assignment on top of the file in the comments.

2. Keep a backup of your work always that will be helpful in preventing any mishap
and avoid last hour submissions

3. Combine all your work in one folder. The folder must contain only .cpp files (no
binaries, no exe files etc.).

4. Rename the folder as ROLL-NUM_PROGRAM_SECTION (e.g.,


i230001_DS/AI) and compress the folder as a zip file. (e.g., i230001_DS/AI.zip).
Strictly follow this naming convention, otherwise marks will be deducted.

5. Submit the .zip file on Google Classroom within the deadline.

Note: Start early so that you can finish it on time.


Question: 01 80 Marks

Cache memory originated in the 1960s as a solution to bridge the speed gap between fast
processors and slower main memory. Early systems like the IBM System/360 used buffer storage
to enhance performance. By the 1970s, cache memory became a standard feature in computers,
storing frequently accessed data for faster retrieval. The 1980s saw the introduction of
multi-level caches (L1, L2) to further optimize performance. Today, cache memory plays a
critical role in modern CPUs, drastically improving computational efficiency.

Problem Statement:

You are required to implement a cache simulation. The memory data is stored in a CSV file,
which will be provided with the question. Each time a store operation (write) or load operation
(read) is requested, you will check the cache and follow the appropriate policies. Cache can be
considered as a singly linked list.

Load Operation:

In a load operation, simply check the cache to see if the address is present.

● Cache Hit: If the address is in the cache, do nothing.


● Cache Miss: If the address is not in the cache, append the cache.

Store Operation:

For store operations (writes), check if the address is already present in the cache:

● Cache Hit: (address is found in the cache)

Write Through: Update both the cache and the memory CSV file immediately.
Change the data in that address of csv and the cache.

Write Back: Update only the cache and mark its dirty bit variable 1. Write to the
memory CSV file when the cache entry is evicted from a load operation.
● Cache Miss: (address is not found in the cache)

Write Allocate: Load the data from the memory CSV file to the cache, update the
cache, and also update the CSV.

Write Around: Write directly to the memory CSV file without updating the
cache.

Specifications:

● At the start of the program you have to ask the user which policy to adopt write through
and write allocate for cache hit and miss or write back and write around for cache hit and
miss respectively.
● Note that the user will keep entering the address and data that should be circulated around
this process. User will enter the address in decimal and the data in hexadecimal but the
cache stores data in decimal and memory in hexadecimal. You have to cope with this
situation.
● The memory is stored in a CSV file, where each row corresponds to a data segment. For
store operations, any changes should overwrite the relevant entry in the CSV file.
● At the start of the program, the user will specify:

Cache Hit Policy: Write Through or Write Back

Cache Miss Policy: Write Allocate or Write Around

● Load operations should simply check the cache, and if there is a miss, the data should be
added to the cache.
Question: 02 80 Marks

Brief History of Web Usage

The concept of web browsing and history management has evolved significantly. In the 1990s,
early browsers like Mosaic and Netscape Navigator introduced basic navigation features but had
limited history management. By the 2000s, browsers such as Internet Explorer, Firefox, and
Safari enhanced session management and history tracking, adding features like bookmarks. The
2010s saw modern browsers like Chrome and Firefox advanced history management with better
sorting, search capabilities, and device synchronization. Today, browsers offer highly
personalized history management, including suggestions based on browsing patterns and
enhanced privacy controls.

Problem Statement

Browser History Management with URL Handling and Sorting

Implement a class BrowserHistory to simulate a web browser's history management system. The
class should provide functionalities for navigating through visited URLs, managing history, and
sorting URLs based on their visit frequency. Additionally, when URLs are navigated to or
queried, the corresponding HTML files should be opened using the default web browser.

BrowserHistory Class

Methods:

● Visit the specified url from the current page. This clears any forward history. When
visiting a URL, the corresponding HTML file should be opened using the default web
browser.
● Moves backward in history by up to steps. If the history contains fewer steps than
requested, it moves only as far back as possible. Returns the current URL after moving
back and opens the corresponding HTML file in the default web browser.
● Moves forward in history by up to steps. If there are fewer steps available, it moves as far
forward as possible. Returns the current URL after moving forward and opens the
corresponding HTML file in the default web browser.
● Opens the top k most frequently visited URLs in the default web browser, based on the
visit frequency. URLs should be opened in descending order of their frequency.

Constraints:

● Each URL is a string that follows typical URL formatting (e.g., "example.com").
● The number of steps for back and forward will always be non-negative integers.
● The number of URLs and the frequency of visits are handled efficiently within reasonable
limits.

When opening URLs, ensure that the corresponding HTML files are properly handled and
opened in the default web browser.

Source Codes:

● The source code to open html files will be provided along.


● The basic code to make an html file is also provided.

You might also like