0% found this document useful (0 votes)
3 views5 pages

1 Why Data Structures Matter ACT

The document outlines steps for inserting elements into an array at various positions, including the beginning, end, and a specified index. It also includes instructions for writing Python functions to add and delete elements from a list without using built-in methods, as well as a function to return unique values from a list. Additionally, it compares the manual method of obtaining unique values with using Python's set() method, noting that the latter is simpler and more efficient.

Uploaded by

Mr. Beginner
Copyright
© © All Rights Reserved
We take content rights seriously. If you suspect this is your content, claim it here.
Available Formats
Download as DOCX, PDF, TXT or read online on Scribd
0% found this document useful (0 votes)
3 views5 pages

1 Why Data Structures Matter ACT

The document outlines steps for inserting elements into an array at various positions, including the beginning, end, and a specified index. It also includes instructions for writing Python functions to add and delete elements from a list without using built-in methods, as well as a function to return unique values from a list. Additionally, it compares the manual method of obtaining unique values with using Python's set() method, noting that the latter is simpler and more efficient.

Uploaded by

Mr. Beginner
Copyright
© © All Rights Reserved
We take content rights seriously. If you suspect this is your content, claim it here.
Available Formats
Download as DOCX, PDF, TXT or read online on Scribd
You are on page 1/ 5

Why Data Structures Matter?

Professional Elective 2 (Data Analysis for Computer Science)


Name: Paul Adrian F. Galleto
Section: UCOS 4-1

1. Write down your answers below. List down all the steps necessary to:
a. Insertion at the beginning of the array
1. We declare an array
2. Make 2 parameters, one for which array to modify, and the other one is what
element to insert
3. Using insert() to determine where to insert the element
4. Test if the function works

b. Insertion at the end of the array


1. Declare an array
2. Make 2 parameters, one for which array to modify, and the other one is what
element to insert
3. Using append() to insert the element at the end of the array
4. Test if it works
c. Insertion of a single element to an array based on a given index.

1. Declare an array
2. Make 3 parameters, one for which array to modify (arr), where to place the
element (index) and the other one is what element to insert (element)
3. Test if it works
2. Paste a screenshot of the code below. Write a Python function that enables you to add a
new element to a list from scratch . The function should take two parameters: arrayIndex
and givenList. Please keep in mind that the function should not have Python’s pre-built
methods like pop(), append(), and remove().

3. Paste a screenshot of the code below. Write a Python function from scratch that enables
you to delete an element from a list. The function should take two parameters:
arrayIndex and givenList. Please keep in mind that the function should not have
Python’s pre-built methods like pop(), append(), and remove().
4. Paste a screenshot of the code below. Write a Python function that returns only the
unique values from a given list and then write a code demonstrating the use of Python’s
set() method. What are the differences between these two codes you’ve written? Write
your answer below the code.

Set is short and much more easy to use than manual

Manual:

Set:

You might also like