PythonDSA

Level order traversal of Binary tree in Python

Level order traversal in python Input:- 5 3 7 2 4 6 8 Level order traversal of BST:  5 3 7 2 4 6 8 import sys class Node : def __init__ ( self ,data): self . right = self . left = None self . data = …

Height of Binary Search Tree in python

Find Height if Binary search tree in Python  Input:  5 3 7 2 4 6 8 Height of tree is : 3 class Node : def __init__ ( self ,data): self . right = self . left = None self . data = data class Solution : …

Bubble sort in python

Sample code for Bubble sort in Python #!/bin/python import sys print "Enter number of numbers" n = int ( raw_input () . strip()) print "Enter numbers separated by space" a = map ( int , raw_input () . strip() . split( &#…

Python data structure - Non sequence types

In the previous post we discussed about sequence types data structure. Here we will be discussing about non sequence types in built data structure of python. Set, frozenset and dict classes are  non -sequence types in python. set class: 1. Sets a…

Python Data Structures - Sequence types

Python has various inbuilt data structure like List, Set , Tuple, Dict which can be broadly classified in two categories. Sequence Types: The list, tuple, and str classes are sequence types in Python, representing a collection of values where  orde…

Load More
That is All