C463/B551/I400 Artificial Intelligence
Dana Vrajitoru

C463/B551/I400 Homework 1

Due date: Wednesday, September 3, 2025.


Ex. 1 Python Review

Write a Python script containing the following functions:

a. Read a CSV file.

A function called readCSV(filename) that reads in a file containing 2D data (rows and columns) in the comma separated value (csv) format. The result of the function should be a 2D list, meaning a list where each element is a list containing one row of data (one data entry). You can assume that the file contains a number of rows of data, where each row contains the same number of real values separated by commas. For this, you can open a text file in read with an instruction

fin = open(filename, 'rt')

Then you can read one line at a time from it with

line = fin.readline()

or just use a loop

for line in fin:

This inputs the line as a string. You need to break it down into strings containing individual numbers with line.split(",") and then convert each element to a float with the function float. Both of these return the result instead of doing the operation in place.

For the result of the function, you can start with an empty list [] and then use the function append to add elements to it. You will need to declare an empty list for each row, add the numbers in that row to it one by one, and then add the whole row to the result you will return. 

b. Shuffle the data.

Write a function shuffleData(data) where data is assumed to be a list. The function should be based on the following algorithm:

for i from 0 through size-2:

j = randint(i, size-1)
swap(data[i], data[j])

Since lists are mutable in Python, the function doesn't need to return anything. You will need to import the module random and use the function randint(low, high) that generates an integer between low and high, including both. Applied to the data obtained from the first function, this should swap entire rows at a time, which is what we want. 

c. Display the data

Write a function called outputData(data) that display data of the form read from point a such that each row is displayed on one line. If the data table is small enough, we should see the rows more or less aligned.

d. Test function

Write a test function testData() that

The test function can take a parameter for the name of the file you want to use, or input it from the user, or use it directly as a constant string in the function call.

Here are a couple of data files you can use to test this function: test1.csv, test2.csv.


Ex. 2 Testing LLMs

Choose 2 or 3 of the following large language models (LLM):

ChatGPT

DeepSeek

Claude

Google Gemini

Microsoft Copilot

Meta AI

Then select one of the following data structures: linked lists, stacks, queues, hash tables, trees, graphs, and ask both of the chosen LLMs a question about an advanced procedure for this data structure. For example, you can ask what are the different types of traversal for binary trees. 

Create a document (text or Word) where you copy the answers from the LLMs as well as the prompt you used and the name of the LLM that you chose. Then add a comment answering the following questions:


Turn in: