Hello, dear friend, you can consult us at any time if you have any questions, add WeChat: daixieit

CSE-2050 Data Structures and Object-Oriented Design

Assignment - 1

Spring 2023

Purpose:

The purpose of this assignment is to help you strengthen your understandings about the topics related to Object-oriented design, timing analysis and linked-lists. In addition, programming tasks help you practice implementing these concepts.

Instructions:

1.    This assignment should be submitted in a group of up to two students.

2.    All theoretical questions should be answered in the space provided and the scanned copies be uploaded on GradeScope under Assignment 1 Theory category. You can attach extra sheet if needed.

3.    Source files for Programming exercises should be directly uploaded on GradeScope under Assignment 1 Programming category.

Grading Criteria:

1.    Your assignments will be checked by instructor/TA followed by a Viva (if needed).

2.    During the viva, you will be judged whether you understood the question yourself or not. If you are unable to answer correctly to the question you have attempted right, you may lose your points. No excuses/justifications will be entertained.

3.    Zero will be given if the assignment is found to be plagiarized.

4.    Untidy work will result in reduction of your points.

Late submission penalty:

•      1-day late submission – 20% deduction of the maximum allowable marks.

•      2-days late submission – 40% deduction of the maximum allowable marks.

•      No submission will be accepted after two days of the original deadline .

CLO Assessment:

This assignment assesses students for some portion of the following course learning outcomes.

Course Learning Outcomes

CLO Assessed

CLO 1

Write programs in python using imports, functions, and object-oriented programming.

CLO 2

Compare data structures and algorithms based on time and space complexity and choose the correct ones for a given problem.

CLO 3

Implement abstract data types (stacks, queues, dequeues, mappings, priority queues) using various data structures (lists, linked lists, doubly linked lists, heaps, trees, graphs) and algorithms

CLO 4

Use recursive algorithms to solve problems.

Questions

1. Define Class, Instance, Inheritance, Composition, and Polymorphism, with examples .

(5x5 points)

2. Define encapsulation, subclass, superclass, method overloading and method overriding with examples. (5x5 points)

3. Calculate the time complexity of the following codes.

(25x2 points)

Programming Exercises

a. Programming Exercise (1/2) - Running Time Analysis

We have two goals in this assignment:

Use python to fit data with user-defined functions

Plot raw data and a best-fit curve on the same figure

We will use thescipymodule for the first and matplotlib (see lab 3) for the second. You should be able to install both in terminal using pip; e.g.:

pip install scipy

If you are struggling, you may consider using Anaconda - an all-in-one python install designed for data science.

Anaconda includes many common packages, including the ones used here.

Fitting Data

The curve fitting functionality we are interested in is in scipys optimize module. We can fit data to a function of our choice as follows:

from scipy import optimize

params, params_cov = optimize.curve_fit(func, xdata, ydata)

optimize.curve_fit returns two collections - the parameters that make func best fit our data, and the covariance of those parameters (which can be ignored for this assignment).

An example:

from scipy import optimize

from matplotlib import pyplot as plt

# linear fitting function

# the first parameter of a fitting funciton must be x

# subsequent parameters are automatically adjusted by curve_fit

def lin(x, m, b):

return m*x + b

# generate data on y = 1*