CSCI 3212 Lab 1
Due Sunday, 01/28/2024, by midnight (23:59, EST)
Announcements
Goals
The goals for this lab assignment are:
-
Review the Data Structure Course
1. Fibonacci Sequence
-
Objective:
Implement and analyze two different methods for computing the nth Fibonacci number, where 0 < n ≤ 200.
1.1. Implementation
-
Iterative Method:
-
Implement a function fibonacciIterative(n) that calculates the nth Fibonacci number using an iterative approach.
-
Ensure your solution handles edge cases (e.g., n = 1 or 2).
-
-
Recursive Method:
-
Implement a function fibonacciRecursive(n) that calculates the nth Fibonacci number using a recursive approach.
-
Consider using memoization to optimize the recursive solution. Optionally, implement a function fibonacciRecursiveMemoized(n) for this.
-
1.2. Analysis and Optimization
-
Time and Space Complexity:
-
Analyze and explain the time and space complexity of both your iterative and recursive implementations. How do these complexities change with the value of n?
-
For the memoized version, discuss how memoization impacts the time and space complexity.
-
-
Performance Comparison:
-
Compare the performance of your iterative, recursive, and memoized recursive solutions. You may use empirical data by measuring the execution time of each method for different values of n.
-
Discuss the benefits of using recursion with memoization over the simple recursive approach.
-
1.3. Real-World Application
-
Research and write a brief explanation about how the Fibonacci sequence is used in real-world applications. This could include examples from nature, art, computer science, or other fields.
1.4. Documentation and Testing
-
Ensure your code is well-documented, explaining the logic behind your implementation.
-
Write test cases for your functions, ensuring they handle various scenarios correctly, including edge cases.
1.5. Optional Challenge
-
Explore tail recursion and its benefits. Can you modify your recursive solution to be a tail-recursive function? Explain the differences and benefits in terms of performance.
2. Self-evaluation about Data Structure
2.1. Which semester did you take the Data Structure course?
2.2. What grade did you got?
2.3. Course materials: Syllabus, course link.
3. Submission Guide
-
Each student only submits one file, lab_1_lastname.zip(file size less than 5 M), including
-
A Code folder for your Java code files, including all the programming tasks mentioned above.
-
Notes_lab_1_lastname.txt for your notes, including all the writing tasks mentioned above.
-
4. Notes
-
Submit your zip file for lab 1 to Blackboard.
-
Lab assignments will typically be due by midnight on Sunday.