From 64ea23ca894677286c2e619d029ea0ffdb465e1d Mon Sep 17 00:00:00 2001 From: Darshan beladiya <42748893+beladiyadarshan@users.noreply.github.com> Date: Mon, 7 Dec 2020 16:41:01 +0530 Subject: [PATCH 01/48] Create dfs.py --- algorithms/8_depth_first_search/dfs.py | 1 + 1 file changed, 1 insertion(+) create mode 100644 algorithms/8_depth_first_search/dfs.py diff --git a/algorithms/8_depth_first_search/dfs.py b/algorithms/8_depth_first_search/dfs.py new file mode 100644 index 0000000..8b13789 --- /dev/null +++ b/algorithms/8_depth_first_search/dfs.py @@ -0,0 +1 @@ + From dd12f8bdb2250b52a3b24dedf72d93b104dad9fc Mon Sep 17 00:00:00 2001 From: Nikhil Ailani <46107121+nikhilailani@users.noreply.github.com> Date: Mon, 7 Dec 2020 16:41:38 +0530 Subject: [PATCH 02/48] Create breadth_first_search.py --- .../breadth_first_search.py | 24 +++++++++++++++++++ 1 file changed, 24 insertions(+) create mode 100644 9_breadth_first_search/breadth_first_search.py diff --git a/9_breadth_first_search/breadth_first_search.py b/9_breadth_first_search/breadth_first_search.py new file mode 100644 index 0000000..842441e --- /dev/null +++ b/9_breadth_first_search/breadth_first_search.py @@ -0,0 +1,24 @@ +def bfs(Data, start, visited=set()): + + queue = [start] + + while queue: + currentnode = queue.pop(0) + if currentnode not in visited: print(currentnode, end = " ") + visited.add(currentnode) + + for i in Data[currentnode] - visited: + queue.append(i) + + return + + +Data = {'A': {'B'}, + 'B': {'A', 'C', 'D'}, + 'C': {'B', 'E'}, + 'D': {'B', 'E'}, + 'E': {'C', 'D', 'F'}, + 'F': {'E'}} + +if __name__ == '__main__': + bfs(Data, 'A') From 44b16f51578cd72caaa7785af893dc63d15dd44f Mon Sep 17 00:00:00 2001 From: Darshan beladiya <42748893+beladiyadarshan@users.noreply.github.com> Date: Mon, 7 Dec 2020 16:41:54 +0530 Subject: [PATCH 03/48] Update dfs.py --- algorithms/8_depth_first_search/dfs.py | 31 ++++++++++++++++++++++++++ 1 file changed, 31 insertions(+) diff --git a/algorithms/8_depth_first_search/dfs.py b/algorithms/8_depth_first_search/dfs.py index 8b13789..e867850 100644 --- a/algorithms/8_depth_first_search/dfs.py +++ b/algorithms/8_depth_first_search/dfs.py @@ -1 +1,32 @@ +#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') From 5bf76d59e9095bba5f3150c4051dcb263f4e3c3a Mon Sep 17 00:00:00 2001 From: Darshan beladiya <42748893+beladiyadarshan@users.noreply.github.com> Date: Mon, 7 Dec 2020 16:42:26 +0530 Subject: [PATCH 04/48] Add files via upload --- .../8_depth_first_search/Dfs_Exerscise.md | 44 ++++++++++++++++++ .../8_depth_first_search/Dfs_exercise.py | 36 ++++++++++++++ algorithms/8_depth_first_search/emp.png | Bin 0 -> 10334 bytes .../8_depth_first_search/updated_graph.jpg | Bin 0 -> 17665 bytes 4 files changed, 80 insertions(+) create mode 100644 algorithms/8_depth_first_search/Dfs_Exerscise.md create mode 100644 algorithms/8_depth_first_search/Dfs_exercise.py create mode 100644 algorithms/8_depth_first_search/emp.png create mode 100644 algorithms/8_depth_first_search/updated_graph.jpg diff --git a/algorithms/8_depth_first_search/Dfs_Exerscise.md b/algorithms/8_depth_first_search/Dfs_Exerscise.md new file mode 100644 index 0000000..c50adb5 --- /dev/null +++ b/algorithms/8_depth_first_search/Dfs_Exerscise.md @@ -0,0 +1,44 @@ +# DFS Exercise + +![alt text](https://github.com/beladiyadarshan/Dfs/blob/main/emp.png?raw=true) + +Given a Graph in Dictionary Form + +-print all employees who are reporting to given employee + +``` +Data = {"karan": {"darshan","nikhil"}, + "darshan": {"khantil", "tanuj"}, + 'tanuj': {"nikhil"}, + "krinish": {"hetul"}, + "khantil" : set(), + "nikhil" : set() + } + + + ``` + + here darshan and nikhil are reporting to karan and so on.... + + ``` + Q.find all employees who are reporting to karan + -do dfs on karan and print all the employees + ``` + +**Explanation :** + +-so here we wants to find all the childs of karan + +-we will do dfs on karan and then we will traverse all the childs of karan that are not visited + +**output will be :** + +karan : nikhil darshan tanuj khantil + +[Solution](https://github.com/beladiyadarshan/Dfs/blob/main/Dfs_exercise.py) + + + + + + diff --git a/algorithms/8_depth_first_search/Dfs_exercise.py b/algorithms/8_depth_first_search/Dfs_exercise.py new file mode 100644 index 0000000..c009db1 --- /dev/null +++ b/algorithms/8_depth_first_search/Dfs_exercise.py @@ -0,0 +1,36 @@ +#function for depth first search +def dfs(Data, start,emp,visited=set()): + + #if not visited print it + if start not in visited: + print(start,end=" ") + + if start==emp: + print(":",end=" ") + + + visited.add(start) + + + for i in Data[start] - visited: + + #if not visited go in depth of it + dfs(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__': + + dfs(Data, "karan","karan") diff --git a/algorithms/8_depth_first_search/emp.png b/algorithms/8_depth_first_search/emp.png new file mode 100644 index 0000000000000000000000000000000000000000..0815ec8f8908a03f2c4156d2f29b3d3ea4379f56 GIT binary patch literal 10334 zcmdsdX*`r)_;-njER%f?g9xPw#e^8kZAr$GHH>|2v1G|scCw5u{7@NWCu@`?TSdyg zmLxHD*)q20jDGxo|5wk8=iT$d_+01Q_c`}D=Q`K=A1ez-DTH}C_a5|@`K%_l+!t*NmV96{KK!-$Fv?*kW!}ZMw=uh4&`d$Qnu?Zo;(8sX0 z31j4xn&;}B6$VH;ZC&+a@Qn%jPTj!lEsj-wJUodY;4^=Xc^L1pVx0VuTm7$lg* zY!Gslz%*BL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X7vKyX-43*@e8^bK+?JC^1=xnG-Ym8=TF&?NfHCQ&0$!LooS6E~79Udr1Ej>$X*e zDr?o3dylH*$7LkZ8xdLoRN6fKwP?<)BRQ>2&b7f_Mo1`n0ix&nsc=sFq0*FXR?=K^ z{X~ZD&tflc*0kR4m@*hMC0oxoBizCcV9euVq~#^pp-K~Sqt|2lF&x5eFQda~c@qbxV|CNbh6`RD8&A^zPW+*yp z`Bvmai@)3~e5pKCRg)I15z}j?8wbEUlNs$FCgd|=7_2%#2~a;u`APUdA3LXb@(iFk zfl3wi`l;lf8?~+_Z`+cwqbEuf}A_E)!+GPuP-RvE7 wfO*l&+j6U_I^eEN_G Date: Mon, 7 Dec 2020 16:43:01 +0530 Subject: [PATCH 05/48] Create breadth_first_search_exercise.md --- .../breadth_first_search_exercise.md | 35 +++++++++++++++++++ 1 file changed, 35 insertions(+) create mode 100644 9_breadth_first_search/breadth_first_search_exercise.md diff --git a/9_breadth_first_search/breadth_first_search_exercise.md b/9_breadth_first_search/breadth_first_search_exercise.md new file mode 100644 index 0000000..99d91dd --- /dev/null +++ b/9_breadth_first_search/breadth_first_search_exercise.md @@ -0,0 +1,35 @@ +# BFS_Traversal +BFS Traversal of a graph in python using graph given in dictionary + +Implement a program to find whether a path exists for an airline route or not. The routes are described using graph having nodes. The names of the graphs are named alphabet characters for easy understanding. Print the path if it exists; print the denying statement if it doesn't! + +Example: A, B, C, D, E, F are the nodes of the graph. + + +For example, 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/BFS_Traversal/blob/main/DFS_BFS_Graph.png) + + +**Explanation:** Here, selecting A as source node and D as destination node, the values are passed to the function. + +Your output should look like this: + +''' +Path exists! +Path : A->B->D +''' + +[Solution](https://github.com/nikhilailani/BFS_Traversal/blob/main/bfs_exercise_solution.py) + From 0dc70eb7c5369ad044f2566a0d2ba14c29069c82 Mon Sep 17 00:00:00 2001 From: Nikhil Ailani <46107121+nikhilailani@users.noreply.github.com> Date: Mon, 7 Dec 2020 16:44:33 +0530 Subject: [PATCH 06/48] Delete breadth_first_search.py --- .../breadth_first_search.py | 24 ------------------- 1 file changed, 24 deletions(-) delete mode 100644 9_breadth_first_search/breadth_first_search.py diff --git a/9_breadth_first_search/breadth_first_search.py b/9_breadth_first_search/breadth_first_search.py deleted file mode 100644 index 842441e..0000000 --- a/9_breadth_first_search/breadth_first_search.py +++ /dev/null @@ -1,24 +0,0 @@ -def bfs(Data, start, visited=set()): - - queue = [start] - - while queue: - currentnode = queue.pop(0) - if currentnode not in visited: print(currentnode, end = " ") - visited.add(currentnode) - - for i in Data[currentnode] - visited: - queue.append(i) - - return - - -Data = {'A': {'B'}, - 'B': {'A', 'C', 'D'}, - 'C': {'B', 'E'}, - 'D': {'B', 'E'}, - 'E': {'C', 'D', 'F'}, - 'F': {'E'}} - -if __name__ == '__main__': - bfs(Data, 'A') From 50db494fa731c5f58609d18493bc608ce240ae14 Mon Sep 17 00:00:00 2001 From: Nikhil Ailani <46107121+nikhilailani@users.noreply.github.com> Date: Mon, 7 Dec 2020 16:44:54 +0530 Subject: [PATCH 07/48] Delete breadth_first_search_exercise.md --- .../breadth_first_search_exercise.md | 35 ------------------- 1 file changed, 35 deletions(-) delete mode 100644 9_breadth_first_search/breadth_first_search_exercise.md diff --git a/9_breadth_first_search/breadth_first_search_exercise.md b/9_breadth_first_search/breadth_first_search_exercise.md deleted file mode 100644 index 99d91dd..0000000 --- a/9_breadth_first_search/breadth_first_search_exercise.md +++ /dev/null @@ -1,35 +0,0 @@ -# BFS_Traversal -BFS Traversal of a graph in python using graph given in dictionary - -Implement a program to find whether a path exists for an airline route or not. The routes are described using graph having nodes. The names of the graphs are named alphabet characters for easy understanding. Print the path if it exists; print the denying statement if it doesn't! - -Example: A, B, C, D, E, F are the nodes of the graph. - - -For example, 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/BFS_Traversal/blob/main/DFS_BFS_Graph.png) - - -**Explanation:** Here, selecting A as source node and D as destination node, the values are passed to the function. - -Your output should look like this: - -''' -Path exists! -Path : A->B->D -''' - -[Solution](https://github.com/nikhilailani/BFS_Traversal/blob/main/bfs_exercise_solution.py) - From 8eafbd8bea33e5e66123934325b86f348bd62c40 Mon Sep 17 00:00:00 2001 From: Nikhil Ailani <46107121+nikhilailani@users.noreply.github.com> Date: Mon, 7 Dec 2020 16:45:29 +0530 Subject: [PATCH 08/48] Create 9_breadth_first_search --- algorithms/9_breadth_first_search | 1 + 1 file changed, 1 insertion(+) create mode 100644 algorithms/9_breadth_first_search diff --git a/algorithms/9_breadth_first_search b/algorithms/9_breadth_first_search new file mode 100644 index 0000000..8b13789 --- /dev/null +++ b/algorithms/9_breadth_first_search @@ -0,0 +1 @@ + From 9a0d3b4dc259d7420f6ad3afa21875026a323677 Mon Sep 17 00:00:00 2001 From: Nikhil Ailani <46107121+nikhilailani@users.noreply.github.com> Date: Mon, 7 Dec 2020 16:45:56 +0530 Subject: [PATCH 09/48] Delete 9_breadth_first_search --- algorithms/9_breadth_first_search | 1 - 1 file changed, 1 deletion(-) delete mode 100644 algorithms/9_breadth_first_search diff --git a/algorithms/9_breadth_first_search b/algorithms/9_breadth_first_search deleted file mode 100644 index 8b13789..0000000 --- a/algorithms/9_breadth_first_search +++ /dev/null @@ -1 +0,0 @@ - From 12828279dcb6f5f9f6babb53fa83aacaf4a565ba Mon Sep 17 00:00:00 2001 From: Nikhil Ailani <46107121+nikhilailani@users.noreply.github.com> Date: Mon, 7 Dec 2020 16:46:36 +0530 Subject: [PATCH 10/48] Create bfs.py --- algorithms/9_Breadth_First_Search/bfs.py | 1 + 1 file changed, 1 insertion(+) create mode 100644 algorithms/9_Breadth_First_Search/bfs.py diff --git a/algorithms/9_Breadth_First_Search/bfs.py b/algorithms/9_Breadth_First_Search/bfs.py new file mode 100644 index 0000000..8b13789 --- /dev/null +++ b/algorithms/9_Breadth_First_Search/bfs.py @@ -0,0 +1 @@ + From 3cc88661a29ce12bae6454740b01043328ad01e6 Mon Sep 17 00:00:00 2001 From: Nikhil Ailani <46107121+nikhilailani@users.noreply.github.com> Date: Mon, 7 Dec 2020 16:47:48 +0530 Subject: [PATCH 11/48] Delete bfs.py --- algorithms/9_Breadth_First_Search/bfs.py | 1 - 1 file changed, 1 deletion(-) delete mode 100644 algorithms/9_Breadth_First_Search/bfs.py diff --git a/algorithms/9_Breadth_First_Search/bfs.py b/algorithms/9_Breadth_First_Search/bfs.py deleted file mode 100644 index 8b13789..0000000 --- a/algorithms/9_Breadth_First_Search/bfs.py +++ /dev/null @@ -1 +0,0 @@ - From dee5947c2738627a9904ad9029c88245205cc35b Mon Sep 17 00:00:00 2001 From: Nikhil Ailani <46107121+nikhilailani@users.noreply.github.com> Date: Mon, 7 Dec 2020 16:49:11 +0530 Subject: [PATCH 12/48] Create bfs.py --- algorithms/9_BreadthFirstSearch/bfs.py | 24 ++++++++++++++++++++++++ 1 file changed, 24 insertions(+) create mode 100644 algorithms/9_BreadthFirstSearch/bfs.py diff --git a/algorithms/9_BreadthFirstSearch/bfs.py b/algorithms/9_BreadthFirstSearch/bfs.py new file mode 100644 index 0000000..842441e --- /dev/null +++ b/algorithms/9_BreadthFirstSearch/bfs.py @@ -0,0 +1,24 @@ +def bfs(Data, start, visited=set()): + + queue = [start] + + while queue: + currentnode = queue.pop(0) + if currentnode not in visited: print(currentnode, end = " ") + visited.add(currentnode) + + for i in Data[currentnode] - visited: + queue.append(i) + + return + + +Data = {'A': {'B'}, + 'B': {'A', 'C', 'D'}, + 'C': {'B', 'E'}, + 'D': {'B', 'E'}, + 'E': {'C', 'D', 'F'}, + 'F': {'E'}} + +if __name__ == '__main__': + bfs(Data, 'A') From ca1904fde9579be0fa2b244c41b42ea16b2b0d56 Mon Sep 17 00:00:00 2001 From: Nikhil Ailani <46107121+nikhilailani@users.noreply.github.com> Date: Mon, 7 Dec 2020 16:50:50 +0530 Subject: [PATCH 13/48] Update bfs.py --- algorithms/9_BreadthFirstSearch/bfs.py | 20 ++++++++++---------- 1 file changed, 10 insertions(+), 10 deletions(-) diff --git a/algorithms/9_BreadthFirstSearch/bfs.py b/algorithms/9_BreadthFirstSearch/bfs.py index 842441e..137ad87 100644 --- a/algorithms/9_BreadthFirstSearch/bfs.py +++ b/algorithms/9_BreadthFirstSearch/bfs.py @@ -1,24 +1,24 @@ -def bfs(Data, start, visited=set()): +def bfs(data, start, visited=set()): queue = [start] while queue: - currentnode = queue.pop(0) - if currentnode not in visited: print(currentnode, end = " ") - visited.add(currentnode) + current_node = queue.pop(0) + if current_node not in visited: print(current_node, end = " ") + visited.add(current_node) - for i in Data[currentnode] - visited: + for i in data[current_node] - visited: queue.append(i) return - -Data = {'A': {'B'}, +if __name__ == '__main__': + + data = {'A': {'B'}, 'B': {'A', 'C', 'D'}, 'C': {'B', 'E'}, 'D': {'B', 'E'}, 'E': {'C', 'D', 'F'}, 'F': {'E'}} - -if __name__ == '__main__': - bfs(Data, 'A') + + bfs(data, 'A') From cf7917fb61b23b9e76cc074424690f6c12179320 Mon Sep 17 00:00:00 2001 From: Darshan beladiya <42748893+beladiyadarshan@users.noreply.github.com> Date: Mon, 7 Dec 2020 16:50:52 +0530 Subject: [PATCH 14/48] Update dfs.py --- algorithms/8_depth_first_search/dfs.py | 10 +++++----- 1 file changed, 5 insertions(+), 5 deletions(-) diff --git a/algorithms/8_depth_first_search/dfs.py b/algorithms/8_depth_first_search/dfs.py index e867850..5cb909f 100644 --- a/algorithms/8_depth_first_search/dfs.py +++ b/algorithms/8_depth_first_search/dfs.py @@ -1,5 +1,5 @@ #function for depth first search -def dfs(Data, start, visited=set()): +def dfs(data, start, visited=set()): #if not visited print it if start not in visited: @@ -8,17 +8,17 @@ def dfs(Data, start, visited=set()): visited.add(start) - for i in Data[start] - visited: + for i in data[start] - visited: #if not visited gi in depth of it - dfs(Data, i, visited) + dfs(data, i, visited) return #sample data in dictionary form -Data = {'A': {'B'}, +data = {'A': {'B'}, 'B': {'A', 'C', 'D'}, 'C': {'B', 'E'}, 'D': {'B', 'E'}, @@ -29,4 +29,4 @@ def dfs(Data, start, visited=set()): if __name__ == '__main__': - dfs(Data, 'A') + dfs(data, 'A') From f5c428914aa26c5ff702a6ca243a961b4f72be5e Mon Sep 17 00:00:00 2001 From: Darshan beladiya <42748893+beladiyadarshan@users.noreply.github.com> Date: Mon, 7 Dec 2020 16:51:48 +0530 Subject: [PATCH 15/48] Update Dfs_exercise.py --- algorithms/8_depth_first_search/Dfs_exercise.py | 10 +++++----- 1 file changed, 5 insertions(+), 5 deletions(-) diff --git a/algorithms/8_depth_first_search/Dfs_exercise.py b/algorithms/8_depth_first_search/Dfs_exercise.py index c009db1..92badb8 100644 --- a/algorithms/8_depth_first_search/Dfs_exercise.py +++ b/algorithms/8_depth_first_search/Dfs_exercise.py @@ -1,5 +1,5 @@ #function for depth first search -def dfs(Data, start,emp,visited=set()): +def dfs(data, start,emp,visited=set()): #if not visited print it if start not in visited: @@ -12,17 +12,17 @@ def dfs(Data, start,emp,visited=set()): visited.add(start) - for i in Data[start] - visited: + for i in data[start] - visited: #if not visited go in depth of it - dfs(Data, i, visited) + dfs(data, i, visited) return #sample data in dictionary form -Data = {"karan": {"darshan","nikhil"}, +data = {"karan": {"darshan","nikhil"}, "darshan": {"khantil", "tanuj"}, 'tanuj': {"nikhil"}, "krinish": {"hetul"}, @@ -33,4 +33,4 @@ def dfs(Data, start,emp,visited=set()): if __name__ == '__main__': - dfs(Data, "karan","karan") + dfs(data, "karan","karan") From 39df8b75327c7aca50e7f8f8c9b65cb954c41071 Mon Sep 17 00:00:00 2001 From: Nikhil Ailani <46107121+nikhilailani@users.noreply.github.com> Date: Mon, 7 Dec 2020 16:52:18 +0530 Subject: [PATCH 16/48] Create bfs_exercise.md --- .../9_BreadthFirstSearch/bfs_exercise.md | 34 +++++++++++++++++++ 1 file changed, 34 insertions(+) create mode 100644 algorithms/9_BreadthFirstSearch/bfs_exercise.md diff --git a/algorithms/9_BreadthFirstSearch/bfs_exercise.md b/algorithms/9_BreadthFirstSearch/bfs_exercise.md new file mode 100644 index 0000000..0efc20f --- /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 program to find whether a path exists for an airline route or not. The routes are described using graph having nodes. The names of the graphs are named alphabet characters for easy understanding. Print the path if it exists; print the denying statement if it doesn't! + +Example: A, B, C, D, E, F are the nodes of the graph. + + +For example, 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/BFS_Traversal/blob/main/DFS_BFS_Graph.png) + + +**Explanation:** Here, selecting A as source node and D as destination node, the values are passed to the function. + +Your output should look like this: + +''' +Path exists! +Path : A->B->D +''' + +[Solution](https://github.com/nikhilailani/BFS_Traversal/blob/main/bfs_exercise_solution.py) From 5f1c5f8938424a00fdc16cdff88bd948fb26a914 Mon Sep 17 00:00:00 2001 From: Darshan beladiya <42748893+beladiyadarshan@users.noreply.github.com> Date: Mon, 7 Dec 2020 16:52:37 +0530 Subject: [PATCH 17/48] Update Dfs_Exerscise.md --- algorithms/8_depth_first_search/Dfs_Exerscise.md | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/algorithms/8_depth_first_search/Dfs_Exerscise.md b/algorithms/8_depth_first_search/Dfs_Exerscise.md index c50adb5..e785e9a 100644 --- a/algorithms/8_depth_first_search/Dfs_Exerscise.md +++ b/algorithms/8_depth_first_search/Dfs_Exerscise.md @@ -7,7 +7,7 @@ Given a Graph in Dictionary Form -print all employees who are reporting to given employee ``` -Data = {"karan": {"darshan","nikhil"}, +data = {"karan": {"darshan","nikhil"}, "darshan": {"khantil", "tanuj"}, 'tanuj': {"nikhil"}, "krinish": {"hetul"}, From 8adbdedd2d2ea18d19cf06d19760c012fc02d616 Mon Sep 17 00:00:00 2001 From: Nikhil Ailani <46107121+nikhilailani@users.noreply.github.com> Date: Mon, 7 Dec 2020 16:54:14 +0530 Subject: [PATCH 18/48] Create bfs_exercise_solution.py --- .../bfs_exercise_solution.py | 27 +++++++++++++++++++ 1 file changed, 27 insertions(+) create mode 100644 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..51ea270 --- /dev/null +++ b/algorithms/9_BreadthFirstSearch/bfs_exercise_solution.py @@ -0,0 +1,27 @@ +def bfs(data, start, end, visited=[]): + queue = [start] + + while queue: + current_node = queue.pop(0) + if current_node==end: + print("Path exists!") + 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') From 7d58e11687bcef1bfa37d543e82a1eb5d6f4e908 Mon Sep 17 00:00:00 2001 From: Nikhil Ailani <46107121+nikhilailani@users.noreply.github.com> Date: Mon, 7 Dec 2020 16:54:51 +0530 Subject: [PATCH 19/48] Add files via upload --- .../9_BreadthFirstSearch/DFS_BFS_Graph.png | Bin 0 -> 9388 bytes 1 file changed, 0 insertions(+), 0 deletions(-) create mode 100644 algorithms/9_BreadthFirstSearch/DFS_BFS_Graph.png diff --git a/algorithms/9_BreadthFirstSearch/DFS_BFS_Graph.png b/algorithms/9_BreadthFirstSearch/DFS_BFS_Graph.png new file mode 100644 index 0000000000000000000000000000000000000000..db439bbe3913ae7055536c3855d772b21c2c76af GIT binary patch literal 9388 zcmeHNX;hQfy8aLmg#xuQRGF+;5D`69kd(0s7Q-wu6=bkl0SCYu2E!0U5tUYI(OQu~ zB!G+oK|nA8s$A4orZ5N?NJR@FK%x@D6ms7kru3|{?p^Dyb=SQ=&JPyr{f52wxA!|d z&-3Q8lY_OK%mx_@!{qS$t(-AT@&$&i@L9bAu1FjRnL+=~I9u<T0)TM1na>#U<{ zf2i6Tf2U;UyealL;oPg4X8!JK*8!{*7I3x_KJ8rCsVV(4D3@b@*T7|{(2)i+? zFtWV<`J>jQ>zu5+_zC$ z)FrT{99!JM&_|x((ikpj)1PWe@2(L)!RpqRuh!XeK}as}r7Lk-WHC&`HlFL$!0D|X z+dzGP%3B)ae)Y+PM%_rb&u95iSTb0wb*rZ7{`#4{?9ghCY>@<}u{VmlI(tmE$elg5 zqkI*HOMlM{**BIQW<89**&~6e*@cA^zMpWe8Q?v#9mTM#YCS>x@hJd?L??hMq{ z$1peg`a<`|4xXt+bURNtx}04eg|TVnFD?C3%HiZ}j+S`vi~~y(nhap9lIu_XvfD!2 zzST)P*|q}nQ;)B=31yQTjv2pdQCu`z2o`C<0Ww(0)!+QGt3v~-Gn$MHq%aTb!zFgD zFjV$c95StZO6(ep4XDlir0A)$m6ZOJ!uKC4gva5I%Pi*DL>I-kwm?ALg6ONvY#Eb1+OVK(_OqYeJ4uT1SSoK%8Bh4b zN2RBqvommcJF5#Ez7*SdhHI``$_i}TrX3!60qQAZxgYG|{KZT;7_jrer-d$+4xT4- z9*dhJb__X-VOsrX&tGP;x{Y6urBLQLZ+X2mS$UA9 zmaL3n(m!ob%lxqRVh?i*ZzMY`siSPi14)tn)#syNw;dGOKQNgd@nAQy z&x(Qseq@a;M67ALHo#jp|VnZnJj|+*L=2upapYrDGc*|j2kF6KZxYR>fVwiu+ zrqsMmK1DT>SgQ545ZZ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IPN+wqoK;pk+vp2v`Qbw4H0zb%%~D(aK*q(1<4irA4@{F%PwA+q$v3PJ(38K~!$W%gSn_ zriiTG{!x`FL?l;WvzLRIr;*D4Bg`RNK&oS$LbZ-`S2ZFP^$)aajaFbM?TxrNRF%F) zt4djX1Ag{UV#uf)K;2`+-2G1c%UQ`#Z04X-S$7={ZJ~sKq>9_K z+~Vg3t%y6LSOStfVti2PTRu+B`C+M#1gJD5Wm&*y+U$(mrL+uX02id@iB%M27m5k^ zP|i{*Vig6zONEn|fDgd4X3O`!0aVX$QYMrG=rpP7hJx+Dk4851sUmeF#C}Wx;IdaY zvVW19VX;u7Zs(Io1-5Vv6n7D7oN$#|3QzC(ih}yfU%E8v5v;LTtw8y7yV5ACj{?U1 z`1N@mxB0HEhQlTJfy@8zU#-Z&_kp+lpZ>z8K)@jh74Wa3UD}I Date: Mon, 7 Dec 2020 16:56:37 +0530 Subject: [PATCH 20/48] Update bfs_exercise.md --- algorithms/9_BreadthFirstSearch/bfs_exercise.md | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/algorithms/9_BreadthFirstSearch/bfs_exercise.md b/algorithms/9_BreadthFirstSearch/bfs_exercise.md index 0efc20f..627709c 100644 --- a/algorithms/9_BreadthFirstSearch/bfs_exercise.md +++ b/algorithms/9_BreadthFirstSearch/bfs_exercise.md @@ -19,7 +19,7 @@ data = {'A': {'B'}, the resultant graph will be :- -![alt text](https://github.com/nikhilailani/BFS_Traversal/blob/main/DFS_BFS_Graph.png) +![alt text](https://github.com/nikhilailani/data-structures-algorithms-python/blob/master/algorithms/9_BreadthFirstSearch/DFS_BFS_Graph.png) **Explanation:** Here, selecting A as source node and D as destination node, the values are passed to the function. @@ -31,4 +31,4 @@ Path exists! Path : A->B->D ''' -[Solution](https://github.com/nikhilailani/BFS_Traversal/blob/main/bfs_exercise_solution.py) +[Solution](https://github.com/nikhilailani/data-structures-algorithms-python/blob/master/algorithms/9_BreadthFirstSearch/DFS_BFS_Graph.pngbfs_exercise_solution.py) From 7d9cac46e1d6e40d666f437983c0ed069eb15d0b Mon Sep 17 00:00:00 2001 From: Nikhil Ailani <46107121+nikhilailani@users.noreply.github.com> Date: Mon, 7 Dec 2020 16:57:17 +0530 Subject: [PATCH 21/48] Update bfs_exercise.md --- algorithms/9_BreadthFirstSearch/bfs_exercise.md | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/algorithms/9_BreadthFirstSearch/bfs_exercise.md b/algorithms/9_BreadthFirstSearch/bfs_exercise.md index 627709c..9384e8a 100644 --- a/algorithms/9_BreadthFirstSearch/bfs_exercise.md +++ b/algorithms/9_BreadthFirstSearch/bfs_exercise.md @@ -31,4 +31,4 @@ Path exists! Path : A->B->D ''' -[Solution](https://github.com/nikhilailani/data-structures-algorithms-python/blob/master/algorithms/9_BreadthFirstSearch/DFS_BFS_Graph.pngbfs_exercise_solution.py) +[Solution](https://github.com/nikhilailani/data-structures-algorithms-python/blob/master/algorithms/9_BreadthFirstSearch/bfs_exercise_solution.py) From e381bc8e434d2ab7769220090c26603c9f67584d Mon Sep 17 00:00:00 2001 From: Darshan beladiya <42748893+beladiyadarshan@users.noreply.github.com> Date: Wed, 23 Dec 2020 09:07:18 +0530 Subject: [PATCH 22/48] Update Dfs_Exerscise.md --- algorithms/8_depth_first_search/Dfs_Exerscise.md | 6 ++---- 1 file changed, 2 insertions(+), 4 deletions(-) diff --git a/algorithms/8_depth_first_search/Dfs_Exerscise.md b/algorithms/8_depth_first_search/Dfs_Exerscise.md index e785e9a..710092a 100644 --- a/algorithms/8_depth_first_search/Dfs_Exerscise.md +++ b/algorithms/8_depth_first_search/Dfs_Exerscise.md @@ -1,10 +1,8 @@ # DFS Exercise -![alt text](https://github.com/beladiyadarshan/Dfs/blob/main/emp.png?raw=true) +![Overview : Employee hierarchy](https://github.com/beladiyadarshan/Dfs/blob/main/emp.png?raw=true) -Given a Graph in Dictionary Form - --print all employees who are reporting to given employee +Given a Graph in Dictionary Form.You have to print all employees who are reporting to given employee ``` data = {"karan": {"darshan","nikhil"}, From d6acab4c1b507858d2098634513f89a85cee8a6a Mon Sep 17 00:00:00 2001 From: Darshan beladiya <42748893+beladiyadarshan@users.noreply.github.com> Date: Wed, 23 Dec 2020 09:07:47 +0530 Subject: [PATCH 23/48] Update Dfs_exercise.py --- algorithms/8_depth_first_search/Dfs_exercise.py | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/algorithms/8_depth_first_search/Dfs_exercise.py b/algorithms/8_depth_first_search/Dfs_exercise.py index 92badb8..09a74bf 100644 --- a/algorithms/8_depth_first_search/Dfs_exercise.py +++ b/algorithms/8_depth_first_search/Dfs_exercise.py @@ -1,11 +1,11 @@ #function for depth first search -def dfs(data, start,emp,visited=set()): +def dfs(data, start,employee,visited=set()): #if not visited print it if start not in visited: print(start,end=" ") - if start==emp: + if start==employee: print(":",end=" ") From 23a6cc984544cb8cb058f90aa6cbe1cda507afe6 Mon Sep 17 00:00:00 2001 From: d_p_beladiya Date: Wed, 23 Dec 2020 10:13:22 +0530 Subject: [PATCH 24/48] flake 8 convention followed --- .../8_depth_first_search/Dfs_exercise.py | 43 ++++++++----------- algorithms/8_depth_first_search/dfs.py | 22 ++++------ 2 files changed, 27 insertions(+), 38 deletions(-) diff --git a/algorithms/8_depth_first_search/Dfs_exercise.py b/algorithms/8_depth_first_search/Dfs_exercise.py index 09a74bf..d6c98d4 100644 --- a/algorithms/8_depth_first_search/Dfs_exercise.py +++ b/algorithms/8_depth_first_search/Dfs_exercise.py @@ -1,36 +1,29 @@ -#function for depth first search -def dfs(data, start,employee,visited=set()): - - #if not visited print it +# function for depth first search +def dfs(data, start, employee, visited=set()): + # if not visited print it if start not in visited: - print(start,end=" ") - - if start==employee: - print(":",end=" ") - - + 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 + # if not visited go in depth of it dfs(data, i, visited) - - return - + return -#sample data in dictionary form -data = {"karan": {"darshan","nikhil"}, - "darshan": {"khantil", "tanuj"}, - 'tanuj': {"nikhil"}, - "krinish": {"hetul"}, - "khantil" : set(), - "nikhil" : set() - } +# sample data in dictionary form +data = { + "karan": {"darshan", "nikhil"}, + "darshan": {"khantil", "tanuj"}, + 'tanuj': {"nikhil"}, + "krinish": {"hetul"}, + "khantil": set(), + "nikhil": set() + } if __name__ == '__main__': - dfs(data, "karan","karan") + dfs(data, "karan", "karan") diff --git a/algorithms/8_depth_first_search/dfs.py b/algorithms/8_depth_first_search/dfs.py index 5cb909f..1671f4e 100644 --- a/algorithms/8_depth_first_search/dfs.py +++ b/algorithms/8_depth_first_search/dfs.py @@ -1,23 +1,20 @@ -#function for depth first search +# function for depth first search def dfs(data, start, visited=set()): - - #if not visited print it + + # if not visited print it if start not in visited: - print(start,end=" ") - - visited.add(start) + 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 + # if not visited gi in depth of it + dfs(data, i, visited) + return -#sample data in dictionary form +# sample data in dictionary form data = {'A': {'B'}, 'B': {'A', 'C', 'D'}, 'C': {'B', 'E'}, @@ -26,7 +23,6 @@ def dfs(data, start, visited=set()): 'F': {'E'}} - if __name__ == '__main__': dfs(data, 'A') From c199807d83e9fa3375c058c94629a10130729972 Mon Sep 17 00:00:00 2001 From: d_p_beladiya Date: Wed, 23 Dec 2020 10:33:52 +0530 Subject: [PATCH 25/48] Modified md file --- .../8_depth_first_search/Dfs_Exerscise.md | 26 +++++++------------ 1 file changed, 10 insertions(+), 16 deletions(-) diff --git a/algorithms/8_depth_first_search/Dfs_Exerscise.md b/algorithms/8_depth_first_search/Dfs_Exerscise.md index 710092a..7f0b295 100644 --- a/algorithms/8_depth_first_search/Dfs_Exerscise.md +++ b/algorithms/8_depth_first_search/Dfs_Exerscise.md @@ -1,8 +1,8 @@ # DFS Exercise -![Overview : Employee hierarchy](https://github.com/beladiyadarshan/Dfs/blob/main/emp.png?raw=true) +![Overview : Employee hierarchy](https://github.com/beladiyadarshan/DFS/blob/main/emp.png?raw=true) -Given a Graph in Dictionary Form.You have to print all employees who are reporting to given employee +Given a graph in dictionary form, print all employees reporting to given employee. ``` data = {"karan": {"darshan","nikhil"}, @@ -16,27 +16,21 @@ data = {"karan": {"darshan","nikhil"}, ``` - here darshan and nikhil are reporting to karan and so on.... + Here, Darshan and Nikhil are reporting to Karan and so on... ``` - Q.find all employees who are reporting to karan - -do dfs on karan and print all the employees + Q.Find all employees who are reporting to Karan + -perform DFS on Karan and print all the employees ``` -**Explanation :** +**Explanation:** --so here we wants to find all the childs of karan +-So here, we want to find all the children of Karan. --we will do dfs on karan and then we will traverse all the childs of karan that are not visited +-We will perform DFS on Karan and then traverse all the children of Karan which are unvisited. -**output will be :** +**Output:** karan : nikhil darshan tanuj khantil -[Solution](https://github.com/beladiyadarshan/Dfs/blob/main/Dfs_exercise.py) - - - - - - +[Solution](https://github.com/beladiyadarshan/DFS/blob/main/DFS_exercise.py) From be6438480d48434efa02570a315b800fcb7268a2 Mon Sep 17 00:00:00 2001 From: nikhilailani Date: Wed, 23 Dec 2020 15:28:36 +0530 Subject: [PATCH 26/48] Create 9_BreadthFirstSearch module --- .vscode/settings.json | 5 +++++ algorithms/9_BreadthFirstSearch/bfs.py | 25 ++++++++++++------------- 2 files changed, 17 insertions(+), 13 deletions(-) create mode 100644 .vscode/settings.json diff --git a/.vscode/settings.json b/.vscode/settings.json new file mode 100644 index 0000000..5b91456 --- /dev/null +++ b/.vscode/settings.json @@ -0,0 +1,5 @@ +{ + "python.linting.pylintEnabled": false, + "python.linting.flake8Enabled": true, + "python.linting.enabled": true +} \ No newline at end of file diff --git a/algorithms/9_BreadthFirstSearch/bfs.py b/algorithms/9_BreadthFirstSearch/bfs.py index 137ad87..01b6a1f 100644 --- a/algorithms/9_BreadthFirstSearch/bfs.py +++ b/algorithms/9_BreadthFirstSearch/bfs.py @@ -1,24 +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 = " ") + 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'}} - + + data = { + 'A': {'B'}, 'B': {'A', 'C', 'D'}, 'C': {'B', 'E'}, 'D': {'B', 'E'}, + 'E': {'C', 'D', 'F'}, 'F': {'E'} + } + bfs(data, 'A') From 4bf2c680acfeeff43adffa2239c8054e7514d6e8 Mon Sep 17 00:00:00 2001 From: Darshan beladiya <42748893+beladiyadarshan@users.noreply.github.com> Date: Thu, 24 Dec 2020 14:44:50 +0530 Subject: [PATCH 27/48] Rename Dfs_exercise.py to dfs_exercise.py --- .../8_depth_first_search/{Dfs_exercise.py => dfs_exercise.py} | 0 1 file changed, 0 insertions(+), 0 deletions(-) rename algorithms/8_depth_first_search/{Dfs_exercise.py => dfs_exercise.py} (100%) diff --git a/algorithms/8_depth_first_search/Dfs_exercise.py b/algorithms/8_depth_first_search/dfs_exercise.py similarity index 100% rename from algorithms/8_depth_first_search/Dfs_exercise.py rename to algorithms/8_depth_first_search/dfs_exercise.py From 7dbdb25d8ba7893a7206c8ab3cb8172a65163915 Mon Sep 17 00:00:00 2001 From: Darshan beladiya <42748893+beladiyadarshan@users.noreply.github.com> Date: Thu, 24 Dec 2020 14:45:34 +0530 Subject: [PATCH 28/48] Update and rename Dfs_Exerscise.md to dfs_exerscise.md --- .../{Dfs_Exerscise.md => dfs_exerscise.md} | 5 +++-- 1 file changed, 3 insertions(+), 2 deletions(-) rename algorithms/8_depth_first_search/{Dfs_Exerscise.md => dfs_exerscise.md} (94%) diff --git a/algorithms/8_depth_first_search/Dfs_Exerscise.md b/algorithms/8_depth_first_search/dfs_exerscise.md similarity index 94% rename from algorithms/8_depth_first_search/Dfs_Exerscise.md rename to algorithms/8_depth_first_search/dfs_exerscise.md index 7f0b295..f44051b 100644 --- a/algorithms/8_depth_first_search/Dfs_Exerscise.md +++ b/algorithms/8_depth_first_search/dfs_exerscise.md @@ -5,13 +5,14 @@ Given a graph in dictionary form, print all employees reporting to given employee. ``` -data = {"karan": {"darshan","nikhil"}, +data = { + "karan": {"darshan","nikhil"}, "darshan": {"khantil", "tanuj"}, 'tanuj': {"nikhil"}, "krinish": {"hetul"}, "khantil" : set(), "nikhil" : set() - } + } ``` From 557eceb361ca9b7114c239b8fbaf85469136971d Mon Sep 17 00:00:00 2001 From: d_p_beladiya Date: Thu, 24 Dec 2020 14:50:13 +0530 Subject: [PATCH 29/48] corrected md file --- .vscode/settings.json | 5 +++++ algorithms/8_depth_first_search/Dfs_Exerscise.md | 3 ++- algorithms/8_depth_first_search/dfs.py | 6 ++++-- 3 files changed, 11 insertions(+), 3 deletions(-) create mode 100644 .vscode/settings.json diff --git a/.vscode/settings.json b/.vscode/settings.json new file mode 100644 index 0000000..9fadd3a --- /dev/null +++ b/.vscode/settings.json @@ -0,0 +1,5 @@ +{ + "python.linting.pylintEnabled": false, + "python.linting.flake8Enabled": true, + "python.linting.enabled": true +} \ No newline at end of file diff --git a/algorithms/8_depth_first_search/Dfs_Exerscise.md b/algorithms/8_depth_first_search/Dfs_Exerscise.md index 7f0b295..9f6cdf6 100644 --- a/algorithms/8_depth_first_search/Dfs_Exerscise.md +++ b/algorithms/8_depth_first_search/Dfs_Exerscise.md @@ -5,7 +5,8 @@ Given a graph in dictionary form, print all employees reporting to given employee. ``` -data = {"karan": {"darshan","nikhil"}, +data = { + "karan": {"darshan","nikhil"}, "darshan": {"khantil", "tanuj"}, 'tanuj': {"nikhil"}, "krinish": {"hetul"}, diff --git a/algorithms/8_depth_first_search/dfs.py b/algorithms/8_depth_first_search/dfs.py index 1671f4e..97bf329 100644 --- a/algorithms/8_depth_first_search/dfs.py +++ b/algorithms/8_depth_first_search/dfs.py @@ -15,12 +15,14 @@ def dfs(data, start, visited=set()): # sample data in dictionary form -data = {'A': {'B'}, +data = { + 'A': {'B'}, 'B': {'A', 'C', 'D'}, 'C': {'B', 'E'}, 'D': {'B', 'E'}, 'E': {'C', 'D', 'F'}, - 'F': {'E'}} + 'F': {'E'} + } if __name__ == '__main__': From 5e8bef68d715860230f451096a73ddc57f354695 Mon Sep 17 00:00:00 2001 From: Karandeep Grover Date: Thu, 24 Dec 2020 15:06:54 +0530 Subject: [PATCH 30/48] BLD: added vscode/settings.json to gitignore --- .gitignore | 3 +++ 1 file changed, 3 insertions(+) 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 From a1b46fb665aa7e70b1bd94530fa2796d8b644eaf Mon Sep 17 00:00:00 2001 From: Karandeep Singh Grover <30365139+groverkds@users.noreply.github.com> Date: Thu, 24 Dec 2020 15:07:35 +0530 Subject: [PATCH 31/48] Delete settings.json --- .vscode/settings.json | 5 ----- 1 file changed, 5 deletions(-) delete mode 100644 .vscode/settings.json diff --git a/.vscode/settings.json b/.vscode/settings.json deleted file mode 100644 index 9fadd3a..0000000 --- a/.vscode/settings.json +++ /dev/null @@ -1,5 +0,0 @@ -{ - "python.linting.pylintEnabled": false, - "python.linting.flake8Enabled": true, - "python.linting.enabled": true -} \ No newline at end of file From 70c126e0f4d4289051b50943473fbb3796455323 Mon Sep 17 00:00:00 2001 From: Karandeep Singh Grover <30365139+groverkds@users.noreply.github.com> Date: Thu, 24 Dec 2020 15:07:50 +0530 Subject: [PATCH 32/48] Delete settings.json --- .vscode/settings.json | 5 ----- 1 file changed, 5 deletions(-) delete mode 100644 .vscode/settings.json diff --git a/.vscode/settings.json b/.vscode/settings.json deleted file mode 100644 index 5b91456..0000000 --- a/.vscode/settings.json +++ /dev/null @@ -1,5 +0,0 @@ -{ - "python.linting.pylintEnabled": false, - "python.linting.flake8Enabled": true, - "python.linting.enabled": true -} \ No newline at end of file From 074c6ca42d9bd847dd143a7c0852bbea83dc7cbf Mon Sep 17 00:00:00 2001 From: Karandeep Singh Grover <30365139+groverkds@users.noreply.github.com> Date: Thu, 24 Dec 2020 15:08:46 +0530 Subject: [PATCH 33/48] Update dfs_exercise.py --- algorithms/8_depth_first_search/dfs_exercise.py | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/algorithms/8_depth_first_search/dfs_exercise.py b/algorithms/8_depth_first_search/dfs_exercise.py index d6c98d4..1c287d1 100644 --- a/algorithms/8_depth_first_search/dfs_exercise.py +++ b/algorithms/8_depth_first_search/dfs_exercise.py @@ -17,11 +17,11 @@ def dfs(data, start, employee, visited=set()): data = { "karan": {"darshan", "nikhil"}, "darshan": {"khantil", "tanuj"}, - 'tanuj': {"nikhil"}, + "tanuj": {"nikhil"}, "krinish": {"hetul"}, "khantil": set(), "nikhil": set() - } +} if __name__ == '__main__': From 57f9f13bcc9cc2a6476dc7aaaa77c2927a6125d1 Mon Sep 17 00:00:00 2001 From: Karandeep Singh Grover <30365139+groverkds@users.noreply.github.com> Date: Thu, 24 Dec 2020 15:11:57 +0530 Subject: [PATCH 34/48] Update dfs_exerscise.md --- algorithms/8_depth_first_search/dfs_exerscise.md | 15 +++++++-------- 1 file changed, 7 insertions(+), 8 deletions(-) diff --git a/algorithms/8_depth_first_search/dfs_exerscise.md b/algorithms/8_depth_first_search/dfs_exerscise.md index f44051b..34fa25d 100644 --- a/algorithms/8_depth_first_search/dfs_exerscise.md +++ b/algorithms/8_depth_first_search/dfs_exerscise.md @@ -2,13 +2,13 @@ ![Overview : Employee hierarchy](https://github.com/beladiyadarshan/DFS/blob/main/emp.png?raw=true) -Given a graph in dictionary form, print all employees reporting to given employee. +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"}, + "tanuj": {"nikhil"}, "krinish": {"hetul"}, "khantil" : set(), "nikhil" : set() @@ -17,21 +17,20 @@ data = { ``` - Here, Darshan and Nikhil are reporting to Karan and so on... + Example: Darshan and Nikhil are reporting to Karan. Khantil and Tanuj are reporting to Darshan. ``` - Q.Find all employees who are reporting to Karan - -perform DFS on Karan and print all the employees + Q. Find all employees who are reporting to Karan. ``` **Explanation:** --So here, we want to find all the children of Karan. +-So here, we want to find all the children nodes of Karan. --We will perform DFS on Karan and then traverse all the children of Karan which are unvisited. +-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) +[Solution](https://github.com/beladiyadarshan/DFS/blob/main/dfs_exercise.py) From 1d7c3087560098a7f7bc1c5cea0efb73360361cf Mon Sep 17 00:00:00 2001 From: Karandeep Singh Grover <30365139+groverkds@users.noreply.github.com> Date: Thu, 24 Dec 2020 15:16:26 +0530 Subject: [PATCH 35/48] Update dfs_exercise.py --- algorithms/8_depth_first_search/dfs_exercise.py | 6 +++--- 1 file changed, 3 insertions(+), 3 deletions(-) diff --git a/algorithms/8_depth_first_search/dfs_exercise.py b/algorithms/8_depth_first_search/dfs_exercise.py index 1c287d1..310a483 100644 --- a/algorithms/8_depth_first_search/dfs_exercise.py +++ b/algorithms/8_depth_first_search/dfs_exercise.py @@ -1,5 +1,5 @@ # function for depth first search -def dfs(data, start, employee, visited=set()): +def find_employees(data, start, employee, visited=set()): # if not visited print it if start not in visited: print(start, end=" ") @@ -9,7 +9,7 @@ def dfs(data, start, employee, visited=set()): for i in data[start] - visited: # if not visited go in depth of it - dfs(data, i, visited) + find_employees(data, i, visited) return @@ -26,4 +26,4 @@ def dfs(data, start, employee, visited=set()): if __name__ == '__main__': - dfs(data, "karan", "karan") + find_employees(data, "karan", "karan") From 699382b9ccb6c85e5f26fe796d1a45b54fddf5ef Mon Sep 17 00:00:00 2001 From: Nikhil Ailani <46107121+nikhilailani@users.noreply.github.com> Date: Thu, 24 Dec 2020 15:23:45 +0530 Subject: [PATCH 36/48] Update bfs_exercise_solution.py --- algorithms/9_BreadthFirstSearch/bfs_exercise_solution.py | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/algorithms/9_BreadthFirstSearch/bfs_exercise_solution.py b/algorithms/9_BreadthFirstSearch/bfs_exercise_solution.py index 51ea270..f6f3a8e 100644 --- a/algorithms/9_BreadthFirstSearch/bfs_exercise_solution.py +++ b/algorithms/9_BreadthFirstSearch/bfs_exercise_solution.py @@ -5,7 +5,7 @@ def bfs(data, start, end, visited=[]): current_node = queue.pop(0) if current_node==end: print("Path exists!") - print("Path : " + "->".join(visited) + "->"+end) + print("Path: " + "->".join(visited) + "->" + end) return visited.append(current_node) From 018f909132aff5fbeb8a474bacf36b9c392cdefc Mon Sep 17 00:00:00 2001 From: Nikhil Ailani <46107121+nikhilailani@users.noreply.github.com> Date: Thu, 24 Dec 2020 15:24:33 +0530 Subject: [PATCH 37/48] Update bfs_exercise_solution.py --- .../9_BreadthFirstSearch/bfs_exercise_solution.py | 14 ++++++++------ 1 file changed, 8 insertions(+), 6 deletions(-) diff --git a/algorithms/9_BreadthFirstSearch/bfs_exercise_solution.py b/algorithms/9_BreadthFirstSearch/bfs_exercise_solution.py index f6f3a8e..bb8dd9f 100644 --- a/algorithms/9_BreadthFirstSearch/bfs_exercise_solution.py +++ b/algorithms/9_BreadthFirstSearch/bfs_exercise_solution.py @@ -18,10 +18,12 @@ def bfs(data, start, end, visited=[]): if __name__ == '__main__': - data = {'A': {'B'}, - 'B': {'C', 'D'}, - 'C': {'E'}, - 'D': {'E'}, - 'E': {'F'}, - 'F': set()} + data = { + 'A': {'B'}, + 'B': {'C', 'D'}, + 'C': {'E'}, + 'D': {'E'}, + 'E': {'F'}, + 'F': set() + } bfs(data, 'A', 'D') From 8d9b988e9d8f3baf415a52cd16caed44b2b281e2 Mon Sep 17 00:00:00 2001 From: Nikhil Ailani <46107121+nikhilailani@users.noreply.github.com> Date: Thu, 24 Dec 2020 15:25:31 +0530 Subject: [PATCH 38/48] Update bfs_exercise_solution.py --- algorithms/9_BreadthFirstSearch/bfs_exercise_solution.py | 8 +++----- 1 file changed, 3 insertions(+), 5 deletions(-) diff --git a/algorithms/9_BreadthFirstSearch/bfs_exercise_solution.py b/algorithms/9_BreadthFirstSearch/bfs_exercise_solution.py index bb8dd9f..9de0d32 100644 --- a/algorithms/9_BreadthFirstSearch/bfs_exercise_solution.py +++ b/algorithms/9_BreadthFirstSearch/bfs_exercise_solution.py @@ -1,6 +1,6 @@ def bfs(data, start, end, visited=[]): queue = [start] - + while queue: current_node = queue.pop(0) if current_node==end: @@ -8,15 +8,13 @@ def bfs(data, start, end, visited=[]): 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'}, From 080306a92dcf7e7fea99da67e4b70276d70bc01d Mon Sep 17 00:00:00 2001 From: Nikhil Ailani <46107121+nikhilailani@users.noreply.github.com> Date: Thu, 24 Dec 2020 15:32:16 +0530 Subject: [PATCH 39/48] Update bfs_exercise.md --- algorithms/9_BreadthFirstSearch/bfs_exercise.md | 6 ++++-- 1 file changed, 4 insertions(+), 2 deletions(-) diff --git a/algorithms/9_BreadthFirstSearch/bfs_exercise.md b/algorithms/9_BreadthFirstSearch/bfs_exercise.md index 9384e8a..16fabbb 100644 --- a/algorithms/9_BreadthFirstSearch/bfs_exercise.md +++ b/algorithms/9_BreadthFirstSearch/bfs_exercise.md @@ -9,12 +9,14 @@ Example: A, B, C, D, E, F are the nodes of the graph. For example, you are given following data: ``` -data = {'A': {'B'}, +data = { + 'A': {'B'}, 'B': {'A', 'C', 'D'}, 'C': {'B', 'E'}, 'D': {'B', 'E'}, 'E': {'C', 'D', 'F'}, - 'F': {'E'}} + 'F': {'E'} +} ``` the resultant graph will be :- From 24c469c95e1df4d8f2c270983703c0f075ab9609 Mon Sep 17 00:00:00 2001 From: Karandeep Singh Grover <30365139+groverkds@users.noreply.github.com> Date: Thu, 24 Dec 2020 15:42:17 +0530 Subject: [PATCH 40/48] Update bfs_exercise.md --- algorithms/9_BreadthFirstSearch/bfs_exercise.md | 12 +++++------- 1 file changed, 5 insertions(+), 7 deletions(-) diff --git a/algorithms/9_BreadthFirstSearch/bfs_exercise.md b/algorithms/9_BreadthFirstSearch/bfs_exercise.md index 16fabbb..bbca067 100644 --- a/algorithms/9_BreadthFirstSearch/bfs_exercise.md +++ b/algorithms/9_BreadthFirstSearch/bfs_exercise.md @@ -1,7 +1,7 @@ # BFS_Traversal BFS Traversal of a graph in python using graph given in dictionary -Implement a program to find whether a path exists for an airline route or not. The routes are described using graph having nodes. The names of the graphs are named alphabet characters for easy understanding. Print the path if it exists; print the denying statement if it doesn't! +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. @@ -23,14 +23,12 @@ 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. -**Explanation:** Here, selecting A as source node and D as destination node, the values are passed to the function. +Expected Output: -Your output should look like this: - -''' -Path exists! +``` Path : A->B->D -''' +``` [Solution](https://github.com/nikhilailani/data-structures-algorithms-python/blob/master/algorithms/9_BreadthFirstSearch/bfs_exercise_solution.py) From c95f88c07803e88adcd8d532c5e2e495655ba712 Mon Sep 17 00:00:00 2001 From: Karandeep Singh Grover <30365139+groverkds@users.noreply.github.com> Date: Thu, 24 Dec 2020 15:42:47 +0530 Subject: [PATCH 41/48] Update bfs_exercise_solution.py --- algorithms/9_BreadthFirstSearch/bfs_exercise_solution.py | 1 - 1 file changed, 1 deletion(-) diff --git a/algorithms/9_BreadthFirstSearch/bfs_exercise_solution.py b/algorithms/9_BreadthFirstSearch/bfs_exercise_solution.py index 9de0d32..46f6b41 100644 --- a/algorithms/9_BreadthFirstSearch/bfs_exercise_solution.py +++ b/algorithms/9_BreadthFirstSearch/bfs_exercise_solution.py @@ -4,7 +4,6 @@ def bfs(data, start, end, visited=[]): while queue: current_node = queue.pop(0) if current_node==end: - print("Path exists!") print("Path: " + "->".join(visited) + "->" + end) return visited.append(current_node) From 9e9315586717668be93f7bb0fb202401bcaf62c9 Mon Sep 17 00:00:00 2001 From: Karandeep Singh Grover <30365139+groverkds@users.noreply.github.com> Date: Thu, 24 Dec 2020 15:45:34 +0530 Subject: [PATCH 42/48] Update bfs_exercise.md --- algorithms/9_BreadthFirstSearch/bfs_exercise.md | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/algorithms/9_BreadthFirstSearch/bfs_exercise.md b/algorithms/9_BreadthFirstSearch/bfs_exercise.md index bbca067..09ac2ab 100644 --- a/algorithms/9_BreadthFirstSearch/bfs_exercise.md +++ b/algorithms/9_BreadthFirstSearch/bfs_exercise.md @@ -6,7 +6,7 @@ Implement a function to find whether a path exists for a given set of airline ro Example: A, B, C, D, E, F are the nodes of the graph. -For example, you are given following data: +For example, if you are given following data: ``` data = { @@ -19,7 +19,7 @@ data = { } ``` -the resultant graph will be :- +The resultant graph will be: ![alt text](https://github.com/nikhilailani/data-structures-algorithms-python/blob/master/algorithms/9_BreadthFirstSearch/DFS_BFS_Graph.png) From cdf5bbc2ca64b62f25a82ceafb2dd73da2fa0155 Mon Sep 17 00:00:00 2001 From: Karandeep Grover Date: Thu, 24 Dec 2020 17:46:59 +0530 Subject: [PATCH 43/48] CLN: renamed the folder to follow the directory convention --- .../dfs.py | 0 .../dfs_exercise.py | 0 .../dfs_exerscise.md | 0 .../emp.png | Bin .../updated_graph.jpg | Bin 5 files changed, 0 insertions(+), 0 deletions(-) rename algorithms/{8_depth_first_search => 8_DepthFirstSearch}/dfs.py (100%) rename algorithms/{8_depth_first_search => 8_DepthFirstSearch}/dfs_exercise.py (100%) rename algorithms/{8_depth_first_search => 8_DepthFirstSearch}/dfs_exerscise.md (100%) rename algorithms/{8_depth_first_search => 8_DepthFirstSearch}/emp.png (100%) rename algorithms/{8_depth_first_search => 8_DepthFirstSearch}/updated_graph.jpg (100%) diff --git a/algorithms/8_depth_first_search/dfs.py b/algorithms/8_DepthFirstSearch/dfs.py similarity index 100% rename from algorithms/8_depth_first_search/dfs.py rename to algorithms/8_DepthFirstSearch/dfs.py diff --git a/algorithms/8_depth_first_search/dfs_exercise.py b/algorithms/8_DepthFirstSearch/dfs_exercise.py similarity index 100% rename from algorithms/8_depth_first_search/dfs_exercise.py rename to algorithms/8_DepthFirstSearch/dfs_exercise.py diff --git a/algorithms/8_depth_first_search/dfs_exerscise.md b/algorithms/8_DepthFirstSearch/dfs_exerscise.md similarity index 100% rename from algorithms/8_depth_first_search/dfs_exerscise.md rename to algorithms/8_DepthFirstSearch/dfs_exerscise.md diff --git a/algorithms/8_depth_first_search/emp.png b/algorithms/8_DepthFirstSearch/emp.png similarity index 100% rename from algorithms/8_depth_first_search/emp.png rename to algorithms/8_DepthFirstSearch/emp.png diff --git a/algorithms/8_depth_first_search/updated_graph.jpg b/algorithms/8_DepthFirstSearch/updated_graph.jpg similarity index 100% rename from algorithms/8_depth_first_search/updated_graph.jpg rename to algorithms/8_DepthFirstSearch/updated_graph.jpg From be9fe697fe46e4be29f94ca3b7d19be0b890d905 Mon Sep 17 00:00:00 2001 From: Karandeep Grover Date: Tue, 26 Jan 2021 10:12:03 +0530 Subject: [PATCH 44/48] updated links which were not working --- .../1_BinarySearch/binary_search_exercise.md | 2 +- algorithms/2_BubbleSort/bubble_sort_exercise.md | 4 ++-- algorithms/3_QuickSort/quick_sort_exercise.md | 2 +- data_structures/2_Arrays/2_arrays_exercise.md | 6 +++--- .../3_LinkedList/3_linked_list_exercise.md | 8 ++++---- .../4_hash_table_exercise.md | 14 +++++++------- data_structures/6_Queue/6_queue_exercise.md | 2 +- data_structures/7_Tree/7_tree_exercise.md | 6 +++--- 8 files changed, 22 insertions(+), 22 deletions(-) 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/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/6_Queue/6_queue_exercise.md b/data_structures/6_Queue/6_queue_exercise.md index 0106930..618f9e0 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) 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) From 4d8a294ddf4dade0bc2bf48af7be401f7014c2ff Mon Sep 17 00:00:00 2001 From: Karandeep Grover Date: Tue, 26 Jan 2021 10:14:11 +0530 Subject: [PATCH 45/48] updated not working links --- data_structures/5_Stack/5_stack_exercise.md | 8 ++++---- data_structures/6_Queue/6_queue_exercise.md | 4 ++-- .../8_Binary_Tree_1/8_binary_tree_part_1_exercise.md | 4 ++-- .../9_Binary_Tree_2/9_binary_tree_part_2_exercise.md | 4 ++-- 4 files changed, 10 insertions(+), 10 deletions(-) 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 618f9e0..3c3fc2d 100644 --- a/data_structures/6_Queue/6_queue_exercise.md +++ b/data_structures/6_Queue/6_queue_exercise.md @@ -15,7 +15,7 @@ For all exercises use [Queue class](https://github.com/codebasics/data-structure 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/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) From 3174849813e2d5851b75aab564fc57ab566ce6fa Mon Sep 17 00:00:00 2001 From: codebasics Date: Tue, 9 Feb 2021 19:23:02 -0500 Subject: [PATCH 46/48] recursion --- algorithms/8_recursion/recursion.py | 16 ++++++++++++++++ 1 file changed, 16 insertions(+) create mode 100644 algorithms/8_recursion/recursion.py diff --git a/algorithms/8_recursion/recursion.py b/algorithms/8_recursion/recursion.py new file mode 100644 index 0000000..a903e1f --- /dev/null +++ b/algorithms/8_recursion/recursion.py @@ -0,0 +1,16 @@ +def find_sum(n): + if n==1: + return 1 + return n + find_sum(n-1) + +def fib(n): + # 0,1,1,2,3,5,8 <-- fibonacci numbers + # -------------- + # 0,1,2,3,4,5,6 <-- index + if n==0 or n==1: + return n + return fib(n-1) + fib(n-2) + +if __name__=='__main__': + print(find_sum(5)) + print(fib(10)) \ No newline at end of file From fd97ca9e7377af65b2c6e7edbbe60f287b85d047 Mon Sep 17 00:00:00 2001 From: Aravinth Date: Thu, 8 Jul 2021 19:12:09 +0530 Subject: [PATCH 47/48] range updated to get odd numbers between 1 and max number --- data_structures/2_Arrays/Solution/3_odd_even_numbers.py | 6 +++--- 1 file changed, 3 insertions(+), 3 deletions(-) diff --git a/data_structures/2_Arrays/Solution/3_odd_even_numbers.py b/data_structures/2_Arrays/Solution/3_odd_even_numbers.py index 334b53c..ec1c4b7 100644 --- a/data_structures/2_Arrays/Solution/3_odd_even_numbers.py +++ b/data_structures/2_Arrays/Solution/3_odd_even_numbers.py @@ -2,8 +2,8 @@ odd_numbers = [] -for i in range(max): - if i%2 == 1: +for i in range(1, max): + if i % 2 == 1: odd_numbers.append(i) -print("Odd numbers: ",odd_numbers) +print("Odd numbers: ", odd_numbers) From 7d353b83e3498a0c1ec58ab184045b0b94f3a68b Mon Sep 17 00:00:00 2001 From: Dhaval Patel <60363945+dhavalsays@users.noreply.github.com> Date: Sun, 13 Nov 2022 19:23:15 -0500 Subject: [PATCH 48/48] Update bubble_sort_exercise.md --- algorithms/2_BubbleSort/bubble_sort_exercise.md | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/algorithms/2_BubbleSort/bubble_sort_exercise.md b/algorithms/2_BubbleSort/bubble_sort_exercise.md index 5068b08..e930890 100644 --- a/algorithms/2_BubbleSort/bubble_sort_exercise.md +++ b/algorithms/2_BubbleSort/bubble_sort_exercise.md @@ -36,5 +36,5 @@ elements = [ ] ``` -[Solution](https://github.com/codebasics/data-structures-algorithms-python/blob/master/algorithmsAlgorithms/2_BubbleSort/bubble_sort_exercise_solution.py) +[Solution](https://github.com/codebasics/data-structures-algorithms-python/blob/master/algorithms/2_BubbleSort/bubble_sort_exercise_solution.py)