Answer:
Heap is useful when you want to find max/min element in the given list
BinarySearchTree is used if you need sorted elements of the list
Explanation:
Heap is Good at finding Min/Max and it's time complexity is (O(1)), while BST is good at all finds (O(logN)). Insert is O(logN) for Heap and BSTstructures..
Max Heap ensures that elements on higher levels are greater than elements at lower level
MinHeap ensures that elements on higher levels are lesser than elements at lower level
BST gives sorted elements by following order (left,root,right).If we want sorted elements we can go with BST
The basic difference between the two is that files store data, while folders store files and other folders. The folders, often referred to as directories, are used to organize files on your computer
The python program that creates a Bankaccount class for a Bank ATM that is made up of the customers and has a deposit and withdrawal function is given below:
<h3>Python Code</h3>
# Python program to create Bankaccount class
# with both a deposit() and a withdraw() function
class Bank_Account:
def __init__(self):
self.balance=0
print("Hello!!! Welcome to the Deposit & Withdrawal Machine")
def deposit(self):
amount=float(input("Enter amount to be Deposited: "))
self.balance += amount
print("\n Amount Deposited:",amount)
def withdraw(self):
amount = float(input("Enter amount to be Withdrawn: "))
if self.balance>=amount:
self.balance-=amount
print("\n You Withdrew:", amount)
else:
print("\n Insufficient balance ")
def display(self):
print("\n Net Available Balance=",self.balance)
# Driver code
# creating an object of class
s = Bank_Account()
# Calling functions with that class object
deposit()
s.withdraw()
s.display()
Read more about python programming here:
brainly.com/question/26497128
#SPJ1