Answer to Question #268898 in Python for Isabel Cortez

Question #268898

1. Data Structures and Algorithms (Project 1)


INSTRUCTIONS:


Create a program using the following features:

* Array

* Class

* Specific Sorting Algorithm

* Specific Searching Algorithm



What is "Specific Sorting Algorithm" and "Specific Searching Algorithm"?

* sorting code that uses a specific sorting process, here is the list of sorting algorithms that you will use

Bubble

Selection

Insertion

Merge

Shell

* searching code that uses a specific searching process, here is the list of searching algorithms that you will use

Linear

Binary

Fibonacci

Jump


1
Expert's answer
2021-11-19T17:09:11-0500
# Searching an element in a list/array in python
# can be simply done using \'in\' operator
# Example:
# if x in arr:
#   print arr.index(x)
  
# If you want to implement Linear Search in python
  
# Linearly search x in arr[]
# If x is present then return its location
# else return -1
  
def search(arr, x):
  
    for i in range(len(arr)):
  
        if arr[i] == x:
            return i
  
    return -1

Need a fast expert's response?

Submit order

and get a quick answer at the best price

for any assignment or question with DETAILED EXPLANATIONS!

Comments

No comments. Be the first!

Leave a comment

LATEST TUTORIALS
New on Blog
APPROVED BY CLIENTS