diff --git a/.gitignore b/.gitignore index b6e4761..2d15a85 100644 --- a/.gitignore +++ b/.gitignore @@ -127,3 +127,6 @@ dmypy.json # Pyre type checker .pyre/ + +# Editor settings +.vscode/settings.json \ No newline at end of file diff --git a/algorithms/1_BinarySearch/binary_search_exercise.md b/algorithms/1_BinarySearch/binary_search_exercise.md index fbec387..fea2b2b 100644 --- a/algorithms/1_BinarySearch/binary_search_exercise.md +++ b/algorithms/1_BinarySearch/binary_search_exercise.md @@ -11,4 +11,4 @@ ``` This should return 5,6,7 as indices containing number 15 in the array -[Solution](https://github.com/codebasics/py/blob/master/Algorithms/1_BinarySearch/binary_search_exercise_solution.py) \ No newline at end of file +[Solution](https://github.com/codebasics/data-structures-algorithms-python/blob/master/algorithms/1_BinarySearch/binary_search_exercise_solution.py) \ No newline at end of file diff --git a/algorithms/2_BubbleSort/bubble_sort_exercise.md b/algorithms/2_BubbleSort/bubble_sort_exercise.md index b507c16..5068b08 100644 --- a/algorithms/2_BubbleSort/bubble_sort_exercise.md +++ b/algorithms/2_BubbleSort/bubble_sort_exercise.md @@ -1,6 +1,6 @@ ### Bubble Sort Exercise -Modify [bubble_sort function](https://github.com/codebasics/py/blob/master/Algorithms/2_BubbleSort/bubble_sort.py) such that it can sort following list of transactions happening in an electronic store, +Modify [bubble_sort function](https://github.com/codebasics/data-structures-algorithms-python/blob/master/algorithms/2_BubbleSort/bubble_sort.py) such that it can sort following list of transactions happening in an electronic store, ``` elements = [ { 'name': 'mona', 'transaction_amount': 1000, 'device': 'iphone-10'}, @@ -36,5 +36,5 @@ elements = [ ] ``` -[Solution](https://github.com/codebasics/py/blob/master/Algorithms/2_BubbleSort/bubble_sort_exercise_solution.py) +[Solution](https://github.com/codebasics/data-structures-algorithms-python/blob/master/algorithmsAlgorithms/2_BubbleSort/bubble_sort_exercise_solution.py) diff --git a/algorithms/3_QuickSort/quick_sort_exercise.md b/algorithms/3_QuickSort/quick_sort_exercise.md index 82e7bfa..0edb19d 100644 --- a/algorithms/3_QuickSort/quick_sort_exercise.md +++ b/algorithms/3_QuickSort/quick_sort_exercise.md @@ -2,7 +2,7 @@ Implement quick sort using lumoto partition scheme. This partition scheme is explained in the video tutorial, you need to write python code to implement it. Check the pseudo code here: https://en.wikipedia.org/wiki/Quicksort Check the section Lomuto partition scheme - [Solution](https://github.com/codebasics/py/blob/master/Algorithms/3_QuickSort/quick_sort_exercise_soluiton_lomuto.py) + [Solution](https://github.com/codebasics/data-structures-algorithms-python/blob/master/algorithms/3_QuickSort/quick_sort_exercise_soluiton_lomuto.py) \ No newline at end of file diff --git a/algorithms/8_DepthFirstSearch/dfs.py b/algorithms/8_DepthFirstSearch/dfs.py new file mode 100644 index 0000000..97bf329 --- /dev/null +++ b/algorithms/8_DepthFirstSearch/dfs.py @@ -0,0 +1,30 @@ +# function for depth first search +def dfs(data, start, visited=set()): + + # if not visited print it + if start not in visited: + print(start, end=" ") + + visited.add(start) + + for i in data[start] - visited: + + # if not visited gi in depth of it + dfs(data, i, visited) + return + + +# sample data in dictionary form +data = { + 'A': {'B'}, + 'B': {'A', 'C', 'D'}, + 'C': {'B', 'E'}, + 'D': {'B', 'E'}, + 'E': {'C', 'D', 'F'}, + 'F': {'E'} + } + + +if __name__ == '__main__': + + dfs(data, 'A') diff --git a/algorithms/8_DepthFirstSearch/dfs_exercise.py b/algorithms/8_DepthFirstSearch/dfs_exercise.py new file mode 100644 index 0000000..310a483 --- /dev/null +++ b/algorithms/8_DepthFirstSearch/dfs_exercise.py @@ -0,0 +1,29 @@ +# function for depth first search +def find_employees(data, start, employee, visited=set()): + # if not visited print it + if start not in visited: + print(start, end=" ") + if start == employee: + print(":", end=" ") + visited.add(start) + + for i in data[start] - visited: + # if not visited go in depth of it + find_employees(data, i, visited) + return + + +# sample data in dictionary form +data = { + "karan": {"darshan", "nikhil"}, + "darshan": {"khantil", "tanuj"}, + "tanuj": {"nikhil"}, + "krinish": {"hetul"}, + "khantil": set(), + "nikhil": set() +} + + +if __name__ == '__main__': + + find_employees(data, "karan", "karan") diff --git a/algorithms/8_DepthFirstSearch/dfs_exerscise.md b/algorithms/8_DepthFirstSearch/dfs_exerscise.md new file mode 100644 index 0000000..34fa25d --- /dev/null +++ b/algorithms/8_DepthFirstSearch/dfs_exerscise.md @@ -0,0 +1,36 @@ +# DFS Exercise + +![Overview : Employee hierarchy](https://github.com/beladiyadarshan/DFS/blob/main/emp.png?raw=true) + +Given a graph containing managers and their employees as a dictionary of sets, print all employees reporting to a given manager. + +``` +data = { + "karan": {"darshan","nikhil"}, + "darshan": {"khantil", "tanuj"}, + "tanuj": {"nikhil"}, + "krinish": {"hetul"}, + "khantil" : set(), + "nikhil" : set() + } + + + ``` + + Example: Darshan and Nikhil are reporting to Karan. Khantil and Tanuj are reporting to Darshan. + + ``` + Q. Find all employees who are reporting to Karan. + ``` + +**Explanation:** + +-So here, we want to find all the children nodes of Karan. + +-We will perform DFS starting on Karan and then traverse all the children of Karan which are unvisited. + +**Output:** + +karan : nikhil darshan tanuj khantil + +[Solution](https://github.com/beladiyadarshan/DFS/blob/main/dfs_exercise.py) diff --git a/algorithms/8_DepthFirstSearch/emp.png b/algorithms/8_DepthFirstSearch/emp.png new file mode 100644 index 0000000..0815ec8 Binary files /dev/null and b/algorithms/8_DepthFirstSearch/emp.png differ diff --git a/algorithms/8_DepthFirstSearch/updated_graph.jpg b/algorithms/8_DepthFirstSearch/updated_graph.jpg new file mode 100644 index 0000000..e39ecc6 Binary files /dev/null and b/algorithms/8_DepthFirstSearch/updated_graph.jpg differ diff --git a/algorithms/9_BreadthFirstSearch/DFS_BFS_Graph.png b/algorithms/9_BreadthFirstSearch/DFS_BFS_Graph.png new file mode 100644 index 0000000..db439bb Binary files /dev/null and b/algorithms/9_BreadthFirstSearch/DFS_BFS_Graph.png differ diff --git a/algorithms/9_BreadthFirstSearch/bfs.py b/algorithms/9_BreadthFirstSearch/bfs.py new file mode 100644 index 0000000..01b6a1f --- /dev/null +++ b/algorithms/9_BreadthFirstSearch/bfs.py @@ -0,0 +1,23 @@ +def bfs(data, start, visited=set()): + + queue = [start] + + while queue: + current_node = queue.pop(0) + if current_node not in visited: + print(current_node, end=" ") + visited.add(current_node) + + for i in data[current_node] - visited: + queue.append(i) + return + + +if __name__ == '__main__': + + data = { + 'A': {'B'}, 'B': {'A', 'C', 'D'}, 'C': {'B', 'E'}, 'D': {'B', 'E'}, + 'E': {'C', 'D', 'F'}, 'F': {'E'} + } + + bfs(data, 'A') diff --git a/algorithms/9_BreadthFirstSearch/bfs_exercise.md b/algorithms/9_BreadthFirstSearch/bfs_exercise.md new file mode 100644 index 0000000..09ac2ab --- /dev/null +++ b/algorithms/9_BreadthFirstSearch/bfs_exercise.md @@ -0,0 +1,34 @@ +# BFS_Traversal +BFS Traversal of a graph in python using graph given in dictionary + +Implement a function to find whether a path exists for a given set of airline routes. The routes are depicted using graphs as a dictionary of sets, where keys represent as source and elements of sets represent destinations. Print the path if it exists. + +Example: A, B, C, D, E, F are the nodes of the graph. + + +For example, if you are given following data: + +``` +data = { + 'A': {'B'}, + 'B': {'A', 'C', 'D'}, + 'C': {'B', 'E'}, + 'D': {'B', 'E'}, + 'E': {'C', 'D', 'F'}, + 'F': {'E'} +} +``` + +The resultant graph will be: + +![alt text](https://github.com/nikhilailani/data-structures-algorithms-python/blob/master/algorithms/9_BreadthFirstSearch/DFS_BFS_Graph.png) + +Example: Source is A, Destination is D. + +Expected Output: + +``` +Path : A->B->D +``` + +[Solution](https://github.com/nikhilailani/data-structures-algorithms-python/blob/master/algorithms/9_BreadthFirstSearch/bfs_exercise_solution.py) diff --git a/algorithms/9_BreadthFirstSearch/bfs_exercise_solution.py b/algorithms/9_BreadthFirstSearch/bfs_exercise_solution.py new file mode 100644 index 0000000..46f6b41 --- /dev/null +++ b/algorithms/9_BreadthFirstSearch/bfs_exercise_solution.py @@ -0,0 +1,26 @@ +def bfs(data, start, end, visited=[]): + queue = [start] + + while queue: + current_node = queue.pop(0) + if current_node==end: + print("Path: " + "->".join(visited) + "->" + end) + return + visited.append(current_node) + + for i in data[current_node] - set(visited): + queue.append(i) + print("Path does not exist!") + return + + +if __name__ == '__main__': + data = { + 'A': {'B'}, + 'B': {'C', 'D'}, + 'C': {'E'}, + 'D': {'E'}, + 'E': {'F'}, + 'F': set() + } + bfs(data, 'A', 'D') diff --git a/data_structures/2_Arrays/2_arrays_exercise.md b/data_structures/2_Arrays/2_arrays_exercise.md index 5713d35..81d65f4 100644 --- a/data_structures/2_Arrays/2_arrays_exercise.md +++ b/data_structures/2_Arrays/2_arrays_exercise.md @@ -17,7 +17,7 @@ Create a list to store these monthly expenses and using that find out, got a refund of 200$. Make a correction to your monthly expense list based on this -[Solution](https://github.com/codebasics/py/blob/master/DataStructures/2_Arrays/Solution/1_expenses.py) +[Solution](https://github.com/codebasics/data-structures-algorithms-python/blob/master/data_structures/2_Arrays/Solution/1_expenses.py) 2. You have a list of your favourite marvel super heros. ``` @@ -35,11 +35,11 @@ Using this find out, Do that with one line of code. 5. Sort the heros list in alphabetical order (Hint. Use dir() functions to list down all functions available in list) -[Solution](https://github.com/codebasics/py/blob/master/DataStructures/2_Arrays/Solution/2_marvel.py) +[Solution](https://github.com/codebasics/data-structures-algorithms-python/blob/master/data_structures/2_Arrays/Solution/2_marvel.py) 3. Create a list of all odd numbers between 1 and a max number. Max number is something you need to take from a user using input() function -[Solution](https://github.com/codebasics/py/blob/master/DataStructures/2_Arrays/Solution/3_odd_even_numbers.py) +[Solution](https://github.com/codebasics/data-structures-algorithms-python/blob/master/data_structures/2_Arrays/Solution/3_odd_even_numbers.py) diff --git a/data_structures/3_LinkedList/3_linked_list_exercise.md b/data_structures/3_LinkedList/3_linked_list_exercise.md index e1245e8..b2cea35 100644 --- a/data_structures/3_LinkedList/3_linked_list_exercise.md +++ b/data_structures/3_LinkedList/3_linked_list_exercise.md @@ -1,6 +1,6 @@ # Exercise: Linked List -1. In [LinkedList class](https://github.com/codebasics/py/blob/master/DataStructures/3_LinkedList/3_linked_list.py) that we implemented in our tutorial add following two methods, +1. In [LinkedList class](https://github.com/codebasics/data-structures-algorithms-python/blob/master/data_structures/3_LinkedList/3_linked_list.py) that we implemented in our tutorial add following two methods, ``` def insert_after_value(self, data_after, data_to_insert): # Search for first occurance of data_after value in linked list @@ -26,7 +26,7 @@ Now make following calls, ll.remove_by_value("grapes") ll.print() ``` -[Solution](https://github.com/codebasics/py/blob/master/DataStructures/3_LinkedList/Solution/singly_linked_list_exercise.py) +[Solution](https://github.com/codebasics/data-structures-algorithms-python/blob/master/data_structures/3_LinkedList/Solution/singly_linked_list_exercise.py) 2. Implement doubly linked list. The only difference with regular linked list is that double linked has prev node reference as well. That way you can iterate in forward and backward direction. Your node class will look this this, @@ -45,6 +45,6 @@ def print_forward(self): def print_backward(self): # Print linked list in reverse direction. Use node.prev for this. ``` -Implement all other methods in [regular linked list class](https://github.com/codebasics/py/blob/master/DataStructures/3_LinkedList/3_linked_list.py) and make necessary changes for doubly linked list (you need to populate node.prev in all those methods) +Implement all other methods in [regular linked list class](https://github.com/codebasics/data-structures-algorithms-python/blob/master/data_structures/3_LinkedList/3_linked_list.py) and make necessary changes for doubly linked list (you need to populate node.prev in all those methods) -[Solution](https://github.com/codebasics/py/blob/master/DataStructures/3_LinkedList/Solution/doubly_linked_list_exercise.py) \ No newline at end of file +[Solution](https://github.com/codebasics/data-structures-algorithms-python/blob/master/data_structures/3_LinkedList/Solution/doubly_linked_list_exercise.py) \ No newline at end of file diff --git a/data_structures/4_HashTable_2_Collisions/4_hash_table_exercise.md b/data_structures/4_HashTable_2_Collisions/4_hash_table_exercise.md index 2ae3acf..84849b4 100644 --- a/data_structures/4_HashTable_2_Collisions/4_hash_table_exercise.md +++ b/data_structures/4_HashTable_2_Collisions/4_hash_table_exercise.md @@ -1,31 +1,31 @@ # Exercise: Hash Table -1. [nyc_weather.csv](https://github.com/codebasics/py/blob/master/DataStructures/4_HashTable_2_Collisions/Solution/nyc_weather.csv) contains new york city weather for first few days in the month of January. Write a program that can answer following, +1. [nyc_weather.csv](https://github.com/codebasics/data-structures-algorithms-python/blob/master/data_structures/4_HashTable_2_Collisions/Solution/nyc_weather.csv) contains new york city weather for first few days in the month of January. Write a program that can answer following, 1. What was the average temperature in first week of Jan 1. What was the maximum temperature in first 10 days of Jan Figure out data structure that is best for this problem -[Solution](https://github.com/codebasics/py/blob/master/DataStructures/4_HashTable_2_Collisions/Solution/weather_analysis.ipynb) +[Solution](https://github.com/codebasics/data-structures-algorithms-python/blob/master/data_structures/4_HashTable_2_Collisions/Solution/weather_analysis.ipynb) -2. [nyc_weather.csv](https://github.com/codebasics/py/blob/master/DataStructures/4_HashTable_2_Collisions/Solution/nyc_weather.csv) contains new york city weather for first few days in the month of January. Write a program that can answer following, +2. [nyc_weather.csv](https://github.com/codebasics/data-structures-algorithms-python/blob/master/data_structures/4_HashTable_2_Collisions/Solution/nyc_weather.csv) contains new york city weather for first few days in the month of January. Write a program that can answer following, 1. What was the temperature on Jan 9? 1. What was the temperature on Jan 4? Figure out data structure that is best for this problem -[Solution](https://github.com/codebasics/py/blob/master/DataStructures/4_HashTable_2_Collisions/Solution/weather_analysis.ipynb) +[Solution](https://github.com/codebasics/data-structures-algorithms-python/blob/master/data_structures/4_HashTable_2_Collisions/Solution/weather_analysis.ipynb) -3. [poem.txt](https://github.com/codebasics/py/blob/master/DataStructures/4_HashTable_2_Collisions/Solution/poem.txt) Contains famous poem "Road not taken" by poet Robert Frost. You have to read this file in python and print every word and its count as show below. Think about the best data structure that you can use to solve this problem and figure out why you selected that specific data structure. +3. [poem.txt](https://github.com/codebasics/data-structures-algorithms-python/blob/master/data_structures/4_HashTable_2_Collisions/Solution/poem.txt) Contains famous poem "Road not taken" by poet Robert Frost. You have to read this file in python and print every word and its count as show below. Think about the best data structure that you can use to solve this problem and figure out why you selected that specific data structure. ``` 'diverged': 2, 'in': 3, 'I': 8 ``` -[Solution](https://github.com/codebasics/py/blob/master/DataStructures/4_HashTable_2_Collisions/Solution/exercise_poem_find_word_occurances.ipynb) +[Solution](https://github.com/codebasics/data-structures-algorithms-python/blob/master/data_structures/4_HashTable_2_Collisions/Solution/exercise_poem_find_word_occurances.ipynb) 4. Implement hash table where collisions are handled using linear probing. We learnt about linear probing in the video tutorial. Take the hash table implementation that uses chaining and modify methods to use **linear probing**. Keep MAX size of arr in hashtable as 10. -[Solution](https://github.com/codebasics/py/blob/master/DataStructures/4_HashTable_2_Collisions/Solution/exercise_hash_table_linear_probing.ipynb) +[Solution](https://github.com/codebasics/data-structures-algorithms-python/blob/master/data_structures/4_HashTable_2_Collisions/Solution/exercise_hash_table_linear_probing.ipynb) diff --git a/data_structures/5_Stack/5_stack_exercise.md b/data_structures/5_Stack/5_stack_exercise.md index 7724753..a91a62a 100644 --- a/data_structures/5_Stack/5_stack_exercise.md +++ b/data_structures/5_Stack/5_stack_exercise.md @@ -1,12 +1,12 @@ ## Data structure tutorial exercise: Stack -1. Write a function in python that can reverse a string using stack data structure. Use [Stack class](https://github.com/codebasics/py/tree/master/DataStructures/5_Stack/5_stack.ipynb) from the tutorial. +1. Write a function in python that can reverse a string using stack data structure. Use [Stack class](https://github.com/codebasics/data-structures-algorithms-python/blob/master/data_structures/5_Stack/5_stack.ipynb) from the tutorial. ``` reverse_string("We will conquere COVID-19") should return "91-DIVOC ereuqnoc lliw eW" ``` -[Solution](https://github.com/codebasics/py/tree/master/DataStructures/5_Stack/Exercise/reverse_string.py) +[Solution](https://github.com/codebasics/data-structures-algorithms-python/blob/master/data_structures/5_Stack/Exercise/reverse_string.py) -2. Write a function in python that checks if paranthesis in the string are balanced or not. Possible parantheses are "{}',"()" or "[]". Use [Stack class](https://github.com/codebasics/py/tree/master/DataStructures/5_Stack/5_stack.ipynb) from the tutorial. +2. Write a function in python that checks if paranthesis in the string are balanced or not. Possible parantheses are "{}',"()" or "[]". Use [Stack class](https://github.com/codebasics/data-structures-algorithms-python/blob/master/data_structures/5_Stack/5_stack.ipynb) from the tutorial. ``` is_balanced("({a+b})") --> True is_balanced("))((a+b}{") --> False @@ -15,4 +15,4 @@ is_balanced("[a+b]*(x+2y)*{gg+kk}") --> True ``` -[Solution](https://github.com/codebasics/py/tree/master/DataStructures/5_Stack/Exercise/balance_paran.py) \ No newline at end of file +[Solution](https://github.com/codebasics/data-structures-algorithms-python/blob/master/data_structures/5_Stack/Exercise/balance_paran.py) \ No newline at end of file diff --git a/data_structures/6_Queue/6_queue_exercise.md b/data_structures/6_Queue/6_queue_exercise.md index 0106930..3c3fc2d 100644 --- a/data_structures/6_Queue/6_queue_exercise.md +++ b/data_structures/6_Queue/6_queue_exercise.md @@ -1,6 +1,6 @@ ## Data structure tutorial exercise: Queue -For all exercises use [Queue class](https://github.com/codebasics/py/blob/master/DataStructures/6_Queue/6_queue.ipynb) implemented in main tutorial. +For all exercises use [Queue class](https://github.com/codebasics/data-structures-algorithms-python/blob/master/data_structures/6_Queue/6_queue.ipynb) implemented in main tutorial. 1. Design a food ordering system where your python program will run two threads, 1. Place Order: This thread will be placing an order and inserting that into a queue. This thread places new order every 0.5 second. (hint: use time.sleep(0.5) function) @@ -15,7 +15,7 @@ For all exercises use [Queue class](https://github.com/codebasics/py/blob/master This problem is a producer,consumer problem where place_order thread is producing orders whereas server_order thread is consuming the food orders. Use Queue class implemented in a video tutorial. -[Solution](https://github.com/codebasics/py/tree/master/DataStructures/6_Queue/Exercise/food_ordering_system.py) +[Solution](https://github.com/codebasics/data-structures-algorithms-python/blob/master/data_structures/6_Queue/Exercise/food_ordering_system.py) 2. Write a program to print binary numbers from 1 to 10 using Queue. Use Queue class implemented in main tutorial. Binary sequence should look like, @@ -35,4 +35,4 @@ Hint: Notice a pattern above. After 1 second and third number is 1+0 and 1+1. 4t You also need to add front() function in queue class that can return the front element in the queue. -[Solution](https://github.com/codebasics/py/tree/master/DataStructures/6_Queue/Exercise/binary_numbers.py) +[Solution](https://github.com/codebasics/data-structures-algorithms-python/blob/master/data_structures/6_Queue/Exercise/binary_numbers.py) diff --git a/data_structures/7_Tree/7_tree_exercise.md b/data_structures/7_Tree/7_tree_exercise.md index b03faa9..8c00808 100644 --- a/data_structures/7_Tree/7_tree_exercise.md +++ b/data_structures/7_Tree/7_tree_exercise.md @@ -4,7 +4,7 @@ ![ss](management_both.PNG) -Extent [tree class](https://github.com/codebasics/py/blob/master/DataStructures/7_Tree/7_tree.py) built in our +Extent [tree class](https://github.com/codebasics/data-structures-algorithms-python/blob/master/data_structures/7_Tree/7_tree.py) built in our main tutorial so that it takes **name** and **designation** in data part of TreeNode class. Now extend print_tree function such that it can print either name tree, designation tree or name and designation tree. As shown below, @@ -19,7 +19,7 @@ if __name__ == '__main__': root_node.print_tree("both") # prints both (name and designation) hierarchy ``` -[Solution](https://github.com/codebasics/py/blob/master/DataStructures/7_Tree/Exercise/management_hierarchy.py) +[Solution](https://github.com/codebasics/data-structures-algorithms-python/blob/master/data_structures/7_Tree/Exercise/management_hierarchy.py) 2. Build below location tree using **TreeNode** class @@ -29,6 +29,6 @@ Now modify print_tree method to take tree level as input. And that should print ![](location_trees_all.png) -[Solution](https://github.com/codebasics/py/blob/master/DataStructures/7_Tree/Exercise/location_hierarchy.py) +[Solution](https://github.com/codebasics/data-structures-algorithms-python/blob/master/data_structures/7_Tree/Exercise/location_hierarchy.py) diff --git a/data_structures/8_Binary_Tree_1/8_binary_tree_part_1_exercise.md b/data_structures/8_Binary_Tree_1/8_binary_tree_part_1_exercise.md index 5e11b62..d050129 100644 --- a/data_structures/8_Binary_Tree_1/8_binary_tree_part_1_exercise.md +++ b/data_structures/8_Binary_Tree_1/8_binary_tree_part_1_exercise.md @@ -1,6 +1,6 @@ ### Binary Tree Part 1 Exercise -Add following methods to [BinarySearchTreeNode class](https://github.com/codebasics/py/tree/master/DataStructures/8_Binary_Tree_1/binary_tree_part_1.py) created in main video tutorial +Add following methods to [BinarySearchTreeNode class](https://github.com/codebasics/data-structures-algorithms-python/blob/master/data_structures/8_Binary_Tree_1/binary_tree_part_1.py) created in main video tutorial 1. find_min(): finds minimum element in entire binary tree 2. find_max(): finds maximum element in entire binary tree @@ -8,5 +8,5 @@ Add following methods to [BinarySearchTreeNode class](https://github.com/codebas 4. post_order_traversal(): performs post order traversal of a binary tree 5. pre_order_traversal(): perofrms pre order traversal of a binary tree -[Solution](https://github.com/codebasics/py/tree/master/DataStructures/8_Binary_Tree_1/Exercise/binary_tree_part_1_exercise.py) +[Solution](https://github.com/codebasics/data-structures-algorithms-python/blob/master/data_structures/8_Binary_Tree_1/Exercise/binary_tree_part_1_exercise.py) diff --git a/data_structures/9_Binary_Tree_2/9_binary_tree_part_2_exercise.md b/data_structures/9_Binary_Tree_2/9_binary_tree_part_2_exercise.md index 6d83725..95cb303 100644 --- a/data_structures/9_Binary_Tree_2/9_binary_tree_part_2_exercise.md +++ b/data_structures/9_Binary_Tree_2/9_binary_tree_part_2_exercise.md @@ -1,6 +1,6 @@ ### Binary Tree Part 2 Exercise -Modify delete method in class [BinarySearchTreeNode class](https://github.com/codebasics/py/tree/master/DataStructures/9_Binary_Tree_2/binary_tree_part_2.py) +Modify delete method in class [BinarySearchTreeNode class](https://github.com/codebasics/data-structures-algorithms-python/blob/master/data_structures/9_Binary_Tree_2/binary_tree_part_2.py) to use min element from left subtree. You will remove lines marked with ---> and use max value from left subtree ``` @@ -24,5 +24,5 @@ to use min element from left subtree. You will remove lines marked with ---> and ---> self.right = self.right.delete(min_val) ``` -[Solution](https://github.com/codebasics/py/tree/master/DataStructures/9_Binary_Tree_2/Exercise/binary_tree_part_2_exercise.py) +[Solution](https://github.com/codebasics/data-structures-algorithms-python/blob/master/data_structures/9_Binary_Tree_2/Exercise/binary_tree_part_2_exercise.py)