I can traverse the binary search tree using recursion easily, but I don't have an idea about traverse without recursion so please anyone explain,.....
yes, you can do it with stack. you have to take stack here the algorithm for p reorder, in-order and post-order traversal in iterative way (non recursive way/method) of binary search tree. Hope you will get properly.
p re order:
1) Create an empty stack node_Stack and push root node to stack.
2) Do following while node_Stack is not empty.
-> Pop an item from stack and print it.
-> Push right child of popped item to stack
-> Push left child of popped item to stack
in-order:
1) Create an empty stack S.
2) Initialize current node as root
3) Push the current node to S and set current = current->left until current is NULL
4) If current is NULL and stack is not empty then
-> Pop the top item from stack.
-> Print the popped item, set current = popped_item->right
-> Go to step 3.
5) If current is NULL and stack is empty then we are done.
post-order:
1.1 Create an empty stack
2.1 Do following while root is not NULL
-> Push root's right child and then root to stack.
-> Set root as root's left child.
2.2 Pop an item from stack and set it as root.
-> If the popped item has a right child and the right child
is at top of stack, then remove the right child from stack,
push the root back and set root as root's right child.
-> Else print root's data and set root as NULL.
2.3 Repeat steps 2.1 and 2.2 while stack is not empty.
Related
I want to update dynamoDB items with nested maps in where I don't know if the items does already exist or not. If it already exist it's all good. But if the item does not exist yet I get an error. I don't have the option to create those "empty" items/maps upfront. So I tried to solve this issue by using two SETs inside UpdateExpression:
UpdateExpression: "SET #info = if_not_exists(#info, :fullData), #info.#version = :shortData",
Which get's me following error:
Two document paths overlap with each other; must remove or rewrite one of these paths; path one: [info], path two: [info, V202014]"
Did anyone found a solution without having to make a try except block with 2 calls (1 update => if error add new)? Or how to get around the two paths restriction?
i am trying to get the direct child of parents, this is the query i have used (Scenario: File system in which a folder contains other folder)
MATCH (n:Folder) WHERE ID(n)=${req.query.id}
OPTIONAL MATCH (b:Folder)<-[r:CONTAINS*0..]-(n:Folder)
return{parent:n.name,child : {name :collect(b)}}
but im getting all the children either direct or indirect childrens, whereas i need only the direct children
i need to get only b4,inner1, and inner2 as direct child, but im getting inner3 also using this query.
managed to get this working with this query
MATCH (n:Folder)-[:CONTAINS]->(childs:Folder)
WHERE id(n) = 24
RETURN childs
Actually i want to copy values from child case to Parent Case, i have add smart shape called "Update Case",But there was an error during the sub case process,
"com.pega.pegarules.pub.generator.UnresolvedAssemblyError: Failed to find instance CTC-FW-CeylonTrFW-Work-VehiclePolicy.UpdateParentCase",
parent case is : CTC-FW-CeylonTrFW-Work-VehiclePolicy
Child Case is : CTC-FW-CeylonTrFW-Work-AssessVehicle
Here Attached with screen shoots
Could you please help me to solve this issueenter image description here
The error is very clear.
Your UpdateParentCase should be present in parent class CTC-FW-CeylonTrFW-Work-VehiclePolicy.
How to use if and else condition in robotframework ,If 'A'node as a child it should click the child node, else it should click node 'B'.
xpath=(.//*[#id='functionals-tab-content']/ul/li/ul/li[${to clickplus firstplus}]/ul/li[${child node click value}]/ul/li[${child node click value1}]/div[1]/a)--- child node of A.
xpath=(.//*[#id='functionals-tab-content']/ul/li/ul/li[${to clickplus firstplus}]/ul/li[${child node click value}]/ul/li[${child node click value1}])--- B node.
"Run Keyword If Element Should Be Visible child node of A. click element child node of A
Run Keyword Unless Element Should Be Visible B node. click element B node.
If give like this its not exceuting throwing error. how to write if and else condition for this. can anyone help me.
Run keyword if requires a python expression; you can't substitute that with a keyword. You'll have to split your statements into two. First, call your keyword and save the result, and then use the result in the if statement.
${result}= Run keyword and ignore error Element should be visible ${node A}
Run keyword if '${result[0]}' == 'PASS'
... click element ${node A}
... ELSE
... click element ${node B}
An example using Run keyword if and Run keyword and ignore error is included in the documentation for the built-in library (specifically, in the documentation for Run Keyword If)
Note: Run keyword and ignore error returns a tuple of two values. The first value will be the string 'PASS' or 'FAIL'.
Note: the use of continuations (...) is not necessary to make the keywords work. Personally I find they make the code considerably easier to read than if you try to put all of that on a single line.
In ClearCase, I would like to see a list of all the files that I am viewing on a certain branch (if I have branch Br I would like a list of all the files that I am viewing a version of them in that branch). Is that possible?
Why not just use...
cleartool find . -all -nvisible -element 'brtype(Br)' -print %CLEARCASE_PN%
The above is supposed to find all elements (even invisible to this view) with the branch BR, and print the pathnames.
The simplest solution would be to:
create a dynamic view
set the right config spec with the relevant element selection rules you want in order to list all the right files.
Don't forget a branch exists independently from files: when you create a branch, no file is affected. Only the file with at least one checked-out version will register in that branch (within their tree view).
See "How to find a Parent Label of a branch in Clearcase" for illustration.