Question

In: Computer Science

Python 3! Please provide detailed information and screenshots! This is a practice for you to discuss...

Python 3! Please provide detailed information and screenshots!

This is a practice for you to discuss an implementation of a BST (Binary Search Tree) in a real-life scenario or real business scenario.

What to submit?

1. An introduction with a title of what is the implementation

2. A diagram or design of how the BST is implemented in your scenario

3. Simple explanation of the implementation

4. Can you make it as an application in Python. Yes/No. If Either Yes or No. What it takes to implement or What are the complexities involved.

5. Design of the application - Write down (not the code) design of Data Collection, Storage of data, OOP design of Application, Pseudo Code of the Design or flow chart, UML diagram.

Solutions

Expert Solution

Ans 1.>

In computer science, binary search, also known as half-interval search, logarithmic search, or binary chop, is a search algorithm that finds the position of a target value within a sorted array.Binary search compares the target value to the middle element of the array. If they are not equal, the half in which the target cannot lie is eliminated and the search continues on the remaining half, again taking the middle element to compare to the target value, and repeating this until the target value is found. If the search ends with the remaining half being empty, the target is not in the array.

Ans.2>

This is the diagram of how Binary search works

Ans.3>

Binary Search Tree is a node-based binary tree data structure which has the following properties:

The left subtree of a node contains only nodes with keys lesser than the node’s key.
The right subtree of a node contains only nodes with keys greater than the node’s key.
The left and right subtree each must also be a binary search tree.

Ans.4>

Yes, We can definately make an application of Binary search in python

following is an example

Problem statement − We will be given a sorted list and we need to find an element with the help of a binary search.

Algorithm
Compare x with the middle element.

If x matches with the middle element, we return the mid index.

Else If x is greater than the mid element, then x can only lie in right half subarray after the mid element. So we recur for the right half.

Else (x is smaller) recur for the left half

Recursive Algorithm

def binarySearchAppr (arr, start, end, x):
# check condition
if end >= start:
   mid = start + (end- start)//2
   # If element is present at the middle
   if arr[mid] == x:
      return mid
   # If element is smaller than mid
   elif arr[mid] > x:
      return binarySearchAppr(arr, start, mid-1, x)
   # Else the element greator than mid
   else:
      return binarySearchAppr(arr, mid+1, end, x)
   else:
   # Element is not found in the array
      return -1
arr = sorted(['t','u','t','o','r','i','a','l'])
x ='r'
result = binarySearchAppr(arr, 0, len(arr)-1, x)
if result != -1:
   print ("Element is present at index "+str(result))
else:
print ("Element is not present in array")

Related Solutions

Please attach the output screenshots, narrative descriptions, or paste the Python codes. Please write code to...
Please attach the output screenshots, narrative descriptions, or paste the Python codes. Please write code to print the type of the following variables. Please write down the codes and the output as well. x = 3.5 y = '3.5' z = {1:'John', 2:'Wick', 3:'Barry', 4:'Allen'}
NOTE: Please provide instructions on how to solve it in excel add screenshots Thank you Suppose...
NOTE: Please provide instructions on how to solve it in excel add screenshots Thank you Suppose a random sample of 137 households in Chicago was taken as part of a study on annual household spending for food at home. The sample data is below. For the sample data, compute the mean and the median and construct a box and whisker plot. (Use Excel to Descriptive statistics and copy paste the screenshot here). Are the data skewed or symmetric? Approximately what...
Assume that you intend to practice in a private practice setting in Canada. Please provide a...
Assume that you intend to practice in a private practice setting in Canada. Please provide a clear and exhaustive list of the limits of confidentiality (in simple language that could easily be understood by a client irrespective of level of education). Please also discuss the ethics and laws related to record keeping. Finally, discuss the extent to which the treatment of children can be kept confidential from their parents and at what age they are deemed capable of consenting to...
Please be detailed with your answer to this practice question. practice #8 What are the three...
Please be detailed with your answer to this practice question. practice #8 What are the three attributes of the “ideal” currency and briefly describe the benefits of each? (is this in relation to the impossible trinity concept?)
Please write the program in JAVA and provide me with the output screenshots!! Assignment Objectives •...
Please write the program in JAVA and provide me with the output screenshots!! Assignment Objectives • Be able to write methods • Be able to call methods Introduction Methods are commonly used to break a problem down into small manageable pieces. A large task can be broken down into smaller tasks (methods) that contain the details of how to complete that small task. The larger problem is then solved by implementing the smaller tasks (calling the methods) in the correct...
Please answer using python 3 and def functions! Lab 2 Drill 3: (function practice) create and...
Please answer using python 3 and def functions! Lab 2 Drill 3: (function practice) create and use a function named highest() that takes three inputs and returns the highest number. After you have got it working, try calling the function with inputs ‘hat’, ‘cat’, ‘rat’.
Please provide detailed and insightful responses to this question. Please only respond if you are fluent...
Please provide detailed and insightful responses to this question. Please only respond if you are fluent in English Please provide links to any sources used. Discuss six (6) things you could recommend to the government of either your Region or Province or Country to do to improve the spread of e-business.
Please attach the output screenshots, narrative descriptions, or paste the Python codes when requested. Task 2...
Please attach the output screenshots, narrative descriptions, or paste the Python codes when requested. Task 2 We are producing two types of products, product A and product B. Product A is defective if the weight is greater than 10 lbs. Product B is defective if the weight is greater than 15 lbs. For a given product, we know its product_type and its weight. Design a program to screen out defective products. Starting the program with variable definition: product_type = 'xxx'...
Please attach the output screenshots, narrative descriptions, or paste the Python codes when requested. Given two...
Please attach the output screenshots, narrative descriptions, or paste the Python codes when requested. Given two exam scores, exam_1 and exam_2, write a program to determine if the student makes progress (exam_2 is greater than exam_1). Return “Yes” or “No”. You can use any exam_1 score and exam_2 score for this exercise.
PLEASE PROVIDE A DETAILED RESPONSE. Discuss what motivates a small business to adopt a budgeting system....
PLEASE PROVIDE A DETAILED RESPONSE. Discuss what motivates a small business to adopt a budgeting system. In doing so, consider the attributes of traditional and flexible budgeting. Is flexibility more or less important to small business budgeting system? What are some of the informational systems and organizational challenges in initiating and implementing a budget?
ADVERTISEMENT
ADVERTISEMENT
ADVERTISEMENT