CSC 212 Project: Developing a Photo Management
Application
College of Computer and Information Sciences
King Saud University
Spring 2025
1 Introduction
The role of a photo management application is to organize photographs so that they can be
easily accessed. In order to help organize photos, the user can provide tags to describe the
content of the photos. A tag is a keyword associated with a photo. In Table 1, you can find
some examples of photos and the tags that are used to describe them.
2 Project description
The photo manager organizes the photos into albums created by the user. An album is identified
by a unique name and regroups photos that satisfy certain conditions. The conditions used to
create albums consist in a sequence of tags separated by ”AND”:
Tag1 AND Tag2 AND Tag3
Table 1: Example of photos with associated tags.
animal, hedge- animal, bear, insect, butterfly, insect, butterfly,
hog, apple, cab, grass, wind flower, color black, flower
grass, green
animal, fox, tree, animal, bear, animal, wolf, animal, raccoon,
forest, grass panda, grass mountain, sky, log, snow
snow, cloud
1
Photos that contain all specified tags will appear in the album. An empty condition matches
all photos.
Example 1. Using the photos of Table 1, the album with the condition bear, will contain two
photos (that of the panda and the grizzly bear). The album with the condition animal AND grass
will contain four photos (hedgehog, grizzly bear, fox and panda). The album with no tags will
contain all eight photos.
You are required to implement the following classes:
public class Photo {
// Constructor
public Photo(String path, LinkedList<String> tags);
// Return the full file name (the path) of the photo. A photo is uniquely identified by
its path.
public String getPath();
// Return all tags associated with the photo
public LinkedList<String> getTags();
}
public class PhotoManager {
// Constructor
public PhotoManager();
// Return all managed photos
public LinkedList<Photo> getPhotos();
// Add a photo
public void addPhoto(Photo p);
// Delete a photo
public void deletePhoto(String path);
}
public class Album {
// Constructor
public Album(String name, String condition, PhotoManager manager);
// Return the name of the album
public String getName();
// Return the condition associated with the album
public String getCondition();
// Return the manager
public PhotoManager getManager();
// Return all photos that satisfy the album condition
public LinkedList<Photo> getPhotos();
// Return the number of tag comparisons used to find all photos of the album
public int getNbComps();
}
The list of photos that belong to the album is determined at the time when the method
getPhotos in Album is called, not when the album is created.
The method public int getNbComps(): Computes the number of tag comparisons
made to determine the photos belonging to an album. Its purpose is to track efficiency
by counting tag comparisons.
The specification above is mandatory (you are not allowed to change these methods).
However, you are free to add methods to these classes as you see fit.
This is a sample showing you how to use the previous classes:
2
public class Test {
public static void main(String[] args) {
PhotoManager manager = new PhotoManager();
Photo photo1 = new Photo("[Link]",toTagsLinkedList("animal, hedgehog, apple,
grass, green"));
[Link](photo1);
Photo photo2 = new Photo("[Link]",toTagsLinkedList("animal, bear, cab, grass,
wind"));
[Link](photo2);
Photo photo3 = new Photo("[Link]",toTagsLinkedList("insect,
butterfly, flower, color"));
[Link](photo3);
Album album1 = new Album("Album1", "bear", manager);
Album album2 = new Album("Album2", "animal AND grass", manager);
[Link]("Get photo1 path and tags:");
[Link]("photo1 path: " + [Link]());
//You can get the list of tags of photo1 by calling [Link]().
//You can write a method that prints the list of tags of photo1.
[Link]("Get album2 name, condition, and photos:");
[Link]("album2 name: " + [Link]());
[Link]("album2 condition: " + [Link]());
//You can get the list of photos in album2 by calling [Link]().
//You can write a method that prints the list of photos in album2.
[Link]("Delete the photo ’[Link]’:");
[Link]("[Link]");
}
private static LinkedList<String> toTagsLinkedList(String tags) {
LinkedList<String> result = new LinkedList<String>();
String[] tagsArray = [Link]("\\s*,\\s*");
for (int i = 0; i < [Link]; i++) {
[Link](tagsArray[i]);
}
return result;
}
3 Optimizing Photo Retrieval with an Inverted Index
In order to accelerate the search for photos, it is possible to store the tags in an inverted index.
The idea is that instead of having the photos point to the tags, the inverted index will store all
the tags, and each tag will point to all the photos that contain it.
The following is an example showing a partial inverted index for the photos shown above:
3
animal → [Link], [Link], [Link], [Link], [Link], [Link]
apple → [Link]
bear → [Link], [Link]
black → [Link]
butterfly → [Link], [Link]
...
You are required to:
1. Represent the photos-tags association using an inverted index stored in the class Pho-
toManager .
Do not build the inverted index at every call of [Link](), otherwise it will
not improve the performance,
The index must be immediately updated after deleting or adding photos.
The tags associated with a photo cannot be changed.
Deleting photos may cause an existing tag to have an empty list of photos. As a
convention, a tag with no associated photos must be deleted from the index.
2. Use a data structure that allows O(log n) in average to search for a tag.
You are required to implement the following specification (this phase requires the chapter
on BST):
public class InvIndexPhotoManager {
// Constructor
public Photomanager();
// Add a photo
public void addPhoto(Photo p);
// Delete a photo
public void deletePhoto(String path);
// Return the inverted index of all managed photos
public BST<LinkedList<Photo>> getPhotos();
}
4 The report
You must deliver a report written using the provided template. Analyze the theoretical
performance using Big-Oh notation. Document and compare the Big-Oh for the method
[Link] hotos() before using the inverted index and after using it.
5 Deliverables and rules
You have to read and follow the following rules:
1. The submission deadline is: 1/05/2025.
2. You will have to submit the code and the report.
3. All data structures used in this project must be implemented by the students. The use
of Java collections or any other library is strictly forbidden.
4. This project is to be conducted by groups of three students.
4
5. All the members of a group must have the same course instructor.
6. Every member of the group must participate in all parts of the project: designing the
software, programming, and writing the report. Members of the same group may receive
different marks according to their participation in the project.
7. Teams that collaborate using GitHub will receive one bonus point, with the total project
mark limited to 10.
8. Any member of the group who fails to attend the demonstration without a proper excuse
(consult the university and college regulations) shall receive the mark 0 in the project.
9. Cheating in the project will be sanctioned.