Posts

Showing posts with the label Data Structures

Is There A Route Between Two Nodes Graph Problem | letsbug

      Find Route Between Two Nodes Graph Problem       Hi everyone in this article we are going to see how to solve the problem of finding route between two nodes of a graph.      Before we start let's make sure that you know a little bit about graphs data structure and how to traverse through a graph.  code:  const testG = {     'A' : [ 'B' , 'C' ],     'B' : [ 'D' , 'F' , 'E' ],     'C' : [ 'F' ],     'D' : [],     'E' : [ 'F' ],     'F' : [],     'G' : [] } const path = ( graph , start , end ) => {     if ( start == end ) return true     const queue = [ start ]     const visited = {}     visited[ start ] = true     while (queue.length) {         const node = queue. shift ()         const neighbors = graph [node]         for ...

Breadth First Search Algorithm In Javascript | letsbug

Image
      In this article we are looking at how we can implement the Breadth First Search in Javascript with recursion . We are not going to waste time so let's just start. Breadth First Search In Javascript     In the below code first we have declared a graph. And this representation of graph is called   adjacency matrix . We have represented the nodes with the key in the graph and connection to other nodes is represented with the value array of the graph object.     Then we have the traverse arrow function which takes in two parameter one is the graph object itself and a starting node. And the function start with creating a visited empty object and a array called queue with the connection of the first node of graph.     And then we initialize the visited object with the first node of the and set it to true. So that we know that we have visited it and do not fall into a infinite cycle.      We then have a helper function in...

Data Structure GRAPH Definitions And Terminology | letsbug

1.  What is a Graph?      - A graph G is a set of two tuples G = ( V, E ), where V is finite non-empty set of vertices and E is the set of pairs of vertices called edges.  2. Adjacent Vertex      - When there is an edge from one vertex to another then these vertices are called adjacent vertices. 3. Cycle      - A path from a vertex to itself is called a cycle. Thus, a cycle is a path in which the initial and final vertices are same. 4.  Complete Graph      - A graph G is said to be complete if every vertex in a graph is adjacent to every other vertex. In this graph, number of edges = n ( n - 1 ) / 2, where n = Number of vertices. 5.  Connected Graph      - An undirected graph F is said to be connected if for every pair of distinct vertices Vi, Vj in V(G) there is a path from Vi to Vj.  6.  Degree of a Vertex      - It is the number of edges incident to a vertex. It is ...

Data Structure TREE Definitions And Terminology | letsbug

1. What is tree?      - A Tree is  a finite set of one or more nodes such that : There is a specially designated node called the root.  Remaining nodes are partitioned into (n >= 0) disjoint sets T1, T2, ..., Tn where each of these sets is a tree. Each T1, T2, T3 .... Tn are called sbu trees of the root. 2. Leaf Node     - In a tree data structure, the node which does not have a child is called as Leaf Node. 3. Height of tree     - In a tree data structure , the total number of edges from leaf node to a particular node in the longest path is called as height of the Node. In a tree, height of the root node is said to be height of the tree. 4.  Depth of tree      - In a tree data structure, the total number of edges from root node to a particular node is called as DEPTH of that Node. In a tree, the total number of edges from root node a to a leaf node in the longest path is said to be Depth of the tree. 5.  Node...

Lowest Common Ancestor Of Binary Tree In Python | letsbug

      Hey in the article we are looking at a coding challenge problem. You might have come across this it is called finding the lowest common ancestor in a binary tree.      So we will find the solution to this problem in python. Let's start. The answer is simple we have to visit every node and check if its child is same as it is asked if so then you return the node and we repeat this process for subtrees of  the tree and then if left and right node exit we return it. to the top. code:  class Node :     def __init__ (self,data):         self . data = data         self . left = None         self . right = None class binaryTree :     def __init__ (self):         self . root = None     #inserts a node in binary tree     def insert (self,data):         if ( self . root == None ):     ...

Multiple Choice Questions On Tree Data Structures | letsbug

  MCQs On Tree Data - Structure

Multiple Choice Questions On Graph Data Structures | letsbug

  MCQs On Graphs Data - Structure

Create A Binary Search Tree In Python | letsbug

      Binary Search Tree is a  tree data structure  where binary tree is either empty or non-empty. if it is non-empty then every node contains a key which is distinct and satisfies the following properties: Values less than its parents are places at left side of the parent node. Values greater than its parent are placed at right side of the parent node. The left and right subtree of are given again binary search trees.      In this article we going to implement binary search tree in python language. Binary Search Tree we are going to implement it with linked nodes and not a array.  Binary Search Tree In Python          So first we will create a node class and then a binary tree class. After that we will implement some methods to the binary tree     List of methods that we will implement in the binary tree are : insert  preOrder treversal postOrder treversal inOrder treversal levelOrder treversal heigh...

