Jokes Etc › Re: Show us how good and creative you are with your use of words... Fun all the way by Jummate(m): 8:54am On Oct 02, 2020 |
Words aren't just enough to describe those feelings you are talking about. I know that. |
Jokes Etc › Re: Show us how good and creative you are with your use of words... Fun all the way by Jummate(m): 7:24pm On Oct 01, 2020 |
People like Nigerians are always happy |
Programming › Re: Beginners/ Intermediate Web Developer Platform To Perfect Your Skills. by Jummate(m): 6:59pm On Aug 06, 2020 |
Please add me 07067896279 |
Programming › Re: Competitive Programming by Jummate(m): 8:56am On Aug 06, 2020*. Modified: 9:26am On Aug 06, 2020 |
Karleb: Binary Search Trees are always balanced!
Binary trees don't always have to be balanced and I guess in such case the tree transversal is the correct way of getting the deepest value.
The tree in the question is a binary tree not a binary search tree. I beg to differ on your first statement. A Binary Search Tree may not always be balanced. A Binary Search Tree can actually be balanced or unbalanced depending on its implementation. A BST can become unbalanced if rotation is not carried out after insertion or removal which increases it complexity to O(n) but balanced BST such as AVL Trees, Red and Black Trees etc always maintain a complexity of O(logn) which BSTs are originally known for. Consider for an example, if I created a BSTwith 1 as the root and subsequently added 2, 3, 4, 5 which will make my BST to look this way: 1 \ 2 \ 3 \ 4 \ 5
This is an unbalanced BST. It will even become more unbalanced if I continue to add in this order up to say 1000. This is just as good as using a list as they will both run with the complexity (O(n)). The only way the complexity can be restored to O(log(n)) is by rotating and rearranging the elements of the BST to form an AVL Tree, Red and Black Trees etc which are balanced BST trees. Then, the BST can look like this for example: 3 / \ 1 4 \ \ 2 5
With this now, searching can now be made in 0(log(n)) I may not know what Google knows. You can just conduct a search on this. On your second paragraph, that the tree is a Binary Tree is even the more reason your algorithm will not work in all cases because you tailored your algorithm to a BST. Remember, you mentioned finding the minimum value in the tree the other time. You know, a Binary Tree may not always have its minimum value on the left as they do not follow the strict principle of arrangement as BSTs. Please do not see this as any form of attack. You can correct me if I'm wrong. I'm always open to learning. |
Programming › Re: Competitive Programming by Jummate(m): 10:16pm On Aug 05, 2020 |
Karleb: Transversal means visiting all nodes. That is, breath first search or depth first search.
Finding the minimum value on a binary search tree should not require that, since we know that the smallest value will always be on the far left of the tree and of course the highest will be on the far right.
So we run a while loop to check if the left node of a particular node is null starting from the root node, the loop will return the node that has no left node.
In this BST the loop will go from 50 to 17 to 12 to 9 and will return 9 since 9 has no left node. Yes, very good. But this will work only if the BST is balanced(in the case of this BST). How about the case of the BST example I posted the other time?. I think it's better that an algorithm works in all cases. Only my thoughts though.. |
Programming › Re: Competitive Programming by Jummate(m): 10:09pm On Aug 05, 2020 |
Karleb: That's right.
But in the question, the value at the deepest level is the minimum. So finding the minimum value of that particular BST would solve the problem. Look at the question again. The tree was only used as an example so as to aid easy understanding of the problem. The question actually expects that any algorithm used should work in all cases(different arrangement of the tree). |
Programming › Re: Competitive Programming by Jummate(m): 6:26pm On Aug 05, 2020 |
vheckthor1: this is a Depth first search algorithm Yeah, I think this should do it. |
Programming › Re: Competitive Programming by Jummate(m): 6:22pm On Aug 05, 2020 |
Karleb: No. It's finding the smallest value of the tree.
The tree transversal will be quite unnecessary. No, the smallest value of a tree may not always be at the deepest level. Take this Binary Search Tree for an example: 10 / \ 5 17 / \ 3 8 / \ 7 9
|
Programming › Re: Competitive Programming by Jummate(m): 10:51pm On Aug 04, 2020 |
Karleb: How about this one?
def spiralPrinting(anArr):
rootList = []
def inner(arr):
rootList.extend(arr[0])
arr.pop(0)
for each in arr:
rootList.append(each.pop())
arr[-1].reverse()
rootList.extend(arr.pop())
if len(arr) > 0:
for x in range(len(arr) -1, -1, -1):
rootList.append(arr[x].pop(0))
if len(arr) > 1:
inner(arr)
else:
if len(arr) > 0:
rootList.extend(arr.pop())
inner(anArr)
return rootList
if __name__ == '__main__':
multi = [[1,2,3,4,5],
[6,7,8,9,10],
[11,12,13,14,15],
[16,17,18,19,20]]
print(spiralPrinting(multi))
This will work for any size of this problem |
Tech Jobs › Re: Join Programners Hub by Jummate(m): 6:43am On Jun 19, 2020 |
Kindly add me up 07067896279 |
Programming › Re: Python 3: Exercises And Solutions. by Jummate(m): 3:47pm On Jun 09, 2020 |
IamGoke: If you are writing code, you need to format your text in code format.
[Code]
#Your code here
[/Code]
Change the C to c
Example below:
print('hello word') def appreciation(): print("Thanks bro" )
|
Programming › Re: Python 3: Exercises And Solutions. by Jummate(m): 12:12am On Jun 09, 2020 |
Jummate: def product(m, n):
if n == 0:
return 0
else:
return m + product(m, n-1) I indented lines 2 and 4 to be under the function declaration. I indented lines 3 to be under the if statement and line 5 to be under the else statement but I don't know why these are not reflecting as such........ |
Programming › Re: Python 3: Exercises And Solutions. by Jummate(m): 11:57pm On Jun 08, 2020 |
gbolly1151: Give a recursive algorithm to compute the product of two positive integers, m and n, using only addition and subtraction. def product(m, n): if n == 0: return 0 else: return m + product(m, n-1) |
Programming › Re: For Django Developer by Jummate(m): 6:38pm On Apr 30, 2020 |
Taofeekdboy: I created this thread for Django aspirants, intermediate and experienced Django developers to share knowledge and projects that you have or been working on.
I have worked and been working on a lot of projects such as sport app, loan calculator, and employee management. The one I just finished is just a social media clone project and it took a bit of my time.
The website is down below: http://mysocialapp.pythonanywhere.com If you are interested, you can Check and leave your comments as well.
So let's share ideas and knowledge..... Great job bro! |
Programming › Re: Let's Learn Python Together by Jummate(m): 6:25pm On Apr 30, 2020 |
admin, please add me up
0706 789 6279 |
Jobs/Vacancies › Re: gggghh by Jummate(m): 3:12pm On Jan 09, 2020 |
07067896279 |
European Football (EPL, UEFA, La Liga) › Re: Everton Vs Chelsea (3 - 1) On 7th December 2019 by Jummate(m): 1:52pm On Dec 07, 2019 |
Tajbol4splend: Even when you have a browsing phone I think the guy was only being sarcastic  |
Technology Market › Re: Laptop Screen Replacement In Nigeria by Jummate(m): 2:05pm On Oct 31, 2019 |
ruphytelecom: If you cannot do great things, do small things in a great way. Napoleon Hill Please, for how much can you fix a Dell e5420 14inches laptop screen? |
Programming › Re: First Thing First, Learn To Program! by Jummate(m): 6:26pm On Jul 25, 2019 |
progeek37: Okay. I created two groups. One for coding programming problems, where programmers meet and code together. And another group for tutorial. The tutorial group is not free. You have to pay as little as 6000 for three months. It is going to be done through WhatsApp and Zoom app, download Zoom app from playstore. We will be using it for screen sharing during the tutorial. Please add me to the Q & A group 07067896279 |
|
Romance › Re: Why Are You Presently Not Dating? by Jummate(m): 11:32am On May 06, 2019 |
|
European Football (EPL, UEFA, La Liga) › Re: Wolverhampton Wanderers Vs Manchester United (2 - 1) On 2nd April 2019 by Jummate(m): 11:15pm On Apr 02, 2019 |
Tonymegabush1: Bro chill..... Turf moor (molineux stadium) is not a place u visit and go home with 3points last last u fit dey draw expeciary if u are a big, check all d big teams dis season non won there, city went home with a draw, Liverpool draw, arsenal lost, Chelsea too lost dnt really know abt spur but I know dem didn't win either...... Honestly There was never a time I expected man u to win wolves.. Liverpool won there 2 - 0 |
Programming › Re: Web Design, Web Development And Mobile App Development Tutorial by Jummate(m): 7:54pm On Mar 23, 2019 |
Nice job bro. Please add me to the Whatsapp group. 0706 789 6279 |
Programming › Re: Let Learn Java Together by Jummate(m): 8:23am On Nov 05, 2018 |
Kindly add up 07067896279 |
Jokes Etc › Re: Show us how good and creative you are with your use of words... Fun all the way by Jummate(m): 1:15pm On Nov 04, 2018 |
Need I say, the poster directly above me is so on point |
Jokes Etc › Re: Show us how good and creative you are with your use of words... Fun all the way by Jummate(m): 8:38am On Nov 03, 2018 |
Like? You meant to type "lie", right? |
Jokes Etc › Re: Show us how good and creative you are with your use of words... Fun all the way by Jummate(m): 3:49pm On Oct 31, 2018 |
Sure as I could be, I can't speak for others |
Jokes Etc › Re: Show us how good and creative you are with your use of words... Fun all the way by Jummate(m): 8:43am On Oct 31, 2018 |
Love is beautiful, I guess that's why |
Forum Games › Re: ╚►start The Sentence With The Last Word (pidgin Version) Part 3 ◄╝ by Jummate(m): 11:30am On Oct 27, 2018 |
Rock na one of them Baba before for Wrestling |
Jokes Etc › Re: Show us how good and creative you are with your use of words... Fun all the way by Jummate(m): 10:55am On Oct 27, 2018 |
time is precious and it waits for nobody. |
Jokes Etc › Re: Show us how good and creative you are with your use of words... Fun all the way by Jummate(m): 7:00am On Oct 27, 2018 |
More haste, less speed |
Education › Re: My Kids Must Study Only These Courses In The University by Jummate(m): 9:39am On Aug 22, 2018 |
Hmmm....just go and watch the movie "3 idiots". Though it's just a movie but maybe you would at least have a change of opinion after seeing it. |