Use a tree or a list or something else?
Hello all...I need to create a sort of "family tree". I'm given a String[] where each entry will either be of the form "child parent" or "person gender". If its in the form "child parent" I know that the family tree has child as a child of parent. If its in the form "person gender", I know what that persons gender is. I need to go through this array of strings making sure that each child has at most two parents which must be of the opposite sex, and that no child is its own descendant (eg. If Bob is a child of Sue who is a child of Joe, Joe better not be a child of Bob). What I need to report is the index of the String[] where this fails.
Hopefully that's a clear explanation.
Here's an example:
{"BOB JOHN","BOB MARY","MARY JOHN","JOHN f","MARY f","AL f"}
Returns: 4
The first 4 elements are considered consistent. They describe that BOB's 2 parents are JOHN and MARY and that (unconventionally) MARY is JOHN's child. JOHN is female. But "MARY f" is inconsistent with this since that makes both of BOB's parents female.My first thought was to store this as a Tree but since a parent can have lots of children and a child can have two parents and I may be adding parents before I know their genders and then having to go through and modify things. It seems too complex. Then I thought to store it as an arraylist. But I still run into problems where if I modify things I have to search through many different places to make sure I reflect it everywhere and everything still holds true.
What do you guys think? I can post some other examples if its still unclear
You should probably approach this problem by breaking it down into some general processing steps. As an example, you probably can't check for required conditions - like gender, parentage, etc - until you have processed the whole set of input. That suggests you will have at least two stages:
Build up structures.
Do the condition checking.
What kinds of structures would you use to do the condition checking?
Hint: Just one structure probably isn't going to hack it.
Hint: For starters, yoou probably need a list of persons.
Hint: Each person should have a gender.
Hint: You need to be able to check for parents of each person.
Hint: You need to check for circles in the parenting.
Similar Messages
-
How can I do mirroring of a screen from new iPad to hdtv using apple tv and still work on something else in my ipad
You don't. Mirroring is duplicating your ipad screen on another projector - so you can't have another app going on your iPad without it also showing up on the projected image. Some apps are designed so that you see a different image in the iPad than the mirrored out display, but even then you're within the app itself.
-
While I was using Spotlight to search for an app. I came across a .PDF file related to my job. However, it's not in the finder nor in the documents folder. As matter of fact, it's not even listed in the PDF files section. I can open it using Spotlight.....but I can't find it. It it on my Inbox? Do I have files lurking around in my computer without me knowing about them? Also I don't remember downloading said file. It's not harmful it's just a simple 32-page .PDF file that contains information on my company policies. But where is it and how did get there?
If you hold down the option key, it will typically show the location. Or you can often hit option-return on the file and it will reveal the file in the Finder, instead of opening it.
Final option is to open it, and just option-click the filename in the toolbar of Preview and it should show you the location.
It's probably an attachment to an email you've received. If you have Mail set to cache emails and their attachments it'll be stashed in a subdirectory of ~/Library/Mail. Which is fine. -
Should I use a CASE statement to accomplish or something else
So I have the following query right now
select *
--bulk collect into possession_leaders
from
select distinct
opt.team_id,
sch.game_code,
sch.game_code_1032,
sch.home_team_id_1032,
sch.home_team_id,
sch.home_team_name,
sch.home_team_nickname,
sch.home_team_abbrev,
sch.away_team_id_1032,
sch.away_team_id,
sch.away_team_name,
sch.away_team_nickname,
sch.away_team_abbrev,
opt.possession,
rank () over (order by possession desc) as rankings_order
from
customer_data.cd_soccer_schedule sch,
soccer.soccer_optical_team_gm_stats opt
where sch.game_code = opt.game_code
and sch.season_id = 200921
and opt.possession is not null
order by rankings_order asc
)It outputs the following (Sorry for it being so cramped together):
**Note: Columns are in the same order as the query, I didn't post the column names b/c everything would look even sloppier then it does
1 5358 870986 2009050606 6 5359 Kansas City Wizards KC 5 5358 D.C. United DC 69.5% 1
2 5354 870945 2009040501 1 5354 Chicago Fire Chi 10 5362 New York Red Bulls RB 58.1% 2
3 5721 870983 2009050211 11 5363 San Jose Earthquakes SJ 17 5721 Chivas USA Chv 56% 3
4 5360 870984 2009050207 7 5360 Los Angeles Galaxy LA 10 5362 New York Red Bulls RB 55.6% 4
5 5361 870961 2009041705 5 5358 D.C. United DC 9 5361 New England Revolution NE 55.4% 5
6 5362 870988 2009050810 10 5362 New York Red Bulls RB 11 5363 San Jose Earthquakes SJ 50.1% 6
7 5363 870988 2009050810 10 5362 New York Red Bulls RB 11 5363 San Jose Earthquakes SJ 49.9% 7
8 5358 870961 2009041705 5 5358 D.C. United DC 9 5361 New England Revolution NE 44.6% 8
9 5362 870984 2009050207 7 5360 Los Angeles Galaxy LA 10 5362 New York Red Bulls RB 44.4% 9
10 5363 870983 2009050211 11 5363 San Jose Earthquakes SJ 17 5721 Chivas USA Chv 44% 10
11 5362 870945 2009040501 1 5354 Chicago Fire Chi 10 5362 New York Red Bulls RB 41.9% 11
12 5359 870986 2009050606 6 5359 Kansas City Wizards KC 5 5358 D.C. United DC 30.5% 12What i'm trying to do is basically have the output formated so that when the team_id column matches the either the home_team_id or away_team_id colum i want the following columns to be renamed as:
so if team_id = home_team_id for example then I want the following...
sch.home_team_id_1032 as team_code_1032,
sch.home_team_id as team_code,
sch.home_team_name as team_name,
sch.home_team_nickname as team_nickname,
sch.home_team_abbrev as team_abbrev
and then the away team columns would be...
sch.away_team_id_1032 as opp_team_code_1032,
sch.away_team_id as opp_team_code,
sch.away_team_name as opp_team_name,
sch.away_team_nickname as opp_team_nickname,
sch.away_team_abbrev as opp_team_abbrev
and same thing vice versa if the team_id column matches the away_team_id
How is the best way to go about this? W/a case statement? and if so can someone please post the logic/Hi,
user652714 wrote:
So I have the following query right now
select *
--bulk collect into possession_leaders
from
select distinct
opt.team_id,
sch.game_code,
sch.game_code_1032,
sch.home_team_id_1032,
sch.home_team_id,
sch.home_team_name,
sch.home_team_nickname,
sch.home_team_abbrev,
sch.away_team_id_1032,
sch.away_team_id,
sch.away_team_name,
sch.away_team_nickname,
sch.away_team_abbrev,
opt.possession,
rank () over (order by possession desc) as rankings_order
from
customer_data.cd_soccer_schedule sch,
soccer.soccer_optical_team_gm_stats opt
where sch.game_code = opt.game_code
and sch.season_id = 200921
and opt.possession is not null
order by rankings_order asc
)It outputs the following (Sorry for it being so cramped together):
**Note: Columns are in the same order as the query, I didn't post the column names b/c everything would look even sloppier then it doesAre you sure?
The 6th column in the query is home_team name; the 6th column of the output has values like 5359 and 5354. Did you perhaps duplicate the rankings_iorder column at the beginning of the results?
Why don't you simplify the problem. Instead of 15 or 16 columns, 10 of which are twins (5 pairs of 2 columns), why don't you post a problem with 6 columns, 4 of which are twins? Pick short columns, such as home_team_abbrev rather than home_team_name.
Adding the other columns later should be easy; merely a matter of coping one of the columns ion the solution.
Whenever you have a problem, post some sample data and the results you want from that data.
In this case, the sample data can be about 6 columns from the result set below. I'll bet you can make a good sample set with fewer than 12 rows, also.
1 5358 870986 2009050606 6 5359 Kansas City Wizards KC 5 5358 D.C. United DC 69.5% 1
2 5354 870945 2009040501 1 5354 Chicago Fire Chi 10 5362 New York Red Bulls RB 58.1% 2
3 5721 870983 2009050211 11 5363 San Jose Earthquakes SJ 17 5721 Chivas USA Chv 56% 3
4 5360 870984 2009050207 7 5360 Los Angeles Galaxy LA 10 5362 New York Red Bulls RB 55.6% 4
5 5361 870961 2009041705 5 5358 D.C. United DC 9 5361 New England Revolution NE 55.4% 5
6 5362 870988 2009050810 10 5362 New York Red Bulls RB 11 5363 San Jose Earthquakes SJ 50.1% 6
7 5363 870988 2009050810 10 5362 New York Red Bulls RB 11 5363 San Jose Earthquakes SJ 49.9% 7
8 5358 870961 2009041705 5 5358 D.C. United DC 9 5361 New England Revolution NE 44.6% 8
9 5362 870984 2009050207 7 5360 Los Angeles Galaxy LA 10 5362 New York Red Bulls RB 44.4% 9
10 5363 870983 2009050211 11 5363 San Jose Earthquakes SJ 17 5721 Chivas USA Chv 44% 10
11 5362 870945 2009040501 1 5354 Chicago Fire Chi 10 5362 New York Red Bulls RB 41.9% 11
12 5359 870986 2009050606 6 5359 Kansas City Wizards KC 5 5358 D.C. United DC 30.5% 12What i'm trying to do is basically have the output formated so that when the team_id column matches the either the home_team_id or away_team_id colum i want the following columns to be renamed as:
so if team_id = home_team_id for example then I want the following...
sch.home_team_id_1032 as team_code_1032,
sch.home_team_id as team_code,
sch.home_team_name as team_name,
sch.home_team_nickname as team_nickname,
sch.home_team_abbrev as team_abbrev
and then the away team columns would be...
sch.away_team_id_1032 as opp_team_code_1032,
sch.away_team_id as opp_team_code,
sch.away_team_name as opp_team_name,
sch.away_team_nickname as opp_team_nickname,
sch.away_team_abbrev as opp_team_abbrev
and same thing vice versa if the team_id column matches the away_team_idSorry, column names have to stay the same throughout the query. This is a very unusual request, and it's hard for me to imagine what you really want.
You miight be able to do a UNION and add rows that look like column headings.
No kidding, you have to post the results you want.
No matter how clear an idea you have of what those resutls should be, no one else knows, and it's much easier to post the correct results than to accurately describe them. -
?
Did it work in previous sessions? If so, suggest that you reset the tool.
To do that, there should be a little arrow on the tool's option bar, top left. Click on it, then reset. -
Using the display on something else than a computer
Is there any way to use the 20-inch Cinema Display on something else than a computer? Such as using it as an external monitor for my HD camera? I'm shooting a short film, and I was wondering if such a display could serve as a video assist.
Thanks.Apple displays aren't much use for any other purpose besides computer monitors. You can use add-on hardware to make them more flexible, but the add-on is so expensive you could almost buy another monitor.
http://www.gefen.com/kvm/product.jsp?prod_id=4173 -
Hi, I was looking to see if anyone knows how I can troubleshoot my connection problem with TFS view in excel. I'm trying to produce a tree view in Office 2013 as described in the following KB -
https://msdn.microsoft.com/en-us/library/dd286627.aspx
I have followed the instructions on the KB all the way up to : 'Add backlog items and tasks and their parent-child links using a tree list' and at this point I can't seem to get it to work as the button is greyed out.
Note that I have completed steps 1-6 for the previous procedure... all 6 steps work just fine. However on step 2 of the second procedure - the instructions state I should be able to 'Add Tree Level' - However the button is greyed out.
Anyone know what I need to do to enable the button to use the tree list in excel?
FrankFrank,
I believe your issue is that you have opened a Flat query and are trying to add tree levels. A flat query is just that and you cannot change the query type from Excel.
The second process is managing a backlog (which is a tree). TFS web access has a link on the backlog view to create a query. That query will be a "tree of work items" query that returns the items in the backlog including their parent-child relationships.
This type of query supports the Add Tree Level and Add Child functionality as does a new Input List (not bound to an existing query).
"You will find a fortune, though it will not be the one you seek." -
Blind Seer, O Brother Where Art Thou
Please Mark posts as answers or helpful so that others may find the fortune they seek. -
Using JavaScript to create reports listing security settings
Hi...I'm trying to create an Acrobat 8 batch process using a JavaScript that creates a log/report that lists the security settings for each PDF in a directory. I want to be able to periodically run this script so that I can ensure that (a)each file uses the departmental permissions password and (b) that the set of permissions (copying not allowed etc.) are set according to our standard.
I've looked at the JavaScript reference etc. but am seriously confused. There's a securityhandler object but how can I use that (or something else) to get a list of the doc's security permissions and to check that password x has been used?
Many thanks.You can try using Auditpol.exe: http://technet.microsoft.com/en-us/library/cc731451%28v=ws.10%29.aspx
This
posting is provided "AS IS" with no warranties or guarantees , and confers no rights.
Microsoft
Student Partner 2010 / 2011
Microsoft
Certified Professional
Microsoft
Certified Systems Administrator: Security
Microsoft
Certified Systems Engineer: Security
Microsoft
Certified Technology Specialist: Windows Server 2008 Active Directory, Configuration
Microsoft
Certified Technology Specialist: Windows Server 2008 Network Infrastructure, Configuration
Microsoft
Certified Technology Specialist: Windows Server 2008 Applications Infrastructure, Configuration
Microsoft
Certified Technology Specialist: Windows 7, Configuring
Microsoft
Certified Technology Specialist: Designing and Providing Volume Licensing Solutions to Large Organizations
Microsoft Certified IT Professional: Enterprise Administrator
Microsoft Certified IT Professional: Server Administrator
Microsoft Certified Trainer
Thanks but I guess, auditpol ca be used only to manipulate system audit policies. how do I specify a folder and user in auditpol ? I could not find or understand how folder can be included with auditpol command line options.
Thanks ! -
I would like to display a Tree report in a list.
I zeroed in on the following function group SEUT which contains the following
function module RS_TREE_LIST_DISPLAY.
Can some one provide me with the procedure to follow to go about using the
functions in the Function group in order to achieve a display of the hierarchical
tree in a list ???Hi
Go to tcode DWDM>Controls->Tree Controls.
you will find examples of program....
(OR)
Tcode SE83 -->Tree control....
Reward points for useful Answers
Regards
Anji -
DTW Production tree headers - price list
I have 2000+ production Bom's headers that I would like to update via DTW. I want to change the price list on the header. The field on the OITT file is PriceList but the DTW template for production trees does not have this field on it. I know the DTW production tree lines template has price list & price fields on them to update ITT1 but not the header. Does anyone know the field name to use to update the price list number on the headers by DTW please?
Hi Gordon,
Thanks for the reply. It wasn't the answer I would have liked but that's the way it is sometimes.
Regards,
Stuart J. -
Hi All,
Unsure if this is a noodle scratcher or undoable!
Either way, does anyone know of a way when using the 'tree'
flash component in Director to get the component to supply a list
of some sort back to director.
I'm adding & subtracting branches to the Object
successfully, but I figure it must know whats where I just need it
to tell Director so I can manipulate it out to a XML file !!
CheersAlright, this is a long one. Make a Director file based on
the following and when it starts it’ll open the xmlDoc.xml
XML file, parse it into a Flash XML object and assign that object
as the dataProvider for a Flash component Tree. Then you can select
a planet node from the Tree, enter text into the Flash component
text field, and click the Flash button to add a moon to the
selected planet node with the entered text as its label. The button
also saves whatever XML makes up the tree to the xmlDoc.xml XML
file by calling the saveXml() function. You could have whatever
event you want call the save function.
To start, drag a Flash Tree component to the stage as sprite
1, a Flash TextInput component to the stage as sprite 2 and a Flash
Button component to the stage as sprite 3. Make sure to do
Modify>Movie>Xtras… and add the FileIo.x32 Xtra so
it’ll work if you make a projector.
Add this script to Frame one:
function exitFrame(me)
///// make Fileio obj, Flash XML obj, populate Tree
// Fileio
var fileObj = new xtra("fileio");
fileObj.openFile(_movie.path + "xmlDoc.xml",0);
var xmlString = fileObj.readFile();
fileObj.closeFile();
fileObj = null;
// Flash XML obj
var fTree = sprite(1);
var fXmlObj = fTree.newObject("XML");
fXmlObj.ignoreWhite = true;
fXmlObj.parseXML(xmlString);
// populate Tree
fTree.dataProvider = fXmlObj;
///// make button listerner to handle clicks
var fButton = sprite(3);
var fButtonEvt = fButton.newObject("Object");
fButton.addEventListener("click",fButtonEvt);
fButton.setCallback(fButton, "click",
symbol("fButtonClick"), "fButtonEvtScript");
Make this Movie Script, name it fButtonEvtScript:
function fButtonClick(me,evtObj)
var fTree = sprite(1);
var fText = sprite(2);
// determine if a Tree node is selected
try
String(fTree.selectedNode.attributes.label);
// execute if node selected is planet
if (fTree.selectedNode.nodeName == "planet")
var newNode = fTree.newObject("XMLNode",1,"moon");
// make node lable text field if text present, else default
text
if (fText.text == "")
newNode.attributes.label = "Default Moon";
} else {
newNode.attributes.label = fText.text;
// add new moon node
fTree.selectedNode.addTreeNode(newNode);
saveXml();
} else {
_player.alert("Must select planet node");
} catch (errObj) {
// alert no node
_player.alert("No Node Selected");
function saveXml()
var fTree = sprite(1);
// make string to save
var xmlString = "<?xml version=\"1.0\"
encoding=\"iso-8859-1\" ?>\n"
xmlString += fTree.dataProvider.firstChild.toString();
// save file
var fileObj = new xtra("fileio");
fileObj.openFile(_movie.path + "xmlDoc.xml",0);
fileObj["delete"].call(fileObj);
fileObj.createFile(_movie.path + "xmlDoc.xml");
fileObj.openFile(_movie.path + "xmlDoc.xml",0);
fileObj.writeString(xmlString);
fileObj.closeFile();
fileObj = null;
Finaly add this script to any Frame after Frame one; I used
Frame 10.
function exitFrame(me)
_movie.go(_movie.frame);
Here’s the XML file:
<?xml version="1.0" encoding="iso-8859-1" ?>
<star label="Sol">
<planet label="Mercury" />
<planet label="Venus" />
<planet label="Terra">
<moon label="Luna" />
</planet>
<planet label="Mars">
<moon label="Phobos" />
<moon label="Deimos" />
</planet>
<planet label="Jupiter">
<moon label="Callisto" />
<moon label="Ganymede" />
<moon label="Europa" />
<moon label="Io" />
</planet>
<planet label="Saturn">
<moon label="Titan" />
</planet>
<planet label="Uranus" />
<planet label="Neptune" />
<planet label="Pluto">
<moon label="Charon" />
</planet>
</star>
Sorry I got slack with the code comments, but I reckon you
can figure out what’s going on. I figure this’ll give
you a good start on what you’re trying to accomplish. I
strongly suggest checking out the LiveDocs for Director regarding
Flash and Components and Flash regarding Flash XML, XMLNode and the
Components Language Reference. Remember though, things have changed
since the Flash 8 Asset Xtra, so some of the documentation is out
of date. -
now that I just re-newed my photoshop photography ....I have not been using that for some reason I have been using something else. they had changed me a couple
of times last year from one thing to another ...so I never go photoshop photography downloaded. I used the other one very little because I wasn't sure I should...gee
I hope that makes sense.
I need to download photoshop photography.
Sherri nicholasYou need to get the owner's manual for your Ford's bluetooth system to see how to put your system into discovery mode for the iPhone as well as the appropriate steps to take.
In addition, you should see if the iPhone is supported. -
Using my TC as a bridge (or something like that)?
Hi. I have a first generation 500 GB Time Capsule (which I love).
In the past, I have used it either to create a wireless network, join a wireless network, or connect via ethernet with wireless disabled.
I wanted to try something else today, and I haven't figured out if it is possible or how to do it. I want to use the TC to connect to a wireless network (an unsecure network that I have no control over) and connect the Time Capsule to my computer with an ethernet cable, and in so doing be able to connect to that wireless network with Airport off on my computer. Can I do that?
Reading some other threads & articles, it seemed to me that I could do this by putting the Time Capsule in bridge mode (Manual Setup>Internet>Connection Sharing>Off (Bridge Mode)). But that doesn't seem to do what I want.
Is there a way to do this? Am I doing something wrong? Could I do it with Airport Express?
I'm using a Macbook 5,2 to set up the TC, but ultimately want to connect it in the way I described to an iMac PPC G4 (700 MHz).
Thanks.I want to use the TC to connect to a wireless network (an unsecure network that I have no control over) and connect the Time Capsule to my computer with an ethernet cable, and in so doing be able to connect to that wireless network with Airport off on my computer. Can I do that?
No, if you use the TC in join wireless mode, the ethernet ports are shut off.. it is a brilliant apple strategy.. the express can do this, neither the TC nor AEBS can.. hence you need to buy yet more apple equipment.. nifty eh!!
There are plenty of other products around that can.. just look for universal wireless bridge or repeater..
A lot of routers running dd-wrt can also do this cheaply.The wireless is probably not that fast so old wrt54gl from ebay for a few dollars will work nicely but look for broadcom chipset routers as they tend to do wireless bridge better than atheros wireless for instance.
http://dd-wrt.com/wiki/index.php/Supported_Devices -
I just got iphone 5c and i am not happy with it. It uses to much data and i don't even know how. I can't get the ringtones i want for my contacts.I got it on my free upgrade but i want to take it back and get something else but where i got it they say i can't because i don't have the earbuds and i have serches or them. now i am suck with a phone i don't like at all until my next upgrade. this is very dishearten
1. If you are this unhappy with that phone, and the lost earbuds is the only thing stopping you from taking it back, why do not just buy some earbuds. That way you can get rid of that phone. It all depend upon how much you want to get rid of that phone.
2. Yet if you are stuck with that iPhone, here is something might help you to control the data usage. By design, iPhones do turn off WiFi when they go dormant. So if a download is in progress and so forth when the phone goes dormant, it will switch to use cellular data, if this setting is left on. Therefore, from multi-sources I have learned that if you keep your iPhone connected to a power source, then it will stay connected to the available WiFi. -
Can I airplay a movie from safari on my MacBook to Apple TV and still use the computer for something else at the same time?
Hi frogjt,
Welcome to the Apple Support Communities!
Great question! You can absolutely do this in OS X 10.9. The attached article explains how the process of using AirPlay with Apple TV to create a second display. Also, towards the bottom of the article there are instructions on how to set your Displays preferences on the computer to make sure the TV and MacBook Pro displays are set up the way you want them to be.
OS X: Using multiple displays in Mavericks
http://support.apple.com/kb/HT5891
Have a great day,
Joe
Maybe you are looking for
-
I can no longer access my Time Capsule Data
I have a 2TB TimeCapsule connected wirelessly to my home Network via an Airport Express. I have an iMac and a MacBook Pro. I keep my documents on there, so I can access them from either device. Today when I tried to access my documents frm the iMac
-
To find where a variable is getting updated in a smart form thru debugging?
Hi Friends, This is urgently required. In transaction vf02 by putting the billing document no.and navigating as follows: billing document -> issue output to ->select the doc->print preview a smart form is generated. The issue that I am facing is that
-
Hi there, I'm new to LabView and I am unable to find a solution to the problem below. I have a VI which takes a number from a control, when the number control changes, the voltage on the appropriate channel changes and it works fine however. it is fo
-
Goods Issue for Reservation using Bar Code System
Hi, Our client wants to use RF devices to post the goods issue for reservations (movement 261) and reversals of these movements (262). I have checked the RF t codes and I do not see this functionality available. Typically client wants to select a res
-
Is there a way to completely reinstall my mail program?
I'm having serious problems with my Mail program and am thinking that maybe if I just completely reinstall Mail on my MacBook Pro, that might help. How would I go about this? (And is there a way to do it without using those discs you get when you buy