How To Create A Linked List In Javascript | letsbug

      Hi in this article we are learning how we can implement linked-list in javascript. We have already seen how we can implement stack data structure using linked lists and we are looking at the linked list themselves.     Linked list is a linear data structure which is more flexible than array . That is what i have to say about on defining them. You can learn more about them online we will just focus on implementing them in javascript. And perform operations on them.     List of operation on linked list that we will implement are: insert()  append() print() length() deleteLast() deleteFirst() findAt()     We are implementing the singly linked list in which every node is linked with a next node. Which means node store the address of the node which will come next to it. But does not know or store from where is has come from or its previous node. Linked List In Javascript Code:   // Constructor Class for Ndoes class Node { ...

Linked List Representation Of Stack Data Structure In Javascript | letsbug

Image
      In the article we are going to implement the data structure called stack . If you don't know about them you can visit my previous blog article for the same by clicking here . In this article we are going the implement the stack but not with array but with linked list .     Now what is linked list? You can say linked list is data structure when one single linear data structure is made by linking many smaller nodes like a chain. To learn more about it please visit here.      We will create a Node class which will be are individual node with next pointer and data property to store the data. Then we will link them in the stack class. And perform stack operations on the linked list.     So let's get started      Linked List Representation Of Stack     Our Stack will have following methods or operations on it. Push() Pop() Peek() isEmpty() print() reverse() length() code: //create node class class Node { ...

Data Structures MCQs with answers parts 2 - letsbug

   Here is another 25 sets of   Data structures MCQs with answers. To view previous set click here 1. Which of the following is false about a circular linked list? Every node has a successor Time complexity of inserting a new node at the head of the list is O(1)  Time complexity for deleting the last node is O(n) We can traverse the whole circular linked list by starting from any point Answer: 2  :  Time complexity of inserting a new node at the head of the list is O(1) 2. How many children does a binary tree have? 2  any number of children 0 or 1 or 2 0 or 1 Answer: 3  : 0 or 1 or 2 3. What is/are the disadvantages of implementing tree using normal arrays?  Difficulty in knowing children nodes of a node Difficult in finding the parent of a node Have to know the maximum number of nodes possible before creation of trees  Difficult to implement Answer: 3  : Have to know the maximum number of nodes possible before creation of trees 4....

Categories

Big Data Analytics Binary Search Binary Search Tree Binary To Decimal binary tree Breadth First Search Bubble sort C Programming c++ Chemical Reaction and equation class 10 class 10th Class 9 Climate Complex Numbers computer network counting sort CSS Cyber Offenses Cyber Security Cyberstalking Data Science Data Structures Decimal To Binary Development diamond pattern Digital Marketing dust of snow Economics Economics Lesson 4 Email Validation English fire and ice Food Security in India Footprints Without feet Forest And Wildlife Resources game Geography Geography lesson 6 glassmorphism Glossary Graph HackerRank Solution hindi HTML image previewer India-Size And Location Insertion Sort Internet Network Status Interview Questions Introduction to cyber crime and cyber security IT javascript tricks json to CSV converter lesson 2 lesson 1 lesson 2 Lesson 3 Lesson 6 lesson 7 Life lines of National Economy life processes Linear Search Linked List lowest common ancestor Machine Learning MCQs median in array Merge sort min and max of two numbers Moment Money and Credit My Childhood Natural Vegetation and Wildlife NCERT Network connectivity devices Network Models Network Security No Men Are foreign Node.js operator overloading P5.js PHP Physical features of India Population Prime Numbers python Quick sort R language Rain on the roof Regular Expression Resources and development reversing array saakhi science Searching Algorithm Selection sort Social Media Marketing social science Software Engineering Software Testing Sorting Algorithm Stacks staircase pattern System Concepts Text Recognition The last Leaf time converter Time Passed From A Date Todo List App Tree Trending Technologies Understanding Economic Development username and password video player Visualization water resources Wired And Wireless LAN साखी
Show more

Popular Posts

Big Data MCQs(multiple choice questions) with answers - letsbug

Making 16 Beads Game In HTML CSS And Javascript | battisi | letsbug

How To Submit Username And Password In HTML And PHP- letsbug