N ' Ary Trees Data Structures [closed] - data-structures

It's difficult to tell what is being asked here. This question is ambiguous, vague, incomplete, overly broad, or rhetorical and cannot be reasonably answered in its current form. For help clarifying this question so that it can be reopened, visit the help center.
Closed 10 years ago.
I was looking at plenty of tree data structures and it is really confusing. Like I understand the basic Binary Trees(also its numerous implementations like the BST Red black trees etc)
But what i really need is some information on N'ary trees.
I need to study various types of N' ary trees and also their performance comparisons.
The only N' ary tree I have seen till now is B+ tree. I need to know which is the fastest N' Ary tree. i.e the most optimized time complexity wise, space complexity is no issue.

Generally, making something a K-ary tree, , does not give any asymptotic advantage over a binary tree (). For example, searching a a balanced binary tree can be done in time. Searching a balanced k-ary tree, will give you . Assuming is a constant, and for any other base, are equivalent asymptotically (the growth rates will be the same for large ). That is, is equivalent to for any and . Therefore, .
Practically, however, a k-ary tree might result in better memory access patterns, because each node contains nodes next to eachother, which means the height of the tree is shorter (wikipedia gives the height, , for a complete k-ary tree as , which is asymptotically the same for any constant ), and traversal might jump around less as well, since leaf nodes can contain multiple in-order keys.

Related

Given n coins, some of which are heavier, find the number of heavy coins? [closed]

It's difficult to tell what is being asked here. This question is ambiguous, vague, incomplete, overly broad, or rhetorical and cannot be reasonably answered in its current form. For help clarifying this question so that it can be reopened, visit the help center.
Closed 9 years ago.
Given n coins, some of which are heavier, algorithm for finding the number of heavy coins using O(log^2 n) weighings. Note that all heavy coins have the same weight and all the light ones share the same weight too.
You are given a balance using which you can compare the weights of two disjoint subsets of coins. Note that the balance only indicates which subset is heavier, or whether they have equal weights, and not the absolute weights.
I won't give away the whole answer, but I'll help you break it down.
Find a O(log(n)) algorithm to find a single heavy coin.
Find a O(log(n)) algorithm to split a set into two sets with equal number of heavy and light counts plus up to two leftovers (for when there are not even amounts of each).
Combine algorithms #1 and #2.
Hints:
Algorithm #1 is independent of algorithm #2.
O(log(n)) hints at binary search
How might you end up with O(log^2(n)) with two O(log(n)) algorithms?

check duplicates in binary tree [closed]

It's difficult to tell what is being asked here. This question is ambiguous, vague, incomplete, overly broad, or rhetorical and cannot be reasonably answered in its current form. For help clarifying this question so that it can be reopened, visit the help center.
Closed 11 years ago.
How can I check that my binary tree doens't contain duplicates?
Do you have an algorithm?
Please write the pseudocode
EDIT: or (better) using math property.
This is my Tree over an alphabet A: (a,U,V) where a \in A and U and V is respectively the left child and the right child.
If the tree is ordered like a binary search tree using a relation of ordering < (riflessive, antisymmetric, transitive, total) I can express that T=(a,U,V) is ordered without duplicates IFONLY \forall u \in flatten(U) and \forall v \in flatten(V). u < a< v and u \neq a and a \neq v and i've to check the property recursively for the tree U and tree tree V. But the question is: How can i check that the tree doesn't contains duplicates if the tree is not ordered (or is not a binary search tree)?
Apologise for my first not clear question
EDIT2: flatten is the function that return the set of the elements of the parameter tree
There is an O(n log n) obvious way, you collect the elements, sort the list and find duplicates. The problem is at least as hard as finding duplicates in an array see this. Therefore, if you rely only on comparisons, you cannot achieve better than O(n log n).
If the input is bounded, say, between the values 1 to 1000 then you can use an array, which we call A.
Go over each node with value val and let A[val]=1.
This way you mark all the elements that you encounter.
This one runs in O(n) and uses additional 1000 elements of space.

List of where various algorithms/structures pop up in web development [closed]

