« first day (2349 days earlier)      last day (992 days later) » 

7:24 AM
I am Learning Binary Search tree , and Trying this problem Binary tree is Binary search tree or Not?

by doing inorder traversing i want to check is it in ascending order or not ,

def isBst(self,root,prev = None):
        if root is not None:

            self.isBst(root.left,prev)
            if prev != None and root.data <= prev.data:
                return False
            prev = root
            self.isBst(root.right,prev)
        else:
            return True
here I am trying to store each inorder traverse in prev variable and checking the next traverse with the prev if it is less th
@urig can you help me in this?
 
1 sec
I think there might be a few issues here.
First thing that comes to mind is that your main if condition doesn't hold for both sides.
I mean, when you're going down the left side you expect root to be smaller than prev and if you're going down the right side you expect it to be bigger.
Also, when you first run self.isBst() (inside that if block), the value from that is never used. You're not using it in your code.
 
@urig Yes! I am trying to do Inorder traversal of the tree and trying to check in each point that is it in ascending order or not
 
Your solution is based on recursion which is fine. In recursion you need to think of two things:
1. How do I break down the problem into smaller parts.
2. What is my stopping condition? When can I no longer break it down?
 
@urig yes
 
1 - You're half way there. You are breaking the problem into left and right. You need to find a way to combine the two parts back together again. Something like: left tree must be a bst AND right tree must be a BST.
2 - You need to identify and code your stopping condition. When do you stop going further down the left or right side?
 
7:37 AM
@urig I am breaking it until the root is not none , for the left and for the right tree
:52692663 i put an Outer if first where the condition is if root is not none:
 
>>> condition = None
>>> if condition:
...     print("Y")
... else:
...     print("N")
...
N
>>>
None is always False btw
 
@PallabTewary Yes. You are correct. Likely the issue is with only checking one side
 
@urig Sorry I am not able to understand . can you correct my code>
 
 
3 hours later…
10:52 AM
import numpy as np
from moviepy.editor import *
from moviepy.video.tools.segmenting import findObjects
screensize = (720,460)
Line1 = TextClip('TEXT LINE ONE',color='white', font="Amiri-Bold",kerning = 5, fontsize=100).set_duration(10)
Line2 = TextClip('TEXT LINE TWO',color='white', font="Amiri-Bold",kerning = 5, fontsize=100).set_duration(10)

rotMatrix = lambda a: np.array( [[np.cos(a),np.sin(a)],[-np.sin(a),np.cos(a)]] )
def vortex(screenpos,i,nletters):
    lambda t: screenpos+400*d(t)*rotMatrix(0.5*d(t)*a).dot(v)
site-packages\moviepy\video\compositing\concatenate.py", line 71, in <listcomp>
    tt = np.cumsum([0] + [c.duration for c in clips])
AttributeError: 'list' object has no attribute 'duration'
 
2 messages moved from Python
 
 
1 hour later…
12:29 PM
17 messages moved from Python
 
 
8 hours later…
8:54 PM
from setuptools import setup, find_packages
import distutils.cmd
import distutils.log
PNAME = 'src.'
PLIST = []


class PackageNameCommand(distutils.cmd.Command):
"""A custom command to run Pylint on all Python source files."""

description = 'Find Package with user specific name'
user_options = [
# The format is (long option, short option, description).
('package-name=', None, 'Package Name'),
]

def initialize_options(self):
"""Set default values for options."""
# Each user option must be listed here with their default value.
 
1 message moved from Python
 

« first day (2349 days earlier)      last day (992 days later) »