Helper names and input conventions depend on the language. Java requires explicit imports; the Python, JavaScript and C++ names listed below are available directly. See the complete-program guides for Java, JavaScript, Python and C++.
| Operation | JavaScript | Python | C++ | Java |
|---|---|---|---|---|
| Node | new ListNode(value, next) | ListNode(value, next) | ListNode<T>(value, next) | Import stay.structures.ListNode |
| Build from values | createLinkedList(values) | create_linked_list(values) | createLinkedList(vector<T>) | Connect constructed nodes |
| Convert to array | linkedListToArray(head) | linked_list_to_array(head) | Not provided; follow next | Not provided; follow next |
Building from an empty array returns null, None or nullptr. Nodes expose val and next.
JavaScript TreeNode, Python TreeNode, C++ TreeNode<T> and Java stay.structures.TreeNode<T> expose val, left and right. Import the Java type explicitly.
JavaScript createBinaryTree(values) and Python create_binary_tree(values) consume compact level-order arrays: only existing parents consume child positions; null or None marks an absent child. binaryTreeToArray(root) and binary_tree_to_array(root) return the same format without trailing missing children. Empty input or an absent root creates an empty tree; converting an empty tree returns an empty array.
C++ createBinaryTree(vector<T>) uses complete-tree positions: children of index i are at 2i+1 and 2i+2; -1 marks an absent node. The same tree above needs vector<int>{1, -1, 2, -1, -1, 3}. C++ does not provide binaryTreeToArray. Java does not provide array/tree conversion helpers; construct and connect its nodes directly.
JavaScript provides Stack, createStack(values) and stackToArray(stack); Python provides Stack, create_stack(values) and stack_to_array(stack). These creation helpers put the first input element at the top. Conversion returns pop order and preserves the stack.
An empty input creates an empty stack. Manually pushing 1, 2, 3 in that order puts 3 at the top. C++ uses standard stack operations push, top and pop; it does not provide createStack or stackToArray. Java can represent a stack with supported list operations; a Stack helper is not predefined.
JavaScript provides Queue, createQueue(values) and queueToArray(queue); Python provides Queue, create_queue(values) and queue_to_array(queue). Input may be a string or array. Conversion returns FIFO order and preserves the queue.
Empty-input behavior differs by language. Use Queue() for an empty Python queue object. C++ uses standard queue operations push, front and pop, without createQueue or queueToArray. Java can use supported LinkedList operations; a Queue helper is not predefined.
Use JavaScript createGraph(data, directed) or Python create_graph(data, directed). Both default to directed graphs. data maps node names to neighbors: arrays describe unweighted edges and mappings to numbers describe weighted edges. Pass false or False for undirected display, and include both directions in the adjacency input.
Java explicitly imports stay.structures.Graph: new Graph() is directed and new Graph(false) is undirected. C++ uses stay::Graph(directed, weighted), with both arguments defaulting to false. These types provide addNode, addEdge, neighbors, visitNode and visitEdge; node identifiers are strings. Java marks weighted edges through the three-argument addEdge; set the second C++ constructor argument to true for weighted display. Algorithms mark visits explicitly; reading neighbors alone does not count as a visit.
Execution, display-capacity and result-size limits still apply. Source-defined classes with the same names as helpers are not automatically the predefined diagram types.