data structure heap of one single node concept!

  • (2 Pages)
  • +
  • 1
  • 2

18 Replies - 834 Views - Last Post: 30 December 2018 - 09:43 AM

#1 RyanMco   User is offline

  • D.I.C Head

Reputation: -9
  • View blog
  • Posts: 93
  • Joined: 27-December 18

data structure heap of one single node concept!

Posted 29 December 2018 - 12:11 PM

Hi, I'm just wondering and not finding the reason why at single node or any leaf node of binary tree its by default satisfy the min/max heap property .. why?! the tree is a min/max if the children is satisfy min/max property .. but there's no information if there's no children then how we decide that's by default its min/max heap?!

Hi please don't close this thread because I have already posted a thread on the same subject and who closed it claiming that I need to code and show some effort .. to code what?! I don't know what he's meaning !! I need to understand the concept of single node of heap, I don't know what code to show.. I'm asking on the concept why single node is immediately already a heap!

thanks

Is This A Good Question/Topic? 0
  • +

Replies To: data structure heap of one single node concept!

#2 modi123_1   User is online

  • Suitor #2
  • member icon



Reputation: 14690
  • View blog
  • Posts: 58,702
  • Joined: 12-June 08

Re: data structure heap of one single node concept!

Posted 29 December 2018 - 12:19 PM

Dude.. there's a computer science subforum. Please post your comp sci theory questions there.

Quote

General Discussion
> Software Development
> Computer Science


https://www.dreaminc...mputer-science/

Are you asking why a single node, the root only, satisfies the min/max tree requirements?

One would figure a single root node is both the smallest, and largest, element in the tree.. as it is the only element in the tree!

https://en.wikipedia...ki/Min-max_heap
Was This Post Helpful? 2
  • +
  • -

#3 macosxnerd101   User is online

  • Games, Graphs, and Auctions
  • member icon




Reputation: 12493
  • View blog
  • Posts: 45,627
  • Joined: 27-December 08

Re: data structure heap of one single node concept!

Posted 29 December 2018 - 01:07 PM

Just to add, sepp2k already answered this question in your first thread. I closed your first thread, as you started making nonsense posts about biconditional statements. It was tangential at best to your topic, and your post wasn't very coherent.

View Postsepp2k, on 29 December 2018 - 09:39 AM, said:

Here are some different-but-equivalent formulations of the heap property for a node n in a max heap:

  • For all children c of n, it must be true that n.value >= c.value.
  • There must be no child c of n, such that n.value < c.value.
  • In the set containing the node n and all of its children, n's value must be the maximum in the set.


I think it's easiest to see why version 3 is true for nodes without children: If you have a set containing only one value, then that value is obviously the maximum in that set. It should also be intuitive that this is equivalent to the other two versions: Saying x is the maximum of a given set is the same as saying that there's no y in the set such that x < y or that for all ys in the set x >= y.

Another way to approach this would be to realize that the statement "there is no element x in the set X, such that ... whatever" is always true if X is the empty set - regardless of which condition you substitute for "whatever". It's already true without any condition ("there is no element x in the set X" is true for the empty set X) and adding an additional condition on the elements of X that we consider isn't going to affect anything.

By the same logic, any universally quantified (i.e. "for all") statement about the empty set must also be true since "for all elements x in X, foo(x) must be true" and "there must be no element x in X, such that foo(x) is false" are equivalent statements and the latter is obviously true for empty sets.

This concept is also known as vacuous truth.

Was This Post Helpful? 0
  • +
  • -

#4 RyanMco   User is offline

  • D.I.C Head

Reputation: -9
  • View blog
  • Posts: 93
  • Joined: 27-December 18

Re: data structure heap of one single node concept!

Posted 29 December 2018 - 01:16 PM

I know but sir you have closed it and didn't let me to reply to his explanation !
now I can reply to his reply..

Can you please explain the another approach you declared? it's still a lil not comprehended, you mean whenever there's empty set then any condition will satisfy it? if yes then why?! thanks !

This post has been edited by Skydiver: 29 December 2018 - 05:33 PM
Reason for edit:: Removed unnecessary quote. No need to quote the post above yours.

Was This Post Helpful? 0
  • +
  • -

#5 macosxnerd101   User is online

  • Games, Graphs, and Auctions
  • member icon




Reputation: 12493
  • View blog
  • Posts: 45,627
  • Joined: 27-December 08

Re: data structure heap of one single node concept!

Posted 29 December 2018 - 01:18 PM

Since the empty set has no elements, every element in the empty set satisfies the given condition.
Was This Post Helpful? 0
  • +
  • -

#6 RyanMco   User is offline

  • D.I.C Head

Reputation: -9
  • View blog
  • Posts: 93
  • Joined: 27-December 18

Re: data structure heap of one single node concept!

Posted 29 December 2018 - 02:12 PM

But max and min isn't confirming at least two elements to compare? Meaning to use max/min we need at least two elements for comparing; but if we have one element then how do we use max/min ? Still really confused ..it doesn't make sound for me once there is one element in a list; and we need the maximal value found; tgen we just say its the maximal value.. How we de ide that?! There's just one element..

This post has been edited by Skydiver: 29 December 2018 - 05:34 PM
Reason for edit:: Removed unnecessary quote. No need to quote the post above yours.

Was This Post Helpful? 0
  • +
  • -

