Recursive function to find the parents of a tree node
Hi,
I need help to write a recursive function to get the parents of a tree node upto the root.The major problem is , each node can have more than one parent.I have two methods ; one to get the immediate parents(getParents() will return me a vector) and the other to get the parents upto the root(will also return me a vector).
Thanks in advance,
nanduvs
let me risk a dumb response ..
if there are multiple parents
why not just follow the first parent
back to the root
if everything starts at one root
Similar Messages
-
Write two functions to find the the number of elements in a linked list?
I am trying to Write two functions to find the the number of elements in a linked list. One method using recursion and One method using a loop...
//The linked List class is Represented here.
public class lp {
public int first;
public lp rest;
public lp(int first1, lp rest1)
first = first1;
rest = rest1;
The program i wrote so far is
import java.util.*;
import linklist.lp;
public class listCount{
//loop function
public static void show_list(lp list)
int counter = 0;
while(list != null)
list = list.rest;
counter++;
System.out.println ("length computed with a loop:" + counter);
//recursive function
public static int recursive_count(lp list)
if (list.first == null)
return 0;
else
return recursive_count(list.rest) + 1;
//main method
public static void main (String args[])
lp list1 = new lp(1, new lp(2, new lp(3, null)));
show_list(list1);
System.out.println("length computed with a recursion:" +
recursive_count(list1));
at the if (list.first == null) line i get the error " incomparable types:
int and <nulltype>" I know this is a beginners error but please
help...What should I do?byte, char, short, int, long, float, double, and boolean are primitives, not objects. They have no members, you cannot call methods on them, and they cannot be set to or compared with null.
-
Function to find the greatest of two numbers
Hi All
In the rtf template, is there any function to find the greatest between two numbers?
Please help
Thanks in AdvanceJust like SQL, use the GREATEST function. List of comparable SQL functions is shown on or about page 9-30 of user guide (depends on which version you have). Search on GREATEST and you'll find it.
-
Query to find the parent group name
what is/are the table name that i should use to find the parent name of the job?
thank you,
warrenHi Warren,
The parent group name (dbo.jobmst.jobmst_prntname) can be found within jobmst table.
For example, the below query will return parent name of a specified job:
SELECT dbo.jobmst.jobmst_prntname
FROM dbo.jobmst
WHERE dbo.jobmst.jobmst_name = 'Enter name of job here'
BR,
Derrick Au -
How to directly change the text of a tree node once its in the tree
How can I directly change the text of a tree node once its in the tree.
I have a property box which fires an eventevery time it is edited
(this is currently just output to the screen via println)
What i want is for the tree node to take the updated text that is in the text box every time
thus giving tree labels that update as you type
PS. i have access to the tree node (DefaultMutableTreeNode) from the code that hanldes
the text box event... use the setUserObject() method of your DefaultMutableTreeNode, that'll set the text of the node.
however, you probably need to do a treeModel.nodeChanged(node) with your tree model, to get the display updated.
thomas -
What is the difference between WHEN-TREE-NODE-ACTIVATED and
Hello
Pls tell me, what is the difference between:
WHEN-TREE-NODE-ACTIVATED Trigger and
WHEN-TREE-NODE-SELECTED Trigger
Best Regards,
Abdetu..in the WHEN-TREE-NODE-SELECTED trigger:
When selecting
IF :SYSTEM.TRIGGER_NODE_SELECTED = 'TRUE' THEN
:GLOBAL.VARIABLE := <a value>;
:PARAMETER.PARAM1 := <a value>;
GO_BLOCK('BLOCK_B');
EXECUTE_QUERY;
END IF;
When deselecting
IF :SYSTEM.TRIGGER_NODE_SELECTED = 'FALSE' THEN
ERASE('GLOBAL.VARIABLE');
:PARAMETER.PARAM1 := NULL;
GO_BLOCK('BLOCK_B');
CLEAR_BLOCK(NO_VALIDATE);
END IF;Of course this is a simple example.
Tony -
How to get the search function to find the correct files
i have long wondered if it was me or the system, but i am very clear finally that the search function *****.
1) i try to find a word in a document.
2) the system shows me several possibilities. chapters 16, 18, 21, etc...
3) i then bring up each one individually and search each one. some of them DON'T EVEN HAVE THE WORD OR PHRASE IN THEM THAT I AM SEARCHING FOR. what's THAT all about?
4) so i look at my real life book or search on the web. voila! there it is. chapter 14.
5) i try again. both finder search and spotlight. NEITHER SHOW ME THE CORRECT DOCUMENT. neither shows me chapter 14. they still show 16, 18, 21, etc.
this has always been VERY mysterious.
it has happened hundreds of times over the years.
i am VERY clear now it is NOT me and it IS the system.
what use is it to get a list of documents that do not have the correct criteria and NOT get the document that has the correct criteria?
is leopard as sucky?thanks for your response.
perhaps you don't use it as much as i do?
i have been cursing this search feature for years.
i often try to find exact words in a particular book
that i have on my computer as .doc files.
and it often does not find what i want and it often
finds what i do not want. so i am very confused.
i went to system preferences. opened spotlight.
there is nothing listed under 'don't search here'...
and i have only a few things listed under 'search here.
i do not understand how that link could help my
problem.
when i search for the word inside a document or
inside a pdf, the programs find the word. but
finder/spotlight does not find it.
i still need more help.
and thanks for your response. -
Function in finding the count of ocurrances of an XML tag in j developer
Hi All,
I need to find the count of an xml tag that appears mutliple times in an xml payload.
I did not find any function in bpel doing this.I am using j developer version 11.1.1.5.0 and SOA Composite editor version 11.1.1.5.0.01.74
Is there any function in Bpel that gives as the count of occurence of an element in a payload?
Kindy suggest me on this.The below function is used inside XSLT to count the nodeset
count(inputNodeSet as node-set)
Returns the number of nodes in inputNodeSet.
Thanks,
Vijay -
Function to find the Last Date of Month One Year Ago - RETURNS ERROR
I've written sql code which takes a date and finds the Last Day of the Month one year ago. For example, it takes the date '2015-04-17' and returns the date '2014-04-30'. The code works fine in a query. Now I'm trying to turn this into a function. However,
when I try to create the function I get the error:
Operand type clash: date is incompatible with int
Why is this error being returned?
Here is my function:
CREATE FUNCTION dbo.zEOM_LY_D(@Input Date)
RETURNS date
AS
BEGIN;
DECLARE @Result date;
SET @Result = convert(DATE, DATEADD(s,-1,DATEADD(mm, DATEDIFF(m,0,dateadd(m, -11, @Input)+1),0)),101)
RETURN @Result;
END;
Thanks for any help you can give.
Stan,
Thanks very much- that does the trick. I should have said I am using SQL 2008 so EOMONTH is not available to me. I still don't get why I got an error though, since I was treating a date like a date and not like an int.
Thanks, John
I think i found the issue but i do not know why it is causing the issue. i think may be the way dates are treated/stored internally..i think dates are stored as no of days after 0001/01/01 but cannot see how this cwould effect..may be somebody else can through
some light.....
if you make it as datetime it will work,
if you leave it as date - eliminate adding 1... you should prefer to use dateadd to add/substract dates.
try this to understand..
--removed the +1 in the code
declare @input date
set @input ='20150503'
select
convert(DATE, DATEADD(s,-1,DATEADD(mm,DATEDIFF(m,0,dateadd(m, -11, @Input)),0)),101)
go
--made the datatype as datetime
declare @input datetime
set @input ='20150503'
select
convert(DATE, DATEADD(s,-1,DATEADD(mm,DATEDIFF(m,0,dateadd(m, -11, @Input)+1),0)),101)
Hope it Helps!! -
How to find the parent package
Hi,
The problem I'm trying to solve is, given an instance of a SSIS package being executed, I need to find the GUID and execution id of the package that calls it. According to the API (https://msdn.microsoft.com/en-us/library/microsoft.sqlserver.dts.runtime.package.aspx)
the Package class
has a property "Parent", which returns the instance of the container that contains the child package. In reality though, this doesn't seem to work. Here's what I did,
1. Create a child package that simply has a script task which writes a line to a file for debugging purpose.
2. Create a custom SSIS component in which the child package is called by the myPackage.Execute() method;
3. Given the reference myPackage, try to print the parent container id through the FireInfo() method from IDTSComponents interface.
What I got was an "reference not set to an object" error, which means the parent property is null. This leads me to wonder, when is the parent property set? Is it only set during the execution of the child package? I tried to access it both before
and after executing the child package, and in both cases the value was null.
My ultimate goal is to write the parent package id (and execution id) into the ssis log so as to easily trace the execution of packages. Another option to achieving this goal would be through passing values via parent package variables but that seems to
be too clumsy.
Any help / suggestion is greatly appreciated.
Regards,
AmosI have done the same thing via different way. Let me tell you how
Step 1: Create a log table
CREATE TABLE [dbo].[ExecutionLog](
[LogID] [int] IDENTITY(1,1) NOT NULL,
[ParentLogID] [int] NULL,
[Description] [varchar](50) NULL,
[PackageName] [varchar](50) NOT NULL,
[PackageGuid] [uniqueidentifier] NOT NULL,
[MachineName] [varchar](50) NOT NULL,
[ExecutionGuid] [uniqueidentifier] NOT NULL,
[Operator] [varchar](50) NOT NULL,
[StartTime] [datetime] NOT NULL,
[EndTime] [datetime] NULL,
[Status] [tinyint] NOT NULL,
[FailureTask] [varchar](64) NULL,
CONSTRAINT [PK_ExecutionLog] PRIMARY KEY CLUSTERED
[LogID] ASC
)WITH (PAD_INDEX = OFF, STATISTICS_NORECOMPUTE = OFF, IGNORE_DUP_KEY = OFF, ALLOW_ROW_LOCKS = ON, ALLOW_PAGE_LOCKS = ON) ON [PRIMARY]
) ON [PRIMARY]
GO
SET ANSI_PADDING OFF
GO
ALTER TABLE [dbo].[ExecutionLog] WITH CHECK ADD CONSTRAINT [FK_ExecutionLog_ExecutionLog] FOREIGN KEY([ParentLogID])
REFERENCES [dbo].[ExecutionLog] ([LogID])
GO
ALTER TABLE [dbo].[ExecutionLog] CHECK CONSTRAINT [FK_ExecutionLog_ExecutionLog]
GO
Step 2: On every package Create three Execute SQL Task
Execute SQL Task 1 : On begin of package
Execute SQL Task 2 : After completion of all task
Step 3: Now create two SP
For EQT #1
--Root-level nodes should have a null parent
if @ParentLogID <= 0 set @ParentLogID = null
--Insert the log record
insert into dbo.ExecutionLog(
ParentLogID
,Description
,PackageName
,PackageGuid
,MachineName
,ExecutionGuid
,Operator
,StartTime
,EndTime
,Status
,FailureTask
) values (
@ParentLogID
,@Description
,@PackageName
,@PackageGuid
,@MachineName
,@ExecutionGuid
,@operator
,getdate()
,null
,0 --InProcess
,null
set @logID = scope_identity()
EQT #2 On End
update dbo.ExecutionLog set
EndTime = getdate() -
,Status = case
when Status = 0 then 1 --Complete
else Status
end --case
where
LogID = @logID
You can create similar SP for OnError if you want
Step 4: Now create two variables LogId & parentLogId Int default value 0
Step 5: Step up parent package variable configuration for logId like below
Step 6: Call these SP in respective execute SQL task
Hope this will help
Glad to help! Please remember to accept the answer if you found it helpful. It will be useful for future readers having same issue.
My Profile on Microsoft ASP.NET forum -
Function that finds the absolute path of a file
Hi,
I'm creating an application using the SDL framework.
The following code gives me the absolute path for the file "caisse.jpg", which is located in my application bundle. Then, I can use the value of "cstrURL" to load the image with IMG_Load(cstrURL);
#import <CoreFoundation/CoreFoundation.h>
int main(int argc, char *argv[])
CFURLRef url = CFBundleCopyResourceURL( CFBundleGetMainBundle(),
CFSTR("caisse"),
CFSTR("jpg"), //extension du fichier
NULL );
const char* cstrURL = CFStringGetCStringPtr(
CFURLCopyFileSystemPath(url,kCFURLPOSIXPathStyle),
CFStringGetSystemEncoding()
printf("URL: %s", cstrURL);
return EXIT_SUCCESS;
But I have many files to load for my application. I tried to create a function that would take as parameter informations about the image, and then automatically find the absolute path of this image.
( void imgPath(char name[], char ext[], char destination[] ---> name = "image", ext = "jpg", destination is a variable in which the function puts the absolute path of the file)
How can I do that? What bugs me is the use of the CFSTR macro in the code I have...
Thank you very much
FRANKYThe CFSTR macro can only use a constant string as parameter, not a variable one.
You can use instead CFStringCreateWithCString if the parameter is a C String (char *).
Additionaly, I think the input parameters of your imgPath function must be of char* type, not char. And the output parameter char** (but it would be easier to know with the function source code). -
How to find the Parent process in workflow
Hi all,
I have a .wft file with me.
It contains atleast 8 processess.
I need to understand the flow of this workflow.
How do i getto know the flow?
How do I getto know the parent process?
I am sure if i know the parent process then i can figure out the flow as well.
Hope someone can help me in thisproblem.
Thanks in anticipation.
regards.Hello,
You can open the .wft file using the Workflow builder and see visually how the processes are designed. You can also see which processes are used as sub processes. These will be your children flows.
Cheers,
Raja -
How to persist parent and child tree node data through JSF and Hibernate
Dear dudes,
I'm a novice to JSF and Hibernate
Actually i want to create a tree structure where for each child node, i should have the parent node reference in my form and then when i save, i need to save the corresponding child node data in the database.
node-1
node 1-1
node 1-11a
node 1-2
node-2
node 2-1
node2-2Whenever i click node 1-1 the corresponding parent node ( node-1) reference should appear in my form and when i save this data this data should be saved under parent node and the tree should be re-rendered.
How this can be accomplished and if there are any URL's please refer.Everybody need not face the same problem you faced. And moreover, everyone out here have their own issues to solve. If people are helping out here, its cause of their passion. Please try to be polite.
First of all, what is that you have tried on the issue? Could you please share your work so that we can try to fill the gaps? -
Listing the children of a tree node
Hi
I have a jsf page where left side is a tree and the right side is divided into two panes(Top & Bottom). Top pane in the edit view of the selected node which is working fine using a backing bean to set the current row(As in the example of Devloper Guide Book).In the bottm pane I need to list the table of children of the selected node. How can I do this ?
The tree is built on the basis of parent id in the same table.
Thanks
Edited by: Suneesh Raman on Sep 5, 2010 4:23 AMHi,
if you use ADF
1. Open the table (Property Inspector "pencil" icon in toolbar). Then expand the tree node "DataSource" area and open the EL edito by pressing the button).
2. Navigate to the iterator that represents the input form / table. Make sure that the table is built on an iterator not dependent on any other collection
see example 50 on http://www.oracle.com/technetwork/developer-tools/adf/learnmore/index-101235.html
Frank -
How to set the control-on hierarchical tree nodes
Hi,
I have created form in which at the left it has hierarchical tree structure(BOM) and towards the right it brings up the query results for selected node.
Now, I have a button upon clicking which I navigate to the root node by issuing
"Ftree.set_Tree_selection(htree, 1, Ftree.select_on);".
But, it cannot automatically run the ' when-tree-node-selected' trigger '.
any solution???
Its really urgent.I have a customer demo on monday.
Please help me asap.
regards,
Nagadeep.Hello Nagadeep,
couldn't you just put the code from the trigger into a procedure
and run that after the navigation to the item?
Just a thought,
Bernd
The docs state that:
No programmatic action will cause the When-Tree-Node-Selected trigger to fire. Only end-user action will generate an event.
Probably due to performance reasons.
Bernd
Message was edited by:
Bernd Prechtl
Maybe you are looking for
-
Installation of Oracle Database 10g 10.2.0.3 on Windows 2003 Server
Hi Guys, We have to install Oracle Database 10g 10.2.0.3 on Windows 2003. I read on net, metalink and OTN as well and it seems there is no single 10.2.0.3 setup available to do so. One has to upgrade from earlier version to 10.2.0.3. Is that so? Is t
-
I have adobe Photoshop element 6
I can't open my adobe photoshop element, the error message says: This application has requested the Runtime to terminate it in an unusual way. Please contact the application support team for more information. I need help for this question. Dan
-
How to use Ago function in BIEE with mysql database
Hi experts, Ago function works well in Oracle database,but when I tried a mysql database,it didn't show results as expected. Anyone knows how to use Ago with mysql as data source?
-
Hello I am unable to connect my Apple mini to the Apple TV. Apple is 6 months old and has mountain lion 10.8.4 apple TV is also the latest version 5.3 softeware version and model md199nfNF/A
-
Employee Code Flow from HR to FI Automatically
Dear Employee Personnel Numbers are being updated regularly from HR. In FI they are not being updated automatically. Once again in FI they are being created as Employee Vendors either through LSMW or directly if they are small in number. Now the p