a question about heap data structure

Reply

Join Date: Sep 2005
Posts: 12
Reputation: md_salman is an unknown quantity at this point 
Solved Threads: 0
md_salman md_salman is offline Offline
Newbie Poster

a question about heap data structure

 
0
  #1
Sep 30th, 2005
although this question is basically related to a data structure, still I think that a good progrmmer should be able to answer it. My question is that "is it possible to determine the order in which some ( numbers or characters etc ) are arrived for insertion into a min or max heap ( if we are given that heap )." I think that its answer is yes as there can be so many combinations that we can describe in this regard, but my tutor says that it is not possible, I will be very thank ful for any serious reply.
Reply With Quote Quick reply to this message  
Join Date: Jun 2005
Posts: 2,039
Reputation: Rashakil Fol is just really nice Rashakil Fol is just really nice Rashakil Fol is just really nice Rashakil Fol is just really nice 
Solved Threads: 139
Team Colleague
Rashakil Fol's Avatar
Rashakil Fol Rashakil Fol is offline Offline
Super Senior Demiposter

Re: a question about heap data structure

 
0
  #2
Sep 30th, 2005
Originally Posted by md_salman
although this question is basically related to a data structure, still I think that a good progrmmer should be able to answer it. My question is that "is it possible to determine the order in which some ( numbers or characters etc ) are arrived for insertion into a min or max heap ( if we are given that heap )." I think that its answer is yes as there can be so many combinations that we can describe in this regard, but my tutor says that it is not possible, I will be very thank ful for any serious reply.
If only insertion has happened, you are correct in that there are a non-zero number of combinations in this regard.

For example, suppose your min-heap has three elements, looking like
  1. X
  2. / \
  3. Y Z
where X < Y < Z. Suppose your insertion algorithm fills the bottom row from left-to-right. It's either that or right-to-left. First I'll assume that you made only three insertions with no deletions.

There are six possible orders of input: X Y Z, X Z Y, Y X Z, Y Z X, Z Y X, Z X Y. Whenever Z comes before Y, the following heap results.

  1. X
  2. / \
  3. Z Y

Therefore, if you have the heap
  1. X
  2. / \
  3. Y Z
and X < Y < Z, then you know that Y was inserted before Z was. Generally speaking, I think you can only derive the order of insertion when comparing two leaf nodes (and probably only with two adjacent leaf nodes), but I do not know for sure.

If the heap has undergone insertion along with removal of the minimum element, then you cannot know anything about the ordering in which two particular elements were inserted.
All my posts may be redistributed under the GNU Free Documentation License.
Reply With Quote Quick reply to this message  
Join Date: Sep 2005
Posts: 6
Reputation: ITgeneration is an unknown quantity at this point 
Solved Threads: 0
ITgeneration ITgeneration is offline Offline
Newbie Poster

Re: a question about heap data structure

 
0
  #3
Oct 3rd, 2005
AOA
here is a link if data structure notes. it will help you to solve your problem \\ Read AVL Tree // data structure.
http://vulms.vu.edu.pk/Links/CS301.htm
ALLAH HAFIZ
Reply With Quote Quick reply to this message  
Reply

This thread is more than three months old.
Perhaps start a new thread instead?
Message:


Thread Tools Search this Thread



About Us | Contact Us | Advertise | DaniWeb | Acceptable Use Policy | RSS Feed

©2003 - 2009 DaniWeb® LLC