#7 macosxnerd101   User is online

  • Games, Graphs, and Auctions
  • member icon




Reputation: 12493
  • View blog
  • Posts: 45,627
  • Joined: 27-December 08

Re: data structure heap of one single node concept!

Posted 29 December 2018 - 02:21 PM

Consider the set S = { 3 }. What is the largest element in S? What is the smallest element in S?

The answer to both of these questions is 3. We don't need an additional element to compare. The definitions of minima and maxima don't require the values of x and y to be distinct.
Was This Post Helpful? 2
  • +
  • -

#8 RyanMco   User is offline

  • D.I.C Head

Reputation: -9
  • View blog
  • Posts: 93
  • Joined: 27-December 18

Re: data structure heap of one single node concept!

Posted 29 December 2018 - 02:38 PM

Well, as I need to learn .. I need to understand it very well, what do you mean "require the values of x and y to be distinct?" isn't minima and maxima require at least two elements to compare and use them?!

what's actually confusing me that if there's two elements like {3,4} the biggest element is 4 so its the maximal because its greater from 3 !.. here all fine !!
now about this {3} its biggest element so its the maximal because its greater from________ ? you got my point?!

This post has been edited by Skydiver: 29 December 2018 - 05:34 PM
Reason for edit:: Removed unnecessary quote. No need to quote the post above yours.

Was This Post Helpful? 0
  • +
  • -

#9 macosxnerd101   User is online

  • Games, Graphs, and Auctions
  • member icon




Reputation: 12493
  • View blog
  • Posts: 45,627
  • Joined: 27-December 08

Re: data structure heap of one single node concept!

Posted 29 December 2018 - 02:39 PM

Definition: Let S be an ordered set. The element x \in S is said to be a maximal element in S if for every y in S, x >= y.

Note that there is nothing in the definition saying that y != x.

Quote

isn't minima and maxima require at least two elements to compare and use them?!


No. See my previous post.

Also, there is no need to quote the post above you. There is a Reply button at the bottom of every page.
Was This Post Helpful? 0
  • +
  • -

#10 RyanMco   User is offline

  • D.I.C Head

Reputation: -9
  • View blog
  • Posts: 93
  • Joined: 27-December 18

Re: data structure heap of one single node concept!

Posted 29 December 2018 - 02:47 PM

that's why I'm just know that the definition of max is like this max(x,y) if x>y =>x else y ; my pre-cognition is totally wrong because it doesn't consider the case of there's "one element" !

min or max value is the smaller/greatest value in the list ! specifically if there's one single value then immediate it's the minimal/max value found in the list !

thanks !

This post has been edited by macosxnerd101: 29 December 2018 - 02:48 PM
Reason for edit:: There is no need to quote the post above yours

Was This Post Helpful? 0
  • +
  • -

#11 macosxnerd101   User is online

  • Games, Graphs, and Auctions
  • member icon




Reputation: 12493
  • View blog
  • Posts: 45,627
  • Joined: 27-December 08

Re: data structure heap of one single node concept!

Posted 29 December 2018 - 02:51 PM

Again, please do not quote the post above yours.

Quote

that's why I'm just know that the definition of max is like this max(x,y) if x>y =>x else y


You are rambling again. This doesn't make any sense.
Was This Post Helpful? 0
  • +
  • -

#12 RyanMco   User is offline

  • D.I.C Head

Reputation: -9
  • View blog
  • Posts: 93
  • Joined: 27-December 18

Re: data structure heap of one single node concept!

Posted 29 December 2018 - 02:51 PM

May I be a lil rude and ask you how should I look at maximum and minimum values?
meaning to find max, I ask myself what's the greatest value among the others? but if there's no others then we just pass the value itself?
thanks
Was This Post Helpful? 0
  • +
  • -

#13 macosxnerd101   User is online

  • Games, Graphs, and Auctions
  • member icon




Reputation: 12493
  • View blog
  • Posts: 45,627
  • Joined: 27-December 08

Re: data structure heap of one single node concept!

Posted 29 December 2018 - 02:53 PM

I provided a definition in a previous post. Start there.
Was This Post Helpful? 0
  • +
  • -

#14 modi123_1   User is online

  • Suitor #2
  • member icon



Reputation: 14690
  • View blog
  • Posts: 58,702
  • Joined: 12-June 08

Re: data structure heap of one single node concept!

Posted 29 December 2018 - 03:29 PM

Quote

I ask myself what's the greatest value among the others?

If there is no other values then that single number is the greatest.

If you need the crutch then look.. if you have one number by itself you would compare it to an empty set of number. A value compared to that empty set is the max and is the minimum.

This isn't some philosophy class where 'things can only be known when compared and cannot exist in a vacuum'.
Was This Post Helpful? 1
  • +
  • -

#15 macosxnerd101   User is online

  • Games, Graphs, and Auctions
  • member icon




Reputation: 12493
  • View blog
  • Posts: 45,627
  • Joined: 27-December 08

Re: data structure heap of one single node concept!

Posted 29 December 2018 - 03:31 PM

Quote

This isn't some philosophy class where 'things can only be known when compared and cannot exist in a vacuum'.


This is why definitions are helpful. Start with the definition. Take an ordered set S with a single element. Show that the single element in S satisfies the definition of a maximal element.
Was This Post Helpful? 3
  • +
  • -

  • (2 Pages)
  • +
  • 1
  • 2