Giter VIP home page Giter VIP logo

data-structures-algorithms-python's Introduction

data-structures-algorithms-python's People

Contributors

aravinth-t avatar beladiyadarshan avatar dhavalsays avatar groverkds avatar nikhilailani avatar udistructor avatar

Stargazers

 avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar

Watchers

 avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar

data-structures-algorithms-python's Issues

Binary search exercise solution could be further optimized

Instead of linearly searching for all the occurrences we could do that faster by searching them all in a binary way.

Here:

while i >=0:
    if numbers[i] == number_to_find:
        indices.append(i)
    else:
        break
    i = i - 1

And here:

while i<len(numbers):
    if numbers[i] == number_to_find:
        indices.append(i)
    else:
        break
    i = i + 1

I would be happy to make a pull request ๐Ÿ˜„

PS: Your tutorial playlist on DSA is amazing!

Incorrect Answer

7_SelectionSort/selection_sort_exercise_solution.py

The code in this file gives incorrect order of anwer conflicting with the correct order in the corresponding .md file.

The code gives this:

{'First Name': 'Aahana', 'Last Name': 'Arora'}
{'First Name': 'Armaan', 'Last Name': 'Dadra'}
{'First Name': 'Armaan', 'Last Name': 'Kumar'}
{'First Name': 'Ingrid', 'Last Name': 'Galore'}
{'First Name': 'Ingrid', 'Last Name': 'Maverick'}
{'First Name': 'Jade', 'Last Name': 'Canary'}
{'First Name': 'Jaya', 'Last Name': 'Seth'}
{'First Name': 'Jaya', 'Last Name': 'Sharma'}
{'First Name': 'Karan', 'Last Name': 'Kumar'}
{'First Name': 'Kiran', 'Last Name': 'Kamla'}

{'First Name': 'Raj', 'Last Name': 'Sharma'}
{'First Name': 'Raj', 'Last Name': 'Nayyar'}

{'First Name': 'Raj', 'Last Name': 'Thakur'}
{'First Name': 'Suraj', 'Last Name': 'Sharma'}

But, it's supposed to be:

[
{'First Name': 'Aahana', 'Last Name': 'Arora'}
{'First Name': 'Armaan', 'Last Name': 'Dadra'}
{'First Name': 'Armaan', 'Last Name': 'Kumar'}
{'First Name': 'Ingrid', 'Last Name': 'Galore'}
{'First Name': 'Ingrid', 'Last Name': 'Maverick'}
{'First Name': 'Jade', 'Last Name': 'Canary'}
{'First Name': 'Jaya', 'Last Name': 'Seth'}
{'First Name': 'Jaya', 'Last Name': 'Sharma'}
{'First Name': 'Karan', 'Last Name': 'Kumar'}
{'First Name': 'Kiran', 'Last Name': 'Kamla'}

**_{'First Name': 'Raj', 'Last Name': 'Nayyar'}
{'First Name': 'Raj', 'Last Name': 'Sharma'}_**

{'First Name': 'Raj', 'Last Name': 'Thakur'}
{'First Name': 'Suraj', 'Last Name': 'Sharma'}

]

Hashtable - Linear probing __setitem__ not considering updates.

Case: Key exists after the first empty slot.
Issue: Code inserts the new (key,value) instead of updating existing (key,value).

Code in question:
def find_slot(self, key, index):
        prob_range = self.get_prob_range(index)
        for prob_index in prob_range:
            if self.arr[prob_index] is None:
                return prob_index
            if self.arr[prob_index][0] == key:
                return prob_index
        raise Exception("Hashmap full") ```
Maybe this can fix it:
def find_slot(self, key, index):
        first_slot = None
        prob_range = self.get_prob_range(index)
        for prob_index in prob_range:
            if first_slot == None and self.arr[prob_index] is None:
                first_slot = prob_index
            if self.arr[prob_index][0] == key:
                return prob_index
        if first_slot is not None:
           return first_slot
        raise Exception("Hashmap full")

Incorrect Answer

How do you reduce a price after getting a refund..? (In Last Question)

In collision Handling , in the chaining method

In collision Handling , in the chaining method we have stored the value in the form form tuple inside the linked list so it means it must be immutable but when i try to execute the code and update that key then the value which is returned is different but your repo the value isnt changed can you help me with this disparity
codebasics

Collision_error

Collision Handling Issue

In Collision Handling in HAsh Table march 17 returns value 59 instead of 9 when we apply hash function to it

FileNotFoundError

Even though I save the file in the same location it still raises an error.

Code not Working

The tutorial was excellent but this code is incomplete and not working correctly.

3_odd_even_numbers.py code is not optimised

max = int(input("Enter max number: "))

odd_numbers = []

for i in range(1, max):
if i % 2 == 1:
odd_numbers.append(i)

print("Odd numbers: ", odd_numbers)

The loop is Executed 0(n) times we can reduce as 0(n/2)

remove unwanted extra interation of loop and saving data in queue in 6_Queue/Exercise/binary_numbers.py

https://github.com/codebasics/data-structures-algorithms-python/blob/master/data_structures/6_Queue/Exercise/binary_numbers.py

Issue:

def produce_binary_numbers(n):
    numbers_queue = Queue()
    numbers_queue.enqueue("1")

    for i in range(n):
        front = numbers_queue.front()
        print("   ", front)
        numbers_queue.enqueue(front + "0")
        numbers_queue.enqueue(front + "1")

        numbers_queue.dequeue()

Proposed below:

def produce_binary_numbers(n):
    numbers_queue = Queue()
    numbers_queue.enqueue("1")
    i = 0
    while i < n//2 and not numbers_queue.is_empty():
        i+=1
        front = numbers_queue.dequeue()
        print(front)
        numbers_queue.enqueue(front + "0")
        numbers_queue.enqueue(front + "1")
        
    while not numbers_queue.is_empty() and i<n:
        print(numbers_queue.dequeue())
        i+=1

Infinite Loop in food_ordering_system.py

There is an error in the dequeue method in the Queue class as when I'm running this program
food_ordering_system.py . I'm getting an infinite loop

Placing order for: samosa
Placing order for:Now serving:  pizza
 pasta
Placing order for: biryani
Placing order for: burger
Now serving:  samosa
Now serving:  pasta
Now serving:  biryani
Now serving:  burger
Queue is empty
Now serving:  None
Queue is empty
Now serving:  None
Queue is empty
Now serving:  None
Queue is empty
Now serving:  None
Queue is empty
Now serving:  None
Queue is empty
Now serving:  None 

and it goes on
I think this error can be solved by using the try and except block
I'm new to open source and trying to make my contribution.
I will work on this issue.
can you guide me?

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    ๐Ÿ–– Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. ๐Ÿ“Š๐Ÿ“ˆ๐ŸŽ‰

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google โค๏ธ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.