It's difficult to tell what is being asked here. This question is ambiguous, vague, incomplete, overly broad, or rhetorical and cannot be reasonably answered in its current form. For help clarifying this question so that it can be reopened, visit the help center.
Closed 11 years ago.
Could someone please list where some of the following algorithms/structures pop up in web development (I'm an aspiring web developer and I'm curious to know when these various topics pop up):
Bubble sort
Insertion sort
Selection
sort
Mergesort
Quicksort
Stack
Queue
Linked List
Binary Trees
Binary Search Trees
Balanced Binary Tree
AVL Trees
Splay Trees
Red-Black trees
Priority Queues
Hashing
Adjacency Linked Lists
Adjacency matrices
Graph
Traversals (Depth First Search,
Breadth First Search)
Minimum
Spanning Trees (Kruskal's algorithm,
Prim's algorithm)
Directed Graph
(Digraph)
Topological sort
The list is some topics that were covered in my Data Structures and Algorithms class. There might be some other important ones that I forgot to list as well.
Most of these are important for teaching concepts, and while some of them are commonly used in most applications (Stacks & Queues, e.g.), they don't really "pop up" the way you're describing.
It is important to understand the principles that these structures illustrate, and to know when to use a LinkedList vs an ArrayList. But as far as "when will I ever use this," it's awfully hard to point to a specific part of a website and say, "see, they used a binary search tree here."
For most web development, these can be grouped together.
Quite a bit of web development is going to use a SQL back-end. In a select statement, you can have an order by clause what will undoubtedly be implemented by one of the sorts you've named (or something similar such as intro-sort, which is mostly a fairly minor variation on Quicksort).
Likewise, you'll deal with associative arrays, which are typically implemented as either some sort of hash table or some sort of balanced tree -- but could also use a splay tree.
graphs and graph traversal don't figure heavily in your typical (e.g., e-commerce) web development. For some types of network management, however, it's typical to put such things as servers into nodes of a graph, with arcs to signify the network connections.
Most languages you use will use stacks implicitly, but it'll be fairly unusual to use them explicitly in typical web development.
Queues will depend. You're not likely to implement a queue, but if (for example) you deal with a distributed database, you'll probably end up using some sort of queue that it provides.

List of generic algorithms and data structures [closed]

It's difficult to tell what is being asked here. This question is ambiguous, vague, incomplete, overly broad, or rhetorical and cannot be reasonably answered in its current form. For help clarifying this question so that it can be reopened, visit the help center.
Closed 12 years ago.
As part of a library project, I want to include a plethora of generic algorithms and data structures. This includes algorithms for searching and sorting, data structures like linked lists and binary trees, path-finding algorithms like A*... the works.
Basically, any generic algorithm or data structure you can think of that you think might be useful in such a library, please post or add it to the list. Thanks! (NOTE: Because there is no single right answer I've of course placed this in community wiki... and also, please don't suggest algorithms which are too specialized to be provided by a generic library)
The List:
Data structures
AVL tree
B-tree
B*-tree
B+-tree
Binary tree
Binary heap
Binary search tree
Linked lists
Singly linked list
Doubly linked list
Stack
Queue
Sorting algorithms
Binary tree sort
Bubble sort
Heapsort
Insertion sort
Merge sort
Quicksort
Selection sort
Searching algorithms
Have you tried Wikipedia?
http://en.wikipedia.org/wiki/List_of_data_structures
http://en.wikipedia.org/wiki/List_of_algorithms
Algorithms, Data Structures.
There's already a resource for this sort of material. I'm voting to close as not a real question.

What are Splay tree, Red-black tree, AVL tree, B-tree and T-tree? [closed]

It's difficult to tell what is being asked here. This question is ambiguous, vague, incomplete, overly broad, or rhetorical and cannot be reasonably answered in its current form. For help clarifying this question so that it can be reopened, visit the help center.
Closed 10 years ago.
What are Splay tree, Red-black tree, AVL tree, B-tree and T-tree?
I'm looking for good implementations.
These are all data structures used for quickly searching binary data. Many are used by different data management systems.
They differ in their approach for storage of data. I'd recommend reading up on each.
Splay: http://en.wikipedia.org/wiki/Splay_tree
Red-Black: http://en.wikipedia.org/wiki/Red-black_tree
AVL: http://en.wikipedia.org/wiki/Avl_tree
B-Tree: http://en.wikipedia.org/wiki/B-Tree
T-Tree: http://en.wikipedia.org/wiki/T-tree
The Tree Data Structure article on Wikipedia would be a good starting point for anyone wanting to learn about different tree structures. I believe that all of the referenced structures have links on the main Tree Data Structure entry.
For implementations I would recommend looking at Cormen's Introduction to Algorithms text, also referenced at wikipedia. If you want concrete implementations, you'll need to specify your desired language.
http://en.wikipedia.org/wiki/Tree_data_structure
Besides the online resources I would also recommend you to get a real book about algorithms. I would strongly recommend Sedgewick:
Algorithms in C++
Algorithms in Java
These are great books that will teach various algorithms (trees, search, graphs, etc.).

Resources