tag:blogger.com,1999:blog-4228859841453048938.post4158360726833595233..comments2024-03-29T15:50:59.980+08:00Comments on Coding Interview Questions: No. 45 - Closest Node in a Binary Search TreeHarry Hehttp://www.blogger.com/profile/10363303096963693183noreply@blogger.comBlogger17125tag:blogger.com,1999:blog-4228859841453048938.post-27714314077551630922020-02-07T23:08:07.493+08:002020-02-07T23:08:07.493+08:00Thank you sharing wondefull Information
I also fo...<br />Thank you sharing wondefull Information <br />I also found Various useful links related to Devops, Docker & Kubernetes <br /><br /><br /><a href="http://linux.amitmaheshwari.in/2020/02/kubernetes-kubectl-commands-cheatsheet.html" rel="nofollow"> Kubernetes Kubectl Commands CheatSheet </a><br /><br /><a href="http://linux.amitmaheshwari.in/2020/02/introduction-to-kubernetes-networking.html" rel="nofollow"> Introduction to Kubernetes Networking </a><br /><br /><a href="http://linux.amitmaheshwari.in/2020/02/basic-concept-of-kubernetes.html" rel="nofollow"> Basic Concept of Kubernetes </a><br /><br /><a href="http://linux.amitmaheshwari.in/2019/11/kubernetes-interview-questions-and.html" rel="nofollow"> Kubernetes Interview Question and Answers </a><br /><br /><a href="http://linux.amitmaheshwari.in/2020/02/kubernetes-kubectl-commands-cheatsheet.html" rel="nofollow"> Kubernetes Sheetsheat </a><br /><br /><a href="http://linux.amitmaheshwari.in/2019/11/docker-interview-questions-and-answers.html" rel="nofollow"> Docker Interview Question and Answers </a><br /><br /><a href="http://linux.amitmaheshwari.in/2019/12/docker-basic-tutorial.html" rel="nofollow"> Docker Basic Tutorial </a><br />Editorhttps://www.blogger.com/profile/08032442576837072724noreply@blogger.comtag:blogger.com,1999:blog-4228859841453048938.post-82032824315763663992019-08-22T05:44:52.442+08:002019-08-22T05:44:52.442+08:00int mostClosetNode(Node root, int value)
{
int mi...int mostClosetNode(Node root, int value)<br />{<br /> int min = Integer.MAX_VALUE;<br /> int mostClosestNode = mostClosetNodeUtil(root,value,min);<br /> return mostClosestNode;<br />}<br /><br />int mostClosetNodeUtil(Node root, int value,int min)<br />{<br /> if(root==null)<br /> {<br /> return Integer.MAX_VALUE;<br /> }<br /> <br /> int currDiff = Math.abs(root.data - value);<br /> if(currDiff<min)<br /> {<br /> min = currDiff;<br /> return root.data;<br /> }<br /> <br /> int minLeft = mostClosetNodeUtil(root.left,value,min);<br /> int minRight = mostClosetNodeUtil(root.right,value,min);<br /> return Math.min(minLeft,minRight);<br /> <br />}Antonhttps://www.blogger.com/profile/01482021956446047879noreply@blogger.comtag:blogger.com,1999:blog-4228859841453048938.post-82687748578294246622018-06-08T17:20:37.409+08:002018-06-08T17:20:37.409+08:00Hola,
Interesting piece!Great to see someone wri...Hola,<br /><br /><br />Interesting piece!Great to see someone write No. 45 - Closest Node in a Binary Search Tree who is not a fanatic or a complete skeptic.<br /><br /><br />I'm new to AWS and I am using it to work on my senior thesis project in college. The project requires using Microsoft SQL however I am using a mac, so I figured the easiest way to make this work would be to use AWS. I am trying to use only options that are eligible for the free tier since my budget is not a lot. <a href="https://www.youtube.com/watch?v=M-vNN1ntJDo&index=1&list=PLVNl9sThbR3FTwlKNHDDTZlxrfwqx8c0l" rel="nofollow"> AWS Tutorial </a><br /><br /><br /><br /><br /><br />Please keep providing such valuable information.<br /><br /><br />,Merci<br />AjeethAnonymoushttps://www.blogger.com/profile/11674257547961232200noreply@blogger.comtag:blogger.com,1999:blog-4228859841453048938.post-32457572461198952162018-06-05T17:20:47.070+08:002018-06-05T17:20:47.070+08:00Salemetsiz Be,
11/10!! Your blog is such a compl...Salemetsiz Be,<br /><br /><br />11/10!! Your blog is such a complete read. I like your approach with #topic. Clearly, you wrote it to make learning a cake walk for me.<br /><br /><br />I like the support for S3 in the AWS console, especially being able to apply ACLs at time of upload. However, it would be very good if the view was sortable by last modified date, as I am typically working with the last 10-15 files uploaded.<br /><br /><br /><br /><br />It was cool to see your <a href="https://medium.com/freetraining/aws-596f86582865" rel="nofollow"> AWS Tutorial USA </a>article pop up in my google search for the process yesterday. Great Guide.<br />Keep up the good work!<br /><br /><br />Cheers,<br /><br />ganeshAnonymoushttps://www.blogger.com/profile/04859983121687046225noreply@blogger.comtag:blogger.com,1999:blog-4228859841453048938.post-55343132231090684602018-06-01T18:37:03.778+08:002018-06-01T18:37:03.778+08:00Hi Man,
Best thing I have read in a while on thi...Hi Man,<br /><br /><br />Best thing I have read in a while on this No. 45 - Closest Node in a Binary Search Tree . There should be a standing ovation button. This is a great piece.<br /><br /><br />I am new to Amazon S3, and so far it seems to be working fine, but I do have one quick question:<br /><br />To upload my files, I just go to Amazon's Console - within my Firefox Browser; but I am wondering: <br />After the Upload is started, is it OK to Exit Firefox right then . . . OR does the upload work better if I keep Firefox running? <a href="https://asha24.com/blog/aws-tutorials-training-certification-and-interview-qa/" rel="nofollow"> AWS Tutorial </a><br /><br /><br /><br /><br /><br />Anyways great write up, your efforts are much appreciated.<br /><br /><br />Grazie,<br />AjeethAnonymoushttps://www.blogger.com/profile/11674257547961232200noreply@blogger.comtag:blogger.com,1999:blog-4228859841453048938.post-15137539556277475402017-01-19T10:49:15.680+08:002017-01-19T10:49:15.680+08:00guessing the main problem is here:
var closestNod...guessing the main problem is here:<br /><br />var closestNode = (searchItem.CompareTo(tmp.data) < 0 ? Anonymoushttps://www.blogger.com/profile/00099243123913061138noreply@blogger.comtag:blogger.com,1999:blog-4228859841453048938.post-35197392023223452752017-01-19T10:42:14.562+08:002017-01-19T10:42:14.562+08:00//i'm looking for a node equal or larger then ...//i'm looking for a node equal or larger then an input so i tryed to modifiy the code with no luck<br /><br />private T Search4(Node tmp, T searchItem)<br /> {<br /> if (tmp == null) return default(T);<br /> if (searchItem.CompareTo(tmp.data) == 0)<br /> {<br /> return tmp.data;<br /> }<br /> var closestNode = (searchItem.CompareTo(tmp.data) < 0 ? Search4(tmp.left, searchItem) : Search4(tmp.right, searchItem));<br /> if (closestNode != null)<br /> {<br /> if ((searchItem.CompareTo(tmp.data) > (searchItem.CompareTo(closestNode))))<br /> {<br /> return closestNode;<br /> }<br /> return tmp.data;<br /> }<br /> return tmp.data;<br /><br /><br />//any advice?Anonymoushttps://www.blogger.com/profile/00099243123913061138noreply@blogger.comtag:blogger.com,1999:blog-4228859841453048938.post-74866677594408684102016-12-16T04:53:52.326+08:002016-12-16T04:53:52.326+08:00//recursive solution: way more elegant.
private ...//recursive solution: way more elegant. <br /><br />private static Node ClosestNode(Node node, int value)<br /> {<br /> if (node == null)<br /> return null;<br /><br /> if (value != node.Key)<br /> {<br /> var closestNode = value < node.Key ? ClosestNode(node.Left, value) : ClosestNode(node.Right, value);<br /> if (closestNode != null)<br /> {<br /> if (Math.Abs(closestNode.Key - value) < Math.Abs(node.Key - value))<br /> return closestNode;<br /> return node;<br /> }<br /> return node;<br /> }<br /> return node;<br /> <br /> }Anonymoushttps://www.blogger.com/profile/14602003034806115639noreply@blogger.comtag:blogger.com,1999:blog-4228859841453048938.post-74859656982001329862016-04-02T08:41:11.305+08:002016-04-02T08:41:11.305+08:00A Haskell solution: https://gist.github.com/pjrt/a...A Haskell solution: https://gist.github.com/pjrt/a3eb270101c40dce4047d14ec9bb15c2Pedro R.https://www.blogger.com/profile/09155622475973504857noreply@blogger.comtag:blogger.com,1999:blog-4228859841453048938.post-62485126499618316342015-02-23T05:18:34.386+08:002015-02-23T05:18:34.386+08:00Can you explain how this would be different in C# ...Can you explain how this would be different in C# using generics?Ryan Kenwardhttps://www.blogger.com/profile/00030125250805247043noreply@blogger.comtag:blogger.com,1999:blog-4228859841453048938.post-37501885157300695282014-12-08T20:41:13.269+08:002014-12-08T20:41:13.269+08:00how much better can we do this using recursion.
C...how much better can we do this using recursion.<br /><br />Can someone tell me the recursion approach and compare the memory and efficiency between the two approaches.Anonymoushttps://www.blogger.com/profile/17935237079291648432noreply@blogger.comtag:blogger.com,1999:blog-4228859841453048938.post-13787428321286948312014-06-07T10:25:29.488+08:002014-06-07T10:25:29.488+08:00A Java solution:
Node findClosestNodeToTargetValu...A Java solution:<br /><br />Node findClosestNodeToTargetValue(Node root, int target) {<br /><br />if (root == null) return null;<br /><br />Node closestNode = root;<br />int closestDiff = Integer.MIN_VALUE;<br /><br />while(root != null) {<br />··if (root.data == target) return root;<br />··<br />··int diff = Math.abs( data - root.data);<br />··if (diff < closestDiff) {<br />···closestDiff = diff;<br />···closestNode = root;<br />··}<br />··root = (target > root.data) ? root.getRight() : root.getLeft();<br />}<br /><br />return root;<br />}A. Thomas Tranhttps://www.blogger.com/profile/00206927766192684054noreply@blogger.comtag:blogger.com,1999:blog-4228859841453048938.post-70596156845552082242014-04-03T09:46:36.932+08:002014-04-03T09:46:36.932+08:00struct node*nearest(struct node*root,int k)
{
if(...struct node*nearest(struct node*root,int k)<br />{<br /> if(root == NULL)<br /> return NULL;<br /> else if(root->data == k)<br /> return root;<br /> else if(root->data>k)<br /> {<br /> struct node*z = nearest(root->left,k);<br /> if(z!=NULL)<br /> {<br /> if(abs(z->data-k)>abs(root->data-k))<br /> return root;<br /> else<br /> return z;<br /> }<br /> else<br /> return root;<br /> }<br /> else<br /> {<br /> struct node*z = nearest(root->right,k);<br /> if(z!=NULL)<br /> {<br /> if(abs(z->data-k)>abs(root->data-k))<br /> return root;<br /> else<br /> return z;<br /> }<br /> else<br /> return root;<br /> }<br />}Vartulhttps://www.blogger.com/profile/08277101630040684036noreply@blogger.comtag:blogger.com,1999:blog-4228859841453048938.post-28872475339172293892013-10-01T00:01:46.127+08:002013-10-01T00:01:46.127+08:00Could we create two integers as "nodeSmall&qu...Could we create two integers as "nodeSmall" & "nodeLarge" to keep track of the two closest values. Using this, the code doesn't need to compare "distance < minDistance" for each node.Jerry Taihttps://www.blogger.com/profile/08491776806268596219noreply@blogger.comtag:blogger.com,1999:blog-4228859841453048938.post-83255741972751404372013-09-22T17:00:35.537+08:002013-09-22T17:00:35.537+08:00SuperSuperAmeyahttps://www.blogger.com/profile/12826889630106460134noreply@blogger.comtag:blogger.com,1999:blog-4228859841453048938.post-50003480291580815232013-07-11T02:07:27.292+08:002013-07-11T02:07:27.292+08:00This comment has been removed by the author.Anonymoushttps://www.blogger.com/profile/00176028693071167073noreply@blogger.comtag:blogger.com,1999:blog-4228859841453048938.post-26722726824630957372013-05-07T22:40:30.342+08:002013-05-07T22:40:30.342+08:00This comment has been removed by the author.popimasterhttps://www.blogger.com/profile/07795225554838225562noreply@blogger.com