Giter VIP home page Giter VIP logo

dsa-self-java-also-contains-solutions-of-many-problems-'s Introduction

DSA_JAVA

created own adt for array

created subsequence pattern

Sorting algorithms

AVL tree

the Height can be maintain while insertion in BST
(int height) should also be added in tree class where data is declared

void height(){
if(root==null)return -1;
return root.height;
}
The upper function will return -1 if root is null else return current height of root

NOW while inserting into BST just maintain the height of root before returning the root;
root.height= Math.max(height(root.left),height(root.right))+1;
the (+1) in the above code will increase the height by 1 when a new nood gets inserted in BST

BFS DFS

bfs dfs is a important searching techniqes of a Tree
In BFS, we perform level wise traversal of node using queue, when the upper level Nodes are traversed then we come to the lower level nodes.

BFS

Queue q= new LinkedList<>()
q.add(root)
while(!q.isEmpty){
itr=q.remove();
check if conditions for adding childs in queue
}

DFS

DFS is a top to bottom search
PREORDER , POSTORDER , INORDER is used in DFS
INORDER = > Inorder gives soted data of a BST
POSTORDER => postorder can be use when we want to delete tree

GOOGLE AMAZON (most asked)

Q-> populating next right node imnt perfect Binary Tree?

approach=>

the next is also provided hence only use LinkedList Logic to solve this question.

q= find elemets of tree from right side view

approach

traverse level wise and find the last node of each level, it can be found by using nested for loop inside while loop, inside will run till the complete level of tree and add last value

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    ๐Ÿ–– Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. ๐Ÿ“Š๐Ÿ“ˆ๐ŸŽ‰

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google โค๏ธ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.