Suppose I have the following
<ul>
<li>Item 1</li>
<li>Item 2
<ul>
<li>Sub Item</li>
</ul>
</li>
<li>Item 3</li>
</ul>
This list is auto-generated by some other code (so adding exclusive id's/class' is out of the question. Suppose I have some jquery code that states that if I mouseover an li, it gets a background color. How...
I've been scratching my head for several hours for this...
problem:
Binary Tree
(0) depth 0
/ \
10 20 depth 1
/ \ / \
30 40 50 60 depth 2
I am trying to write a function that takes depth as argument and return the sum of values of nodes of the given depth.
For instance, if I pass 2, it should return 180 (i.e. ...
Using JQuery or Javascript how would I return 'Mary Boone' from the xml below starting out with the show 'id' attribute of '2'?
I'm thinking something along the lines of -
var result = xml.getElementByAttribute("2").gallery.text();
the XML:
<shows>
<show id="1">
<artist>Andreas Gursky</artist>
<gallery>Matthew M...
Is it possible to have a foreach statement that will traverse through a Collections object in reverse order?
If not a foreach statement is there any other way? Thanks.
...
I have this html:
<div class="portlet-header">
Company Information ... <button> some button here </button>
</div>
<div class="portlet-content">
<div class="content_regular">
<table style=" width:100%; height:100%;">
...content
</table>
</div>
</div>
how do i get the hmtl after i click the butto...
Okay, Now I have an unordered list here:
<ul id="mycustomid">
<li><a href="url of Item A" title="sometitle">Item A</a>
<ul class="children">
<li><a href="url of Child1 of A" title="sometitle">Child1 of A</a>
<ul class="children">
<li><a href="url of Grandchild of A" title="sometitle...
Right so I'm creating a plugin using jquery what I have thus far is this. .
(function ($) {
$.fn.AppCompFunctionality = function () {
var defaults = {
};
var options = $.extend(defaults, options);
return this.each(function () {
$(this).click(function () {
var currentComps = $("#currentComps").get();
$(current...
I have a connected, directed, cyclic graph. The task is to discover every single node in the graph without falling into an infinite loop, as a regular tree traversal algorithm will do.
You can assume that I already know what node to start at so as to reach all points in the directed graph, and that for each node I have a function that w...
In-order tree traversal obviously has application; getting the contents in order.
Preorder traversal seems really useful for creating a copy of the tree.
Is there a common use for postorder traversal of a binary tree?
...
I have written the following code for constructing a tree from its inorder and preorder traversals. It looks correct to me but the final tree it results in does not have the same inorder output as the one it was built from. Can anyone help me find the flaw in this function?
public btree makeTree(int[] preorder, int[] inorder, int left,...
So i must say that i love this site because its sooooo helpful and now i have another question! my Huffman tree which i had asked about earlier has another problem! here is the code:
package huffman;
import java.io.FileNotFoundException;
import java.io.FileReader;
import java.util.ArrayList;
import java.util.PriorityQueue;
import java...
Hi,
I have a hashmap that I have created to control the events for buttons. It is defined as so:
var Signage_Manager = {
init: function() {
Signage_Manager.buttonActions.set_events();
},
buttonActions: {
buttons: {
'#add_product': {action: 'navigate', href: '/manager/add_product'},
'.back_to_dashboard': {act...
Hi,
So I've got a expanding/collapsing tree that I'm keeping track of in session data.
I want to be able to render the tree in Django based upon the session data.
I am saving the state with something like:
request.session['treedata'][item_id] = state # (0 or 1)
In my template for rendering, I'm looping through the items and for e...
Hi. I'm having some trouble writing a jQuery function and could use a little help. Here's what I'd like to accomplish:
I have a ul element with 5 li children. Elsewhere on the page, I have a container div with 5 div children. When I click a link in the third li, I'd like to hide the other divs and show only the third one.
Currently ev...
I have a tree represented as a nested vector. I want to have a generalization of indexed for trees, showing the index of each node like this,
(visit 42); => [0 42]
(visit [6 7]); => [0
; [[0 6]
; [1 7]]]
The naive implementation would use clojure.zip directly (as already asked here)
(defn visit [...
I came across solution given at http://discuss.joelonsoftware.com/default.asp?interview.11.780597.8 using Morris InOrder traversal using which we can find the median in O(n) time.
But is it possible to acheive the same using O(logn) time? The same has been asked here - http://www.careercup.com/question?id=192816
...
Hi, i just followed the answers provided in this question:
http://stackoverflow.com/questions/1310649/getting-a-modified-preorder-tree-traversal-model-nested-set-into-a-ul
I already built my database and is working properly, printing all the child and parent pages with the correct identation.
But, i want to make it like a web search. S...
I have a multidimensional matrix that can have any number of dimensions greater than one. Looking for an efficient algorithm that can visit every point in the matrix.
Some info about the code:
The matrix has value accessors like (although these aren't really relevant).
object value = matrixInstance.GetValue(int[] point);
matrixInsta...
Hi.
I am making an IM application for Android.
The application consists of a server and client, both residing on the android.
At startup, the applications register with a webserver.
If a client wants to send an IM to a server behind a NAT router, how this be done?
I heard of stun4j and jstun but found nowhere an example of their usage in...
Is there an algorithm that will allow me to traverse a weighted graph in the following manner?
Start at a specific node
Go through all vertecies in the graph
Do this in the least amount of time (weights are times)
End up at the starting node
...