Data Structure Algorithms Articles

Page 24 of 24

Binary Trees and Properties in Data Structures

Arnab Chakraborty
Arnab Chakraborty
Updated on 27-Aug-2019 4K+ Views

In this section we will see some important properties of one binary tree data structure. Suppose we have a binary tree like this.Some properties are −The maximum number of nodes at level ‘l’ will be $2^{l-1}$ . Here level is the number of nodes on path from root to the node, including the root itself. We are considering the level of root is 1.Maximum number of nodes present in binary tree of height h is $2^{h}-1$ . Here height is the max number of nodes on root to leaf path. Here we are considering height of a tree with one ...

Read More

Binary Tree Representation in Data Structures

Arnab Chakraborty
Arnab Chakraborty
Updated on 27-Aug-2019 17K+ Views

Here we will see how to represent a binary tree in computers memory. There are two different methods for representing. These are using array and using linked list.Suppose we have one tree like this −The array representation stores the tree data by scanning elements using level order fashion. So it stores nodes level by level. If some element is missing, it left blank spaces for it. The representation of the above tree is like below −12345678910111213141510516-81520-------23The index 1 is holding the root, it has two children 5 and 16, they are placed at location 2 and 3. Some children are ...

Read More

Step Count Method in Algorithm

Arnab Chakraborty
Arnab Chakraborty
Updated on 27-Aug-2019 11K+ Views

The step count method is one of the method to analyze the algorithm. In this method, we count number of times one instruction is executing. From that we will try to find the complexity of the algorithm.Suppose we have one algorithm to perform sequential search. Suppose each instruction will take c1, c2, …. amount of time to execute, then we will try to find out the time complexity of this algorithmAlgorithmNumber of timesCostseqSearch(arr, n, key)i := 0while i < n, do   if arr[i] = key, then      break   end ifdonereturn i1n+1n0/11c1c2c3c4c5Now if we add the cost by multiplying the ...

Read More

Dynamic Programming in JavaScript

Samual Sam
Samual Sam
Updated on 30-Jul-2019 3K+ Views

Dynamic programming breaks down the problem into smaller and yet smaller possible sub-problems. These sub-problems are not solved independently. Rather, results of these smaller sub-problems are remembered and used for similar or overlapping sub-problems. Dynamic programming is used where we have problems, which can be divided into similar sub-problems so that their results can be re-used. Mostly, these algorithms are used for optimization. Before solving the in-hand sub-problem, the dynamic algorithm will try to examine the results of the previously solved sub-problems. The solutions of sub-problems are combined in order to achieve the best solution. For a problem to be ...

Read More
Showing 231–234 of 234 articles
« Prev 1 20 21 22 23 24 Next »
Advertisements