Sheet 03
Sheet 03
Introduction to Assignment
Arrays and linked lists are two fundamental data structures in programming, each with unique
characteristics and applications. Understanding their advantages and disadvantages is crucial for
selecting the appropriate data structure for a given task. This laboratory exercise aims to deepen
our understanding of these differences and complement the theoretical knowledge acquired in
the classroom.
• Access Method: Arrays offer fast random access to elements via their indices, making
them ideal for applications requiring frequent indexed access.
• Operations: Insertion and deletion operations in arrays are slower due to the need to shift
all elements following the insertion or deletion point, which can be time-consuming for
large arrays.
• Memory Utilization: Arrays have inefficient memory utilization when not fully used, as
the entire memory block is allocated upfront.
• Access Method: Linked lists are node-based, where each node contains data and a pointer
to the next node. This structure makes random access inefficient, requiring sequential
access to elements.
• Operations: Linked lists excel at insertion and deletion operations because only the af-
fected node and its neighbors need updating, reducing time complexity compared to arrays.
• Memory Utilization: Linked lists utilize memory effectively by allocating it only for the
nodes in use.
March 2025
Summary
In summary, arrays are best suited for scenarios requiring fast access and fixed-size data, while
linked lists are more appropriate for dynamic data sets with frequent insertions or deletions.
Investigation Steps
Part A: Array data structure analysis
1. Write a Java program to create a given array size of n elements. Store values 1, 2, . . . , n
in the array. Modify this base code to include the following:
a) Include a method printElement which can retrieve the n th element and print it to
the console.
b) Include code to calculate the time complexity of the printElement method.
c) Include breakpoints at appropriate places in the program to be used in the debug mode
of the IDE to compute memory usage of printElement via VisualVM software.
2. Find the time and space complexity for different values of the input size n and graph. Use
the graphs to identify the Big-O complexity for time and space.
a) Include a method printElement which can retrieve the nth element and print it to
the console.
b) Include code to calculate the time complexity of the printElement method.
c) Include breakpoints at appropriate places in the program to be used in the debug mode
of the IDE to compute memory usage of printElement via VisualVM software.
2. Find the time and space complexity for different values of the input size n and graph. Use
the graphs to identify the Big-O complexity for time and space.
2
Submission Guidelines
Use the IC03.docx template provided on CourseWEB for your submission. Copy and paste the
Excel diagrams and tables into the template, adjusting section sizes as needed. Only one sub-
mission per group is required. Before uploading, rename the file to IC03 ¡Group Number¿.docx
and convert it to PDF before uploading.
Grading Scheme
This assignment accounts for 5% of your final grade. Each subpart is worth 10 marks, distributed
across the following criteria: accuracy of the estimates, methodology, and the explanation
